tao-context-vcc
Algorithmic compactor that shrinks long TAO transcripts before they hit the model. Same input always produces the same output. Idempotent on a second pass.
When to trigger
- A TAO session has accumulated >75% of the model's context window.
- Token-budget telemetry on
.harness/agent-sdk-metrics/*.jsonlshows tokens-per-turn climbing past the historical baseline. - A new tao-loop iteration is about to start and the autoresearch lens flags rising tokens/turn.
Public API
from app.server.tao_context_vcc import compact, compact_for_sdk
compacted, stats = compact(messages, target_token_budget=120_000)
# stats.bytes_in / bytes_out / messages_in / messages_out / techniques_applied
Techniques (all deterministic)
- tool-output dedup — repeat tool turns become
<truncated: same as msg N>. - verbose-block truncate — >2000 lines or >50 KB clipped to head + tail with
<elided ...>. - repeat-pattern collapse — runs of identical messages collapse to one with
<repeated K times>. - whitespace + log-noise normalisation — trailing-ws strip, blank-line dedup, CRLF → LF.
Validation harness
scripts/validate_tao_context_vcc.py <dir> runs compact() on every saved TAO session jsonl and prints tokens_in / tokens_out / pct_reduction / techniques_applied. Exits 0 if the median reduction is ≥30%.
Out of scope
- Semantic summarisation (LLM-based compaction lives in
context-compressor, not here). - Cross-session compaction. Each call is per-transcript, pure.