Keep the parent run alive when automatic `SummarizingCompaction` fails
- Closes #12307
Why
A toolless summarizer can imitate a transcript's tool call, exhaust its retries and abort the parent run. This implements Douwe's design in the issue: on SummarizingCompaction's own automatic trigger, summary failures end the compaction attempt, not the run. Builds on #12315's retries field, without changing its default.
[!WARNING]
Compatibility impact: Default FallbackCompaction chains now recover from UnexpectedModelBehavior instead of propagating it immediately.
Why this can ship in a minor release: Maintainer-approved Harness 0.x bug fix for #12307; no core API change.
Migration: Pass fallback_on=(ModelAPIError, FallbackExceptionGroup) for the old selection. The capability docs carry the release/migration note and the API gate has exact waivers.
New public surface
None. FallbackCompaction.fallback_on now defaults to (ModelAPIError, FallbackExceptionGroup, UnexpectedModelBehavior).
User-visible behavior
- The automatic path catches
UnexpectedModelBehavior,ModelAPIErrorandFallbackExceptionGroup, keeps the history unchanged, discards the attempt's receipts and recordscompaction.skipped='summary_failed'pluserror.typeon its span. Uses #11649's no-shrink rejection/receipt scope. UsageLimitExceededand programming errors still stop the run. Failed summary calls still count towards usage; while the trigger stays exceeded, the next request retries compaction.FallbackCompactiontries the next strategy by default onUnexpectedModelBehavior. Explicitcompact()/compact_now()still raise; no changes to clai2/compact's explicit call path.
Verification
-
Regression tests in
test_no_shrink.py: six fail before the fix and pass after. Cover tool-call imitation, empty summaries, API errors, exhaustedFallbackModel, receipts, default fallback, explicit calls, usage limits and programming errors. -
Focused tests: 495 passed across the failure, compaction, no-shrink, fallback and clai2 compaction test files. Doc-snippet parsing/import checks: 1059 passed, 66 skipped. Ruff and single-file Pyright clean.
-
README, docs page and context-management skill updated together.
-
clai2's
compactionplugin: its automatic chain now also falls back to truncation onUnexpectedModelBehavior;/compactkeeps raising it, so the user sees the summarizer error (Douwe's call on this PR).
What changes for existing users
Automatic summary failures leave the history unchanged rather than killing the run; default fallback chains also recover from invalid model output. Explicit summary calls and the parent's usage limits retain their error behavior.
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
- PR title is fit for the release changelog.
(Claude, Douwe's coding agent)