feat(core): elide oversized historic tool results from model context

Tool results from prior turns (skill loads, file reads, HTTP fetches)
dominate resent context and are rarely needed verbatim. A decorator over
the context resolver now replaces prior-turn tool results above a size
threshold with a short placeholder telling the model to re-run the tool
if it needs the output. The current turn's in-flight results are always
sent verbatim, the durable log is untouched, and elision is a pure
per-message function so resolved prefixes stay byte-stable for provider
prefix caching.

Policy lives in config/context.json (elideHistoricToolResults, default
on; elideHistoricToolResultsThresholdChars, default 10000). The inspect
CLI composes through the same decorated resolver so debug output still
matches transmitted bytes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Arjun 2026-07-07 03:09:32 +05:30 committed by Ramnique Singh
parent 26e2fde0a8
commit 99f196e16c
5 changed files with 393 additions and 4 deletions

View file

@ -390,6 +390,18 @@ Rules:
It rejects the execution and does not append `turn_failed`.
- The reducer treats `context` as opaque data and never resolves references.
The app wires the resolver through a decorator (`context-elision.ts`) that
applies transmit-time elision to the materialized prefix: tool results from
prior turns above a size threshold are replaced with a short placeholder
telling the model to re-run the tool if it needs the output. The durable log
is untouched; only the transmitted bytes change. Elision is a pure function
of each message, so resolved prefixes stay byte-stable across calls (provider
prefix caches keep working), and the current turn's own in-flight tool
results never pass through the resolver, so they are always sent verbatim.
Policy lives in `config/context.json` (`elideHistoricToolResults`, default
true; `elideHistoricToolResultsThresholdChars`, default 10000). The inspect
CLI composes through the same decorated resolver.
### 6.7 Agent snapshot inheritance
Session turns whose resolved system prompt and tool set are byte-identical