Skip to content

fix: include tools in post-compression token estimate#14882

Open
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:fix/compression-token-estimate-14695
Open

fix: include tools in post-compression token estimate#14882
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:fix/compression-token-estimate-14695

Conversation

@LeonSGP43

Copy link
Copy Markdown
Contributor

Summary

  • use estimate_request_tokens_rough(...) when updating last_prompt_tokens after context compression
  • include tool schema tokens in the post-compression estimate so the next compression cycle is scheduled against the real request size
  • add a regression test covering _compress_context() with a large tool schema

Closes #14695

Testing

  • python3 -m pytest -o addopts= tests/run_agent/test_context_token_tracking.py

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder labels Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Post-compression token estimate excludes tools schema, delaying next compression cycle

2 participants