-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add tokenizer tests and fix auto-compact calculation to account for max_tokens #7342
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
|
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 3 files
React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai
to give feedback, ask questions, or re-run the review.
extensions/cli/src/util/tokenizer.ts
Outdated
|
||
// Ensure we have positive space available for input | ||
if (availableForInput <= 0) { | ||
throw new Error(`max_tokens is larger than context_length, which should not be possible. Please check your configuration.`); |
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.
Error message is misleading when triggered by small context limits with default 35% reservation
Prompt for AI agents
Address the following comment on extensions/cli/src/util/tokenizer.ts at line 140:
<comment>Error message is misleading when triggered by small context limits with default 35% reservation</comment>
<file context>
@@ -117,20 +117,37 @@ export function calculateContextUsagePercentage(
/**
* Check if the chat history exceeds the auto-compact threshold
* @param chatHistory The chat history to check
- * @param modelName The model name
+ * @param model The model configuration
* @returns Whether auto-compacting should be triggered
*/
export function shouldAutoCompact(
chatHistory: ChatCompletionMessageParam[],
</file context>
Summary by cubic
Fix auto-compact to properly account for model max_tokens and prevent context overflow. Add unit tests for tokenizer functions and compaction logic.
Bug Fixes
Tests