Auto-compaction deadlock: summarize_transcript has no token-budget guard, compaction can never recover once history exceeds input budget
Summary
The automatic context-compaction path (summarize_transcript) sends the entire session history + system prompt to the summarization model without any token-budget protection. The manual path (archive_session) correctly uses get_history(max_tokens=budget) chunking, but the automatic path does not.
Consequence
Once a session's history exceeds the model's input budget, a deadlock occurs:
- Governor blocks the request because input > budget ("Unable to compact context")
- Compaction itself requires an LLM call whose input (full history + prompt) also exceeds the budget
- That call is also blocked / falls back to raw archiving, so history never shrinks
- The session is permanently stuck — the only recovery is
/newor manually clearing history
In our case the trigger was a misconfigured contextWindowTokens (64000 vs the model's real 1M window), which made fixed overhead (~92k tokens of system prompt + tool definitions) exceed the local input budget (~54784). But even with a correctly sized window, any session whose history grows past the window hits the same permanent deadlock — a bigger window only delays it.
Observed behavior
Compressing context… → Unable to compact context (input 91985 tokens > budget 54784)Repeated on every turn; context never reduced.
Suggested fix
Apply the same budget guard used by archive_session to summarize_transcript: when the history passed to the summarizer exceeds the model's input budget, truncate/chunk it via get_history(max_tokens=budget - reserved_for_prompt) (or fall back to keeping the most recent N messages) so compaction can always make progress.
Environment
- nanobot v0.3.5 (upgrade that made the failure visible: precise tiktoken estimation + strict governor)
- macOS, GLM-5.3-Flash endpoint
Source: HKUDS/nanobot