-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add pruning fallback and character truncation for large context #8122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add compileChatMessages pruning as fallback when context length validation fails - Truncate Bash tool output by both lines (5000) and characters (200000) - Reuse existing pruning logic from core/llm/countTokens.js - Log pruning details when it occurs Fixes CON-4274 Generated with [Continue](https://continue.dev) Co-Authored-By: Continue <noreply@continue.dev> Co-authored-by: nate <nate@continue.dev>
|
I'd recommend a different truncation strategy for the bash output. Perhaps keep the last X lines from the end backwards to capture the outcome of tests and installs. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 2 files
RomneyDa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compile chat messages already supports unified history, no need to convert between the two. CLI should just always use compile chat messages, no need for a duplicate token counting validation step.
|
@continue also implement @chezsmithy's truncation recommendation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TomIsion thanks for the contribution! could you check cubic feedback and rebase main?
EDIT ignore this, mistaken comment
|
kicked off a session to address comments. |
…ation - Remove duplicate token validation logic; use compileChatMessages directly - Eliminate unnecessary conversions between unified history and ChatMessage formats - Change bash tool truncation to keep LAST X lines/chars instead of first X - Better captures test/install outcomes at the end of command output - Simplify pruning flow: always use compileChatMessages for context management Addresses feedback from @RomneyDa and @chezsmithy Co-authored-by: dallin <dallin@continue.dev>
|
I have read the CLA Document and I hereby sign the CLA 1 out of 2 committers have signed the CLA. |
Changes MadeAddressed the review feedback: 1. Simplified Context Handling (per @RomneyDa)
2. Improved Bash Tool Truncation (per @chezsmithy)
Technical DetailsThe changes reduce complexity by ~37 lines while improving functionality:
These changes make the code more maintainable and align with how |
Summary
This PR addresses CON-4274 by adding two improvements to handle large context in the CLI:
Pruning fallback: When context length validation fails before sending chat messages, we now use the existing
compileChatMessagespruning logic fromcore/llm/countTokens.jsas a fallback. This removes older messages while preserving the system message, tools, and the most recent user/tool sequence.Bash tool output truncation: The Bash tool now truncates output by both:
Whichever limit is hit first will trigger truncation with an appropriate message.
Changes
extensions/cli/src/stream/streamChatResponse.ts: Added pruning fallback inprocessStreamingResponsewhen context validation failsextensions/cli/src/tools/runTerminalCommand.ts: Added character-based truncation to Bash tool outputTesting
compileChatMessagesfunction from coreFixes CON-4274
This agent session was co-authored by nate and Continue.
Summary by cubic
Prevents oversized contexts from breaking CLI requests by always pruning chat history and truncating Bash tool output. Fixes CON-4274 and improves reliability with large conversations and long command results.
Written for commit fdcdcb6. Summary will update automatically on new commits.