Repository navigation
fix(codex): attach a request over the turn cap instead of losing its middle - #200735
Conversation
A request larger than the runtime's turn cap or most of the model window was cut (Codex) or overflowed the model (embedded runtime). Core now fits it once per harness attempt: the full text becomes a readable inbound attachment when the run may read files, and the model sees its head, tail and the attachment path. Otherwise only the middle is cut. The transcript keeps the original. Co-authored-by: obviyus <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. What this changesFits oversized requests by attaching their complete text when readable and sending a bounded head-and-tail excerpt. Example: A 2,948,079-character Codex request asks for a codeword appearing only in its middle.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 4 items remain This PR addresses a demonstrated input-loss bug, but native-model budgeting and remote attachment placement introduce two regressions that need correction. Priority: P2 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherHarness selection receives the prepared request and model policy, bounds the model-facing text, and uses the existing media store and attachment capability while preserving the original transcript. flowchart TD
A[Prepared current request] --> B[Harness selection]
B --> C[Input budget]
C --> D[Inbound attachment store]
D --> E[Execution host attachment paths]
C --> F[Bounded request text]
E --> F
F --> G[Selected agent harness]
Technical reviewBest possible solution: Use only authored or observed context limits and stage complete requests through the execution host’s existing attachment owner. Do we have a high-confidence way to reproduce the issue? Current source exposes both introduced failure paths, and the supplied real Gateway comparisons establish the original oversized-request problem; review execution remained read-only. Is this the best way to solve the issue? Shared fitting and reuse of inbound attachments are appropriate, but capacity and attachment reachability must remain with their existing native-runtime and execution-host owners. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7ba70332d8dd. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +136, Tests +61, Docs +7. Total +204 across 6 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 17, 2026, 1:40 PM ET / 18:40 UTC. |
…n placement Review: calling the local-host preparer from core bypassed the Codex connection's placement checks, and cutting at the attach budget regressed built-in runs that would still fit. Core now offers fitCurrentInput as a host capability; Codex calls it with its connection-level preparer. The built-in runtime cuts only a request that cannot fit the model window. Co-authored-by: obviyus <[email protected]>
The reply allowance shares the window, so a 400k-token model with a 128k reply cap cut to 1.4M chars still overflowed. Both limits now use the input share of the window. Co-authored-by: obviyus <[email protected]>
Review: a chars-per-token estimate cannot prove token overflow, so cutting or spilling below the Codex hard cap dropped content that fit, and the built-in runtime has its own token-aware overflow handling. The fitter now acts only past the runtime's hard per-turn text cap, which only Codex declares, and leaves the built-in runtime unchanged. Co-authored-by: obviyus <[email protected]>
|
Landed as 52e8079. On the Codex runtime, a current request over the 1,048,576-character turn cap used to lose its middle. Now, when the run can read files where Codex runs, the full request is saved as an attachment, and the model keeps the instruction, both untrusted-content markers and the attachment path. The Codex connection's own preparer decides placement. Otherwise only the middle is cut, as before. Proof: a 3 MB request with the needed fact only at its midpoint, on a real Gateway with gpt-5.4. |
…middle (openclaw#200735) Related: openclaw#200514, openclaw#200690 ## What Problem This Solves The Codex app-server rejects any turn over 1,048,576 characters (`MAX_USER_INPUT_TEXT_CHARS` in codex-rs). Since openclaw#200690, a current request over that cap keeps its head and tail and loses its middle. Anything that appears only in the middle is gone, and the model answers from what remains. Large requests come from hooks (up to 1 MiB since openclaw#200514), the OpenAI-compatible endpoint (20 MiB bodies), channel messages, pastes and cron messages. ## Fix - **New host capability, `fitCurrentInput`.** It is a generic harness host capability, so there are no new Plugin SDK exports. The Codex attempt calls it right after its connection is ready, with the Codex turn cap and the connection's own `prepareInputAttachments`. - **Over the cap, and the run may read files on this host:** the full request is saved as an inbound attachment (`current-request.txt`). The model sees the request's head and tail, which keep the instruction and both untrusted-content markers. It also sees a marker saying the visible part is incomplete and that it should search the attachment before answering, plus the attachment path. - **Placement is the connection's decision.** It already refuses local paths for a sandbox, remote execution, non-stdio transport, a remote workspace root, restricted tools or a non-full permission mode, and prefers a registered remote attachment binding. - **Otherwise:** only the middle is cut, as in openclaw#200690. - **Transcript:** keeps the original (`transcriptPrompt`). There is no change to stored turns, schema or retention; the file follows the operator's existing inbound attachment retention. - **Visible outcome:** each case logs `current input oversize: chars=… budget=… action=attached|cut`. **Scope, after local review.** Earlier revisions also estimated a token budget from the model window and fitted requests for the built-in runtime. A chars-per-token estimate cannot prove token overflow. Fitting below the hard cap could drop content that fit, and the built-in runtime has its own token-aware overflow handling. This version acts only past a runtime's hard per-turn text cap, so nothing that worked inline changes. ## User Impact On the Codex runtime, a request over 1 MiB stays usable: the agent can search the full text instead of guessing from its start and end. Requests within the cap and the built-in runtime behave as before. ## Evidence Real Gateways from source with real models on the Codex runtime, `POST /v1/chat/completions`. **1. 3 MB request.** A 2,948,079-character meeting transcript. The instruction is at the top ("Kenji Sato states the budget codeword. Reply with ONLY that codeword"). The codeword `HERON-5150` appears once, at the 49.9% offset. | model | `main` 709b566 | this PR, final head | |---|---|---| | gpt-5.4 | `Fire`, `Fire`, `ClawRouter` (0/3) | `HERON-5150` ×3 (3/3) | | gpt-5.4-mini | `armed`, `Fire`, `Fire` (0/3) | `HERON-5150` 1/3 (`armed`, `done`) on an earlier head with the same staging path | - The log shows `current input oversize: chars=2948079 budget=1048576 action=attached`. - The Codex rollout shows the agent opening `…/media/inbound/current-request---….txt`, parsing it, and printing the matching segment. **2. 2 MiB request whose instruction is only at the top** ("reply exactly ZEBRA-4217"), gpt-5.4-mini, final head: `ZEBRA-4217`, `action=attached`. **Tests:** - `src/agents/harness/current-input-budget.test.ts` covers three cases: - unchanged within the cap; - attached: the saved file holds the full original, and the instruction and both markers stay inline; - cut-only when staging returns nothing. - Passing: `src/agents/harness/` and every `extensions/codex/src/app-server/run-attempt*.test.ts` (11 shards), `tsgo:core`, `tsgo:extensions`, `check:test-types`, `plugin-sdk:surface:check`, oxlint, oxfmt and `git diff --check`. **Not covered / accepted:** - gpt-5.4-mini is unreliable at finding a middle-only fact through the attachment (1/3). The docs say so. - Requests over the 5 MB inbound media cap fall back to the cut. - Each retry of the same oversized turn saves its own copy. - The Codex-side head/tail cut from openclaw#200690 stays as the guard for prompt decoration that still exceeds the cap. - The built-in runtime's handling of an oversized single message stays a separate, token-aware follow-up. Co-authored-by: Ayaan Zaidi <[email protected]>
…middle (#200735) Related: #200514, #200690 ## What Problem This Solves The Codex app-server rejects any turn over 1,048,576 characters (`MAX_USER_INPUT_TEXT_CHARS` in codex-rs). Since #200690, a current request over that cap keeps its head and tail and loses its middle. Anything that appears only in the middle is gone, and the model answers from what remains. Large requests come from hooks (up to 1 MiB since #200514), the OpenAI-compatible endpoint (20 MiB bodies), channel messages, pastes and cron messages. ## Fix - **New host capability, `fitCurrentInput`.** It is a generic harness host capability, so there are no new Plugin SDK exports. The Codex attempt calls it right after its connection is ready, with the Codex turn cap and the connection's own `prepareInputAttachments`. - **Over the cap, and the run may read files on this host:** the full request is saved as an inbound attachment (`current-request.txt`). The model sees the request's head and tail, which keep the instruction and both untrusted-content markers. It also sees a marker saying the visible part is incomplete and that it should search the attachment before answering, plus the attachment path. - **Placement is the connection's decision.** It already refuses local paths for a sandbox, remote execution, non-stdio transport, a remote workspace root, restricted tools or a non-full permission mode, and prefers a registered remote attachment binding. - **Otherwise:** only the middle is cut, as in #200690. - **Transcript:** keeps the original (`transcriptPrompt`). There is no change to stored turns, schema or retention; the file follows the operator's existing inbound attachment retention. - **Visible outcome:** each case logs `current input oversize: chars=… budget=… action=attached|cut`. **Scope, after local review.** Earlier revisions also estimated a token budget from the model window and fitted requests for the built-in runtime. A chars-per-token estimate cannot prove token overflow. Fitting below the hard cap could drop content that fit, and the built-in runtime has its own token-aware overflow handling. This version acts only past a runtime's hard per-turn text cap, so nothing that worked inline changes. ## User Impact On the Codex runtime, a request over 1 MiB stays usable: the agent can search the full text instead of guessing from its start and end. Requests within the cap and the built-in runtime behave as before. ## Evidence Real Gateways from source with real models on the Codex runtime, `POST /v1/chat/completions`. **1. 3 MB request.** A 2,948,079-character meeting transcript. The instruction is at the top ("Kenji Sato states the budget codeword. Reply with ONLY that codeword"). The codeword `HERON-5150` appears once, at the 49.9% offset. | model | `main` 9aed362 | this PR, final head | |---|---|---| | gpt-5.4 | `Fire`, `Fire`, `ClawRouter` (0/3) | `HERON-5150` ×3 (3/3) | | gpt-5.4-mini | `armed`, `Fire`, `Fire` (0/3) | `HERON-5150` 1/3 (`armed`, `done`) on an earlier head with the same staging path | - The log shows `current input oversize: chars=2948079 budget=1048576 action=attached`. - The Codex rollout shows the agent opening `…/media/inbound/current-request---….txt`, parsing it, and printing the matching segment. **2. 2 MiB request whose instruction is only at the top** ("reply exactly ZEBRA-4217"), gpt-5.4-mini, final head: `ZEBRA-4217`, `action=attached`. **Tests:** - `src/agents/harness/current-input-budget.test.ts` covers three cases: - unchanged within the cap; - attached: the saved file holds the full original, and the instruction and both markers stay inline; - cut-only when staging returns nothing. - Passing: `src/agents/harness/` and every `extensions/codex/src/app-server/run-attempt*.test.ts` (11 shards), `tsgo:core`, `tsgo:extensions`, `check:test-types`, `plugin-sdk:surface:check`, oxlint, oxfmt and `git diff --check`. **Not covered / accepted:** - gpt-5.4-mini is unreliable at finding a middle-only fact through the attachment (1/3). The docs say so. - Requests over the 5 MB inbound media cap fall back to the cut. - Each retry of the same oversized turn saves its own copy. - The Codex-side head/tail cut from #200690 stays as the guard for prompt decoration that still exceeds the cap. - The built-in runtime's handling of an oversized single message stays a separate, token-aware follow-up. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 52e8079) Backport-proof: added a production-host Codex turn/start regression with registered workspace attachment owner; red on a8f3bfad459c because complete-request attachment guidance is absent. Existing placement and live binding owner retained. Co-authored-by: vincentkoc <[email protected]> Co-authored-by: RomneyDa <[email protected]>
…middle (#200735) Related: #200514, #200690 ## What Problem This Solves The Codex app-server rejects any turn over 1,048,576 characters (`MAX_USER_INPUT_TEXT_CHARS` in codex-rs). Since #200690, a current request over that cap keeps its head and tail and loses its middle. Anything that appears only in the middle is gone, and the model answers from what remains. Large requests come from hooks (up to 1 MiB since #200514), the OpenAI-compatible endpoint (20 MiB bodies), channel messages, pastes and cron messages. ## Fix - **New host capability, `fitCurrentInput`.** It is a generic harness host capability, so there are no new Plugin SDK exports. The Codex attempt calls it right after its connection is ready, with the Codex turn cap and the connection's own `prepareInputAttachments`. - **Over the cap, and the run may read files on this host:** the full request is saved as an inbound attachment (`current-request.txt`). The model sees the request's head and tail, which keep the instruction and both untrusted-content markers. It also sees a marker saying the visible part is incomplete and that it should search the attachment before answering, plus the attachment path. - **Placement is the connection's decision.** It already refuses local paths for a sandbox, remote execution, non-stdio transport, a remote workspace root, restricted tools or a non-full permission mode, and prefers a registered remote attachment binding. - **Otherwise:** only the middle is cut, as in #200690. - **Transcript:** keeps the original (`transcriptPrompt`). There is no change to stored turns, schema or retention; the file follows the operator's existing inbound attachment retention. - **Visible outcome:** each case logs `current input oversize: chars=… budget=… action=attached|cut`. **Scope, after local review.** Earlier revisions also estimated a token budget from the model window and fitted requests for the built-in runtime. A chars-per-token estimate cannot prove token overflow. Fitting below the hard cap could drop content that fit, and the built-in runtime has its own token-aware overflow handling. This version acts only past a runtime's hard per-turn text cap, so nothing that worked inline changes. ## User Impact On the Codex runtime, a request over 1 MiB stays usable: the agent can search the full text instead of guessing from its start and end. Requests within the cap and the built-in runtime behave as before. ## Evidence Real Gateways from source with real models on the Codex runtime, `POST /v1/chat/completions`. **1. 3 MB request.** A 2,948,079-character meeting transcript. The instruction is at the top ("Kenji Sato states the budget codeword. Reply with ONLY that codeword"). The codeword `HERON-5150` appears once, at the 49.9% offset. | model | `main` 9aed362 | this PR, final head | |---|---|---| | gpt-5.4 | `Fire`, `Fire`, `ClawRouter` (0/3) | `HERON-5150` ×3 (3/3) | | gpt-5.4-mini | `armed`, `Fire`, `Fire` (0/3) | `HERON-5150` 1/3 (`armed`, `done`) on an earlier head with the same staging path | - The log shows `current input oversize: chars=2948079 budget=1048576 action=attached`. - The Codex rollout shows the agent opening `…/media/inbound/current-request---….txt`, parsing it, and printing the matching segment. **2. 2 MiB request whose instruction is only at the top** ("reply exactly ZEBRA-4217"), gpt-5.4-mini, final head: `ZEBRA-4217`, `action=attached`. **Tests:** - `src/agents/harness/current-input-budget.test.ts` covers three cases: - unchanged within the cap; - attached: the saved file holds the full original, and the instruction and both markers stay inline; - cut-only when staging returns nothing. - Passing: `src/agents/harness/` and every `extensions/codex/src/app-server/run-attempt*.test.ts` (11 shards), `tsgo:core`, `tsgo:extensions`, `check:test-types`, `plugin-sdk:surface:check`, oxlint, oxfmt and `git diff --check`. **Not covered / accepted:** - gpt-5.4-mini is unreliable at finding a middle-only fact through the attachment (1/3). The docs say so. - Requests over the 5 MB inbound media cap fall back to the cut. - Each retry of the same oversized turn saves its own copy. - The Codex-side head/tail cut from #200690 stays as the guard for prompt decoration that still exceeds the cap. - The built-in runtime's handling of an oversized single message stays a separate, token-aware follow-up. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 52e8079) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 4f7dcc1980d999588febf5f02aa05c4d5a1e30eb)
Related: #200514, #200690
What Problem This Solves
The Codex app-server rejects any turn over 1,048,576 characters (
MAX_USER_INPUT_TEXT_CHARSin codex-rs). Since #200690, a current request over that cap keeps its head and tail and loses its middle. Anything that appears only in the middle is gone, and the model answers from what remains.Large requests come from hooks (up to 1 MiB since #200514), the OpenAI-compatible endpoint (20 MiB bodies), channel messages, pastes and cron messages.
Fix
fitCurrentInput. It is a generic harness host capability, so there are no new Plugin SDK exports. The Codex attempt calls it right after its connection is ready, with the Codex turn cap and the connection's ownprepareInputAttachments.current-request.txt). The model sees the request's head and tail, which keep the instruction and both untrusted-content markers. It also sees a marker saying the visible part is incomplete and that it should search the attachment before answering, plus the attachment path.transcriptPrompt). There is no change to stored turns, schema or retention; the file follows the operator's existing inbound attachment retention.current input oversize: chars=… budget=… action=attached|cut.Scope, after local review. Earlier revisions also estimated a token budget from the model window and fitted requests for the built-in runtime. A chars-per-token estimate cannot prove token overflow. Fitting below the hard cap could drop content that fit, and the built-in runtime has its own token-aware overflow handling. This version acts only past a runtime's hard per-turn text cap, so nothing that worked inline changes.
User Impact
On the Codex runtime, a request over 1 MiB stays usable: the agent can search the full text instead of guessing from its start and end. Requests within the cap and the built-in runtime behave as before.
Evidence
Real Gateways from source with real models on the Codex runtime,
POST /v1/chat/completions.1. 3 MB request. A 2,948,079-character meeting transcript. The instruction is at the top ("Kenji Sato states the budget codeword. Reply with ONLY that codeword"). The codeword
HERON-5150appears once, at the 49.9% offset.main9aed362Fire,Fire,ClawRouter(0/3)HERON-5150×3 (3/3)armed,Fire,Fire(0/3)HERON-51501/3 (armed,done) on an earlier head with the same staging pathcurrent input oversize: chars=2948079 budget=1048576 action=attached.…/media/inbound/current-request---….txt, parsing it, and printing the matching segment.2. 2 MiB request whose instruction is only at the top ("reply exactly ZEBRA-4217"), gpt-5.4-mini, final head:
ZEBRA-4217,action=attached.Tests:
src/agents/harness/current-input-budget.test.tscovers three cases:src/agents/harness/and everyextensions/codex/src/app-server/run-attempt*.test.ts(11 shards),tsgo:core,tsgo:extensions,check:test-types,plugin-sdk:surface:check, oxlint, oxfmt andgit diff --check.Not covered / accepted: