Repository navigation
fix(coding-agent): compact before model requests - #241
Closed
Issacboy123 wants to merge 1 commit into
Closed
Issacboy123 wants to merge 1 commit into
Issacboy123 wants to merge 1 commit into
Conversation
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
Long tool loops could exceed the reserve threshold before the next compaction check. Checks before a prompt also missed the new input. This PR connects the request-preparation hook to automatic compaction. Each normal request checks its context after new input and tool results arrive, then continues with the rebuilt history.
Depends on
fix/bound-proactive-compaction-attempts.Reasoning
Checking at this point includes queued input and tool results. AgentSession still owns compaction and saves the result. Before rebuilding context, it verifies that live messages match the selected session history. If a hook changes messages so they no longer match, Diffex warns and continues with those messages. Changes made by later request-only transforms are outside the budget check.
Changes
Testing
node ../../node_modules/vitest/dist/cli.js --run test/agent-loop.test.ts test/agent.test.tsnode ../../node_modules/vitest/dist/cli.js --run test/suite/agent-session-compaction.test.ts test/agent-session-compaction.test.ts test/compaction.test.ts test/agent-session-auto-compaction-queue.test.ts test/suite/agent-session-prompt.test.ts test/suite/agent-session-queue.test.ts test/agent-session-stats.test.ts test/suite/agent-session-current-plan-restoration.test.ts test/session-manager/compaction-rollback.test.ts test/suite/regressions/pre-prompt-compaction-no-continue.test.ts test/suite/regressions/177-compaction-busy-state.test.ts test/suite/regressions/6647-compaction-retries-transient-stream-drop.test.ts test/suite/agent-session-context-usage.test.ts test/suite/agent-session-proactive-compaction.test.ts test/suite/subagent-coordination.test.ts test/suite/agent-session-request-compaction.test.tsnode ../../node_modules/vitest/dist/cli.js --run test/interactive-mode-compaction.test.ts test/print-mode.test.ts test/rpc-jsonl.test.ts test/rpc-prompt-response-semantics.test.tsnpm run check