Repository navigation
fix(agents): Codex sessions stop dead-ending on the transcript byte fuse with a wrong context warning - #137752
zhangguiping-xydt wants to merge 7 commits into
Conversation
A Codex session whose active transcript crossed the configured maxActiveTranscriptBytes was routed into required native preflight compaction. Host-isolated and policy-restricted bindings refuse that operation by design, so the refusal surfaced as a generic context-too-large reply that recommended /compact, which is skipped for the same reason, and every later turn was rejected before model execution even though the context reading was small. Codex already owns the byte fuse: the startup binding caps native rollout transcripts at the same threshold and restarts oversized threads fresh each turn. Stop attempting the duplicate host-side preflight for Codex runtimes on the byte trigger, matching the documented behavior and the existing token-pressure skip. Non-Codex runtimes keep the byte-triggered preflight, and the native-tool restriction is untouched.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 4, 2026, 9:56 AM ET / 13:56 UTC. ClawSweeper reviewWhat this changesThis PR lets Codex-backed turns continue when a transcript-byte preflight receives one of two successful, intentional native-compaction declines, while retaining failed-compaction handling. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 1 item remains No blocking correctness finding. The exact, success-gated classification repairs the documented restricted-binding no-op without converting known failed compactions into skips; normal exact-head CI remains the only routine gate. Priority: P1 Review scores
Verification
How this fits togetherBefore a Codex-backed turn reaches model dispatch, OpenClaw checks transcript pressure and may require compaction. The Codex plugin owns restricted-thread behavior; startup binding rotation drops an oversized native binding so the subsequent turn can start fresh. flowchart LR
A[Incoming Codex turn] --> B[Transcript byte preflight]
B --> C[Native compaction result]
C --> D{Successful intentional decline?}
D -->|Yes| E[Admit turn]
D -->|No| F[Fail required preflight]
G[Startup binding rotation] --> H[Fresh restricted thread]
H --> A
Before merge
Agent review detailsSecurityNone. PR surfaceSource +20, Tests +224. Total +244 across 7 files. View PR surface stats
Review metrics
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: Keep the exact successful-result contract and the startup-binding rotation boundary; a future API redesign can replace the string coupling with a typed native-compaction skip outcome if that contract needs to evolve. Do we have a high-confidence way to reproduce the issue? Yes, from the source path: the plugin emits the successful restricted-binding decline and the required byte preflight previously throws unless that result is treated as benign. The supplied linked real-function trace exercises that path; this review did not execute untrusted contributor code. Is this the best way to solve the issue? Yes. The patch preserves byte-triggered native recovery for bindings that can perform it and changes only the two exact successful Codex ownership declines, leaving unsuccessful policy blocks as failures. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 068ef71bd20e. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
When the Codex plugin declines native compaction for a host-isolated or policy-restricted binding, that result is an intentional no-op, not a compaction failure. Preflight was throwing on it, which surfaced as the generic context-too-large reply and blocked every later turn of the session even though the context reading was small. Classify the plugin's decline reasons (native-tool restriction and Codex-owned automatic compaction) as a benign skip at the shared compaction-reason layer so preflight skips instead of throwing. The byte-triggered attempt itself is unchanged: supervised, context-engine, and unrestricted Codex bindings keep their configured recovery, and restricted bindings are rotated by the startup binding as documented.
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
Correct distinction. An intentional ok: true, compacted: false Codex policy decline should not become context exhaustion. Keeping real compaction failures hard while allowing the documented Codex-owned skip preserves recovery semantics.
The decline classifier matched failure wording too broadly: sandbox and node-host policy blocks reuse the decline phrasing with ok:false results, and the benign-skip check ignored the ok flag, so those genuine failures would have become successful preflight skips. Match the two documented decline reasons exactly and gate the decline class on a successful result; regressions now keep locked-harness and policy-block failures failing required byte preflight.
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Closing this unmerged as superseded by #136533, landed on The final repair moved the reported failure out of string classification and into the compaction owner:
That means the two Codex decline strings added here are no longer needed to admit the affected turn. Keeping them would couple shared core policy to plugin-owned wording after the owner-level path has removed that dependency. Thanks @zhangguiping-xydt for the diagnosis and the careful success-vs-failure regressions. Your contribution is preserved in the landed squash's co-author credit. |
Closes #137697
What Problem This Solves
Fixes an issue where users chatting with OpenClaw on Codex hosted models could have every later turn in a session rejected with "⚠️ Context is too large and auto-compaction could not recover this turn. Try again, use /compact, or use /new" — while the context reading was actually small (the report shows 26k/272k, 10%) — and
/compactwas skipped with "native compaction is unavailable for a host-isolated Codex session". The only way out was/new, losing the session.Why This Change Was Made
When a Codex session's active transcript crossed the configured
agents.defaults.compaction.maxActiveTranscriptBytes, the preflight sent the session into required native compaction. The Codex plugin intentionally declines that operation for host-isolated or policy-restricted bindings — compaction is a separate Codex operation without the turn-scoped restricted environment — and that decline is an intentional no-op, not a compaction failure. Preflight treated it as a hard failure, threw, and the turn-admission caller formatted it as a generic context-exhausted reply recommending the same unavailable/compact.This change classifies the plugin's two documented decline reasons (the host-isolated restriction and Codex-owned automatic compaction) as a benign skip at the shared compaction-reason layer — matched exactly, and only for successful (
ok: true) results — so preflight skips instead of throwing and the turn is admitted.ok: falsefailures whose wording overlaps the decline phrasing (sandbox and node-host policy blocks, locked-harness fallback) still fail required preflight, with regressions preserving that. The byte-triggered attempt itself is unchanged: supervised, context-engine thread-bootstrap, and unrestricted Codex bindings keep their configured native recovery, and restricted bindings are enforced by the documented startup-binding rotation, which caps native rollout transcripts at the same threshold and restarts oversized threads fresh on the next ordinary turn. Non-Codex runtimes are untouched, and the native-tool restriction is preserved exactly.User Impact
A medium-running Codex session no longer dead-ends behind a misleading context warning. When the transcript byte fuse trips, the next message is admitted as usual; bindings that can compact natively still do, and oversized restricted threads restart fresh through the documented rotation, so the conversation continues in the same session instead of requiring
/new.Evidence
Red on pinned main (
ddb6a70c044) at the admission owner, with the exact reporter failure produced by feeding the real plugin's decline into the real preflight gate:Green after the fix, driven end to end with real functions:
maybeCompactCodexAppServerSessionran against a real policy-restricted binding (real binding store, real on-disk session file) under the preflight trigger shape (trigger: "budget", non-manual native request allowed) — no fake client, since the decline precedes any app-server connection:{ "ok": true, "compacted": false, "reason": "native compaction is unavailable for a host-isolated Codex session", "result": { "details": { "backend": "codex-app-server", "skipped": true, "reason": "native_tool_policy_restricted", "expectedThreadId": "thread-1" } } }runSessionCompactionIfNeeded, backed by a real SQLite store with the transcript over the threshold, consumed that exact captured artifact on this head: the byte-triggered attempt runs once (preflightRequired: true,transcript_bytes), the decline is a benign skip, the turn is admitted, and no byte latch is written. The committed regression asserts the same flow, and a second committed regression asserts the byte-triggered native attempt still runs for Codex runtimes generally — preserving supervised, context-engine, and unrestricted recovery.rotateOversizedCodexAppServerStartupBinding, so the next ordinary turn proceeds on a fresh thread; the existing real-plugin suite still verifies restricted bindings send no native compact RPC.0cc4a186joining the complete reporter path — restricted binding over the byte fuse → real plugin decline → rotation clears the oversized binding for a fresh thread → the following ordinary turn is admitted by the reply preflight gate → ok:false policy-block failures still fail required preflight: https://gist.github.com/zhangguiping-xydt/9662dfa8a90eaf939142ba0bdf818bcd (captured plugin result and per-step logs: https://gist.github.com/zhangguiping-xydt/9adb4ab97188e71359289e5b9c273dd5)ok: falsepolicy-block result whose wording overlaps the decline phrasing still fails required byte preflight (committed regressionstill fails required byte preflight when native compaction fails), preserving locked-harness and sandbox/node-host failure semantics.Affected suites:
agent-runner-memory107 passed,compact-reasons49 passed (including new classification tests), codex app-server runtime shard 27 files / 1222 passed (threetransport-process-snapshotfailures reproduced once under parallel load and pass 30/30 in isolation with and without this branch — timing flake, unrelated), codexcompact52 passed,cli-compaction+ failure-reply 43 passed, embedded overflow-compaction 27 passed;tsgocore/extensions/test typechecks, oxlint, and oxfmt clean. A live hosted Codex turn was not possible from this environment (no Codex credentials); the blocked-turn decision happens entirely before model dispatch, which the admission-owner proof exercises directly.Risks
The classification widens the benign-skip set by exactly the plugin's two intentional decline reasons;
ok: falsefailures (native execution policy blocks, missing bindings) still throw, and manual/compactnow reports the decline as a skip, matching the wording users already see. Two open PRs touch adjacent compaction surfaces (#119985 reset replay-window accounting, #136533 heartbeat byte-fuse enforcement) and neither covers this blocked-turn path; this change does not alter their non-Codex or measurement semantics.