compression: profile-aware worker + real-token baseline estimator
Item 2 — thread the active profile into CompressionWorker so
compress_context applies per-profile overrides (compression_keep_recent,
compression_max_tokens, compression_prompt_file). navi_code now compresses
with keep_recent=12 instead of the global 8.

Item 1 — estimate the next LLM call's context from the *real* prompt_tokens
of the previous call (bulk) plus a heuristic delta for messages appended
since, replacing the chars//3 estimate that undercounts code-heavy tool
output and fired midturn compression too late (Navi kept working until the
window was exhausted). Baseline is recorded after each stream and cleared
after compression; check_context_size and the midturn gate use it, with a
heuristic fallback when no baseline exists or the context shrank.

Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 3d9c3da commit 1b91fcf99b1c7ca621888cd7ac3515632b162f28
@Eugene Sukhodolskiy Eugene Sukhodolskiy authored 6 hours ago
Showing 5 changed files
View
navi/core/agent.py
View
navi/core/compressor.py
View
navi/workers/base.py
View
navi/workers/compressor.py
View
tests/unit/core/test_compressor.py