feat(chat): handle compact_context tool-result to trim message history#452
Open
anfibiacreativa wants to merge 1 commit into
Open
feat(chat): handle compact_context tool-result to trim message history#452anfibiacreativa wants to merge 1 commit into
anfibiacreativa wants to merge 1 commit into
Conversation
When da-agent triggers auto-compact and the model calls compact_context, replace the full message array with the compacted summary and persist to IndexedDB. The model's follow-up confirmation appends normally, giving a clean [summary, confirmation] state for the next turn. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
Commits
|
Open
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
compact_contexttool-result inchat-controller.jsto trim message history after server-triggered compactionWhy
compact_contexttoolWhat Changed
nx2/blocks/chat/chat-controller.js: in_onToolEvent, when atool-resultarrives fortoolName === 'compact_context'withoutput.compacted === true:this._messageswith a single synthetic user message{ role: 'user', content: summary, compacted: true }[compacted-summary, assistant-confirmation]Integration contract
tool-resultstream event wheretoolName === 'compact_context'andoutput.compacted === truewithoutput.summarycontaining the markdown summaryTest Plan
npx eslint nx2/blocks/chat/chat-controller.js)loadInitialMessagescorrectly loads compacted messages from IndexedDB (user role, string content passes the orphan filter)COMPACT_THRESHOLD_OVERRIDE=0.001, send enough messages to trigger compaction, verify history is trimmed in UI and IndexedDBRisks / Follow-ups
compacted: truemarker is there for future use) @sharanyavinod--no-verifyin sandbox, runnpm testlocally before pushing