Repository navigation
fix(agents): avoid synthetic overflow in tool-heavy sessions - #110297
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 20, 2026, 12:23 AM ET / 04:23 UTC. Summary PR surface: Source +140, Tests +623. Total +763 across 35 files. Reproducibility: yes. The PR provides a concrete current-main Gateway restart scenario with twelve large historical tool results, a reduced context budget, and observable provider-call, compaction, and transcript-retention outcomes. Review metrics: none identified. Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Confirm that provider rejection, rather than conservative generic character estimates, is the intended authority for whole-session recovery, then land this tested internal-boundary implementation if that policy is accepted. Do we have a high-confidence way to reproduce the issue? Yes. The PR provides a concrete current-main Gateway restart scenario with twelve large historical tool results, a reduced context budget, and observable provider-call, compaction, and transcript-retention outcomes. Is this the best way to solve the issue? Unclear pending owner approval. The patch is mechanically coherent and avoids exposing a public SDK seam, but only an agent-runtime owner can decide whether provider rejection should replace generic local recovery authority. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d18a7cff8e54. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +140, Tests +623. Total +763 across 35 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (8 earlier review cycles)
|
|
Implemented the remaining root-cause owner-boundary work at
The persistent-data warning is a false positive: provider-prompt identity is process-local run state cleared in Current proof:
This evidence supports the broader provider-authoritative policy as the best fix: local estimates shape and diagnose, while an actual provider rejection is the authority for whole-session recovery. The narrower aggregate-only patch would leave the same false authority in preflight and tool-loop paths. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
69ddaa9 to
eb623c0
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
ClawSweeper follow-up evidence:
This closes the current-main merge-proof rank-up move. Agent-runtime owner confirmation of the provider-authoritative recovery policy remains the final non-mechanical maintainer decision. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
Final pre-landing audit follow-up for exact PR head
The private matrix now has 71 passing candidate scenarios, zero planned/blocked/implementation-failing scenarios, and one intentionally retained current-main negative control. This completes the requested user-facing proof audit; ClawSweeper's explicit agent-runtime owner acceptance of provider-authoritative recovery remains the only non-mechanical decision before landing. |
|
Merged via squash.
|
…w#110297) * fix(agents): defer context overflow to provider * fix(agents): align provider pressure tests * fix(agents): make overflow recovery authoritative * test(agents): preserve generic compaction lock type * test(agents): auto-clean SQLite compaction fixture * test(agents): keep compaction guard private * fix(agents): keep overflow recovery ownership internal * fix(agents): preserve session sdk type exports
Closes #107655
Related: #107821
What Problem This Solves
Fixes an issue where long-lived, tool-heavy sessions could discard a provider-acceptable projected prompt and trigger whole-session compaction when conservative local character estimates reported pressure.
On current
main, a restored session with twelve 50k-character tool results manufactured a local context overflow before provider submission. Recovery compacted and persistently rewrote the session even though the controlled provider accepted the projected prompt.Why This Change Was Made
Generic aggregate, preflight, and tool-loop character pressure now remains prompt-shaping and diagnostic input rather than proof of context overflow. Explicit opt-in mid-turn recovery remains unchanged. When a provider actually rejects context, the existing recovery path records the final provider request identity and prevents resending a byte-identical rejected payload while allowing materially changed retries.
This addresses the common false-positive authority across all three generic gates. #107821 is a useful narrow mitigation for successful aggregate replacement, but it leaves the normal preflight estimator and always-on tool-loop character guard able to manufacture the same overflow without a provider rejection.
No configuration, protocol, provider identity, public API, or persisted-session format changes.
AI-assisted: yes. I traced the runtime and upstream Codex contracts, reviewed every accepted autoreview finding, and understand the implementation and proof.
User Impact
Tool-heavy sessions can submit their bounded provider prompt without premature compaction or history loss. Genuine provider context rejections still use bounded recovery, and an identical rejected request cannot enter a retry loop.
Evidence
Deterministic Gateway reproduction on the current-main baseline:
execresults under a 1.05M model window.Exact final patch on Blacksmith Testbox via Crabbox:
.artifacts/and is intentionally not part of this PR.Regression and repository proof:
pnpm check:changedon Testbox: passed, including production/test typechecks and full selected lint/policy gates (13m50s).pnpm buildon Testbox: passed (1m22s).git diff --check: passed.