Skip to content

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

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

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 runtime: loop, agent_init, prompt builder, context-compression, responses endpoint labels Apr 24, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused diagnosis and regression coverage. This is now implemented on main.

Closing as implemented on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists sweeper:implemented-on-main Sweeper: behavior already present on current main 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

3 participants