Skip to content

Conversation

@Wendong-Fan
Copy link
Member

Description

  • Fix token_limit property to correctly use user-provided value instead of always comparing with model's limit
  • Reset summary state when clearing memory to prevent stale token counts
  • Re-fetch context after summarization to use accurate token counts
  • Pass token_limit to context summarizer agents for consistent behavior
  • Remove reactive token limit error handling in favor of proactive summarization
  • Improve warning message in UnifiedModelType.token_limit to show model name

Checklist

Go over all the following points, and put an x in all the boxes that apply.

  • I have read the CONTRIBUTION guide (required)
  • I have linked this PR to an issue using the Development section on the right sidebar or by adding Fixes #issue-number in the PR description (required)
  • I have checked if any dependencies need to be added or updated in pyproject.toml and uv lock
  • I have updated the tests accordingly (required for a bug fix or a new feature)
  • I have updated the documentation if needed:
  • I have added examples if this is a new feature

If you are unsure about any of these, don't hesitate to ask. We are here to help!

@Wendong-Fan Wendong-Fan self-assigned this Dec 27, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 27, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch token_count_fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the Review Required PR need to be reviewed label Dec 27, 2025
@Wendong-Fan Wendong-Fan added this to the Sprint 45 milestone Dec 27, 2025
@Wendong-Fan Wendong-Fan marked this pull request as ready for review December 27, 2025 15:58
Copy link
Collaborator

@fengju0213 fengju0213 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks great, apart from the missing guard condition I mentioned.

I also have a suggestion regarding extensibility. Since we've completely removed the fallback mechanism in this PR, I wonder if we should consider retaining a limited fallback for cases where the context window is exceeded despite our proactive measures. Even if we trigger summarization at 50% context usage, there are edge cases where a single turn could still overwhelm the entire context window.

Previously, we handled this by providing a condensed summary of the tool call that caused the overflow, which gave the agent feedback to avoid repeating the same strategy. Since this logic has been removed, perhaps we could consider re-introducing a strategy (possibly in a future PR) to truncate tool outputs when a context explosion occurs, while still preserving a summary of the cause for the agent. What are your thoughts on this?

@Wendong-Fan Wendong-Fan merged commit 10e459c into master Dec 28, 2025
14 checks passed
@Wendong-Fan Wendong-Fan deleted the token_count_fix branch December 28, 2025 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review Required PR need to be reviewed

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants