-
Notifications
You must be signed in to change notification settings - Fork 4.1k
fix(cli): context length tweaks and terminal output truncation #9467
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
Conversation
Learn moreAll Green is an AI agent that automatically: ✅ Addresses code review comments ✅ Fixes failing CI checks ✅ Resolves merge conflicts |
1 similar comment
Learn moreAll Green is an AI agent that automatically: ✅ Addresses code review comments ✅ Fixes failing CI checks ✅ Resolves merge conflicts |
|
✅ Review Complete Code Review SummaryTroubleshooting
|
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 3 files
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.
1 issue found across 11 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="extensions/cli/src/util/tokenizer.ts">
<violation number="1" location="extensions/cli/src/util/tokenizer.ts:227">
P2: Empty enum array (`enum: []`) would subtract 3 tokens without adding any back, potentially resulting in negative token count. Consider adding a guard for empty arrays or ensuring `tokens` doesn't go negative.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| } | ||
|
|
||
| if (fieldEnum && Array.isArray(fieldEnum)) { | ||
| tokens -= 3; |
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.
P2: Empty enum array (enum: []) would subtract 3 tokens without adding any back, potentially resulting in negative token count. Consider adding a guard for empty arrays or ensuring tokens doesn't go negative.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At extensions/cli/src/util/tokenizer.ts, line 227:
<comment>Empty enum array (`enum: []`) would subtract 3 tokens without adding any back, potentially resulting in negative token count. Consider adding a guard for empty arrays or ensuring `tokens` doesn't go negative.</comment>
<file context>
@@ -196,16 +197,158 @@ export function calculateContextUsagePercentage(
+ }
+
+ if (fieldEnum && Array.isArray(fieldEnum)) {
+ tokens -= 3;
+ for (const e of fieldEnum) {
+ tokens += 3;
</file context>
| tokens -= 3; | |
| if (fieldEnum.length === 0) { | |
| return tokens; | |
| } | |
| tokens -= 3; |
✅ Addressed in d7b91f8
|
🎉 This PR is included in version 1.38.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.37.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |

Description
We already are very conservative about when to auto-compact, since we leave 35% or max tokens and then 80% of that, so compaction usually happens around 50% of actual context length. So it seems the only major cause of the context length exceeded issue is huge tool outputs.
Environment Variables
CONTINUE_CLI_BASH_MAX_OUTPUT_CHARSCONTINUE_CLI_BASH_MAX_OUTPUT_LINESCONTINUE_CLI_READ_FILE_MAX_OUTPUT_CHARSCONTINUE_CLI_READ_FILE_MAX_OUTPUT_LINESCONTINUE_CLI_FETCH_MAX_OUTPUT_LENGTHCONTINUE_CLI_DIFF_MAX_OUTPUT_LENGTHCONTINUE_CLI_SEARCH_CODE_MAX_RESULTSCONTINUE_CLI_SEARCH_CODE_MAX_RESULT_CHARSpartially a remake of #8122
Continue Tasks
Powered by Continue
Summary by cubic
Improves CLI output truncation and context length checks to prevent overflows. Keeps the most relevant output, counts system/tool tokens in auto-compaction, and adds configurable limits per tool.
New Features
Refactors
Written for commit d7b91f8. Summary will update on new commits.