- Clamp the summary request's max_tokens to the model's output limit so a
large STRIX_CONTEXT_SUMMARY_TOKENS can't get the request rejected (which
left the overflowing session uncompacted). Applied consistently to the
input-budget reservation and the request itself.
- Replace the tokenizer-unavailable fallback with the UTF-8 byte length, a
guaranteed upper bound on tokens for byte-level BPE, so budget checks can
never under-count dense history.
The chars/4 fallback under-counts dense text (code, base64, CJK), which
could let a summary request be packed past the real context window and get
rejected. Use a conservative ~3-chars/token estimate instead so budget
checks never under-count.
Restore cumulative history compaction (removed in the SDK migration) so a
long scan no longer replays an ever-growing transcript until it overflows
the model's context window and the run fails.
- strix/llm/context_budget.py: resolve the model's real input/output token
limits from LiteLLM metadata (128k gpt-4o, 272k gpt-5, 1M claude-sonnet-4,
131k deepseek), with a large configurable fallback for unmapped models and
a chars/4 token-count fallback.
- strix/llm/compaction.py: provider-agnostic compaction via litellm. Keeps a
security-focused structured summary (objective, findings, credentials,
payloads, URLs/paths, work state, dead ends, next move), keeps the most
recent turns by token budget, and snaps the summary boundary so no tool
call is separated from its result. Both triggers: proactive before each
run and reactive compact-and-retry on a real context-overflow error.
- Wire both triggers into the agent run loop next to the existing image
recovery; add replace_session_items() with restore-on-failure.
Env-tunable via STRIX_CONTEXT_* (auto-compact on by default).