-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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 <[email protected]> Co-authored-by: nate <[email protected]>
|
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 |
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 pruning chat history and truncating Bash tool output. Fixes CON-4274 and improves reliability with large conversations and long command results.