Repository navigation
fix(agents): honor preflight compaction budget - #130562
Conversation
Use the reserve-adjusted prompt budget only for synthetic mid-turn precheck recovery while preserving the raw context budget for provider overflow and timeout recovery.\n\nFixes #130226\nReported-by: @HelloBias
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 9:25 PM ET / August 27, 2026, 01:25 UTC. ClawSweeper reviewWhat this changesThe PR makes synthetic mid-turn preflight overflows compact against the reserve-adjusted budget that triggered recovery while retaining the raw model window for provider overflows and timeout recovery. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open for normal maintainer review: the focused guard matches the recorded preflight provenance and no concrete patch defect was found, but the branch is behind main and its session-compaction behavior still needs exact-head validation. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherEmbedded agent runs measure prompt pressure before submission and, on overflow, ask a context engine to compact the active session before retrying. This change selects the recovery target from the recorded preflight failure provenance. flowchart LR
A[Rendered session prompt] --> B[Reserve-aware preflight]
B --> C[Recorded mid-turn failure]
C --> D[Overflow recovery]
D --> E[Select compaction target]
E --> F[Context engine compaction]
F --> G[Retry current transcript]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +8, Tests +58. Total +66 across 2 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Rebase onto current main, preserve the narrow provenance gate, and demonstrate through the real context-engine boundary that only the synthetic precheck compacts to the reserve-adjusted target. Do we have a high-confidence way to reproduce the issue? Yes, from source: a mid-turn precheck records a reserve-adjusted budget while the previous overflow recovery always forwarded the raw context budget. The supplied report also provides a concrete affected-session scenario, but no live run was executed in this read-only review. Is this the best way to solve the issue? Yes, subject to exact-head boundary proof: selecting the target at the overflow owner from the closed terminal provenance prevents the narrower budget from leaking into provider or timeout recovery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 67d22a58acad. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
ClawSweeper rank-up moves:
No ClawSweeper code findings remain. |
|
Merged via squash.
|
Use the reserve-adjusted prompt budget only for synthetic mid-turn precheck recovery while preserving the raw context budget for provider overflow and timeout recovery.\n\nFixes openclaw#130226\nReported-by: @HelloBias
Summary
Root cause
The mid-turn precheck preserved
promptBudgetBeforeReserve, but overflow recovery always passedcontextTokenBudgetto forced context-engine compaction. A prompt above the reserve-adjusted budget but below the hard window could therefore be judged already under target, making recovery a deterministic no-op.The overflow owner has both the failure provenance and the measured preflight budget. It now selects the narrower target only for a genuine synthetic mid-turn precheck failure with a finite positive budget.
Contract evidence
Sibling Codex source independently separates proactive compaction pressure from the hard provider window:
codex-rs/protocol/src/openai_models.rs:481codex-rs/core/src/session/context_window.rs:53codex-rs/core/src/session/turn.rs:1024codex-rs/codex-api/src/sse/responses.rs:680Validation
200000instead of the triggering241616pnpm tsgo:core: passedgit diff --check: passedtbx_01m10c0h3eyw9jt5x0dj7q5d0w, workflow33028988171: infrastructure blocked after more than five hours without a terminal summary; the exact task-owned lease and processes were stopped, and no replacement heavy run was startedScope
The positive production delta is the explicit provenance and validity gate needed to prevent the narrower budget from leaking into provider overflow.
This deterministic session-block fix is release-note worthy; the landing release workflow owns the changelog entry.
Fixes #130226
Reported by @HelloBias.