Add a `retries` field to `SummarizingCompaction`
Closes #12314
Related: #12307 (fatal path fixed separately — the automatic compaction path should catch a failed summary instead of killing the parent run) — a summarizer model that imitates a tool call from the transcript it summarizes dies at core's default budget of 1, and the UnexpectedModelBehavior escapes to kill the parent run.
Problem
The summary agent is toolless by construction, but it reads a transcript full of tool calls, so a small model can emit one. An unknown-tool call burns core's retry budget of 1 in one strike: the first imitation is absorbed, the second raises UnexpectedModelBehavior: Tool 'x' exceeded max retries count of 1, which escapes before_model_request and kills the run being compacted — with a message naming a tool the summarizer never declared. There is no supported way to raise the budget from outside: SummarizingCompaction has no retries field, and summarization_capabilities is forwarded to the child agent but does not cover retries.
Change
Add a kw-only retries field to SummarizingCompaction (default 1, the current behavior) and forward it to the nested Agent(...) construction.
The default stays put on purpose. The summary call's requests fold into the parent run's usage and reserved_usage_limits reserves one request for the parent, so raising the default changes what a finite request_limit means for compaction — test_empty_summary_fallback_with_request_limit pins that accounting ("The summary agent defaults to one output retry"). Whether the default should rise is a maintainer decision; this PR closes the "no supported way" gap so users with a weak summarizer model can absorb the imitations now. A toolless agent has nothing of its own to burn the budget on, so a raised budget only ever absorbs summary-model slips.
Bug fix verification
New test TestPublicPath.test_retries_field_absorbs_tool_call_imitations — a summarizer that emits lookup tool calls on three consecutive attempts before writing text, with retries=3:
- on
mainthe field does not exist (TypeError: unexpected keyword argument 'retries'); - with the change, the run completes (
result.output == 'ok') and the summarizer makes 4 calls (summarizer_calls == 4), i.e. the imitations were retried within the raised budget instead of killing the parent run.
Validation
tests/harness/compaction: 823 passed / 9 failed — the 9 are the known WindowsLocalWorkspaceBackendbaseline, same count onmain; the new test passes.ruff checkandruff format --checkclean on both changed files.- Changed regions of
_summarizing_compaction.pyat 100% line and branch coverage.
Summary by cubic
Adds a kw-only retries field to SummarizingCompaction (default 1, unchanged behavior) and forwards it to the nested summary Agent, closing #12314. A toolless summarizer reads transcripts full of tool calls, and a weak model can imitate one; at the default budget the second imitation raises UnexpectedModelBehavior that escapes the compaction and kills the parent run. Before this change there was no supported way to raise that budget.
- Raising the budget only absorbs summary-model slips, since the toolless agent has nothing of its own to burn retries on; every retry is a real request charged to the parent run's usage, so a finite
request_limitstill binds first. - The default stays at 1 on purpose: summary requests fold into the parent run's usage and
reserved_usage_limitsreserves one request for the parent, so raising the default would change what a finiterequest_limitmeans for compaction. - Adds a test where a summarizer emitting three consecutive tool-call imitations completes successfully with
retries=3instead of killing the run.