- _loop_local: two-stage compaction at 22k tokens (tiktoken cl100k).
Stage 1 elides old tool messages to [tool output elided: N chars, exit=X],
preserving tool_call_id. Stage 2 folds turn pairs into a synthesized
system note. Last 3 turns + system + initial user always intact.
Emergency-compact retry on a 32k BadRequest from vLLM.
- _loop_cloud_openai: assistant content is "" not None on tool-only turns
(OpenAI 400's on null). Bash output decoded with errors="replace" and
stubbed to [binary output: N bytes, exit=X] on >5% replacement or NUL.
- _openai_retry: local-vLLM branch now retries APIConnectionError /
APITimeoutError / InternalServerError 3x with 1/2/4s backoff.
- Tests: 18 cases covering compaction shape, token budget, tool_call_id
preservation, null-content guard, binary decode, local retry.
Addresses ctx-overflow in Gemma-31B SWE n=100 cells (61 + 19 errored
rows) and the OpenAI/Gemini adapter errors across ~19 cells in the
n=100 hybrid sweep.