feat(chat): handle compact_context tool-result to trim message history#452
Open
anfibiacreativa wants to merge 10 commits into
Open
feat(chat): handle compact_context tool-result to trim message history#452anfibiacreativa wants to merge 10 commits into
anfibiacreativa wants to merge 10 commits 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 <[email protected]>
|
Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
|
Merged
5 tasks
mhaack
reviewed
May 26, 2026
mhaack
approved these changes
May 26, 2026
mhaack
requested changes
May 26, 2026
- pass sessionId to saveMessages so compaction preserves the session - trim inline comment and move contract details to docs/chat-ui-component.md - document compacted message shape and compact_context event contract Co-authored-by: Cursor <[email protected]>
mhaack
previously approved these changes
Jul 14, 2026
Adds unit tests for the auto-compact branch in ChatController._onToolEvent: - replaces history with the compacted summary, clears tool cards, persists - keys off the tool-result toolName when there is no prior tool-call card - does not trim when compacted is not true - does not trim when summary is missing or not a string (malformed payload guard)
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