|
compressor: count the context the model is sent, not the history it never sees
The session-info modal showed "817 288 / 131 072 (100%)" for a session whose context held a 1.47 MB code_exec result. The estimate was honest about session.context, but build() head/tail-truncates every oversized tool/assistant message to context_message_token_budget before the call, so the model never received that megabyte. truncate_oversized() moves the per-build rule to module level (the method now delegates, behaviour unchanged) so the compressor can price the same view it will send: compress_and_save_session stores estimate_tokens(truncate_oversized( new_context)) instead of estimate_tokens(new_context). Full content stays in stored history — the user still sees it, reloads are unaffected. Regression test keeps a 1 MB tool result in the context and asserts the stored count equals the truncated-view estimate and is >10x smaller than the raw one. |
|---|
|
|
| navi/core/compressor.py |
|---|
| navi/core/context_builder.py |
|---|
| tests/unit/core/test_compressor.py |
|---|