fix(coding-agent): bound btw side-query context - #826
Merged
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
/btwside-query prompts against the selected model's effective prompt window/compactmessage when mandatory prompt content cannot fitRoot cause
/btwcaptured and converted the current branch, then called the provider runtime directly without passing through the main-turn context pipeline. A large session could therefore send a raw side-query snapshot larger than the selected model accepted, even while the main turn's reduced context remained healthy.The reported screenshot reproduced the user-visible symptom:
Design
getPromptContextWindow()policy.modelRuntime.streamSimple, credential/header routing, no-tools mode, cancellation, synchronous snapshotting, and ephemeral history behavior unchanged.The refreshed
gajae-codeimplementation corroborates newest-first retention and oldest-context removal, but uses fixed 12-turn/64 KiB bounds. This PR intentionally uses Senpi's model-aware token machinery instead of copying those fixed limits.RED -> GREEN evidence
red-overflow.log— pre-fix context estimated 8,018 tokens against a 1,744-token budget.red-boundary.log— pre-fix context estimated 4,027 tokens against a 900-token budget.btw-side-query.test.tsplus regression /btw: No API provider registered for api: claude-agent-sdk #488, 16/16 passing.Evidence is preserved under:
Real CLI QA
Source-built Senpi RPC mode ran against an isolated local fake provider with a persisted oversized session.
Observed:
/btw 이거 draft PR은 이미 만들어져있는건가?returned aninfonotification/btwreturnedUsage: /btw <question>with no extra provider requestIndependent hands-on review also exercised a 1.08 MB / 49-entry real session: the unbounded request was approximately 293,511 tokens against a 56,000-token prompt window; the bounded request was 50,038 tokens and completed successfully.
Validation
npm run checknpm run buildnpx tsc --noEmitorigin/mainThe full coding-agent suite completed with 7,228 passed / 35 skipped and four load-sensitive failures outside this diff. Each failed test passed on isolated rerun:
Known conflict: PR #746
Open PR #746 changes the same BTW context builder to add prior BTW continuity. The features are complementary, not duplicates.
When resolving the landing order,
priorBtwmessages from #746 must be included in the message list before the final question and then flow throughboundSideQueryMessages(). Taking either PR'sbuildSideQueryContext()body wholesale would silently drop the other feature or reintroduce unbounded BTW growth.Reviewer results
Summary by cubic
Bounds
/btwside-query prompts to the selected model’s effective prompt window to prevent context-window overflows on large sessions. Preserves newest relevant context and the final question while leaving the main session history unchanged.getPromptContextWindow./compactmessage when mandatory content cannot fit.Written for commit 86b719d. Summary will update on new commits.