Repository navigation
fix(agent-prompt): press Enter again while a Windows Codex composer still holds a dispatch - #33295
Conversation
…till holds a dispatch Codex on Windows reads a paste as console key events and takes an Enter that reaches it before the last pasted key as a newline, so a large dispatch sat in its composer as [Pasted Content N chars]. After the first Enter, agents with a submit retry now press Enter again only while no turn has started and the composer still shows a draft, for up to a paste-sized window on Windows. Fixes #11343
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 8 minutes. View limit details
Walkthrough
Priority: Severity of issue fixed: Medium Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
e83e56e2-174d-4a76-aa9d-801d8cdc9fcc
Files selected for processing: 5-
src/main/runtime/agent-prompt-submission-runtime.test.tssrc/main/runtime/orca-runtime-tests/agent-launch-prompt-submit.spec.tssrc/main/runtime/terminal/input/terminal-agent-prompt-resubmit.tssrc/main/runtime/terminal/input/terminal-agent-prompt.tssrc/shared/agent-prompt-injection.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
-
…showing this prompt Review follow-up: the draft gate now matches the held prompt itself (Codex paste placeholders summing to its length, or its text), so a rotating placeholder, question overlay or the user's own draft never gets an Enter. Turn start and permission are re-checked after the write guard. The gated loop runs only for Windows input-record agents; elsewhere only the existing launch retry remains, skipped once a turn started. The blind launch retry no longer ends the Windows rescue early.
…side worker-start's grace Re-review follow-up: a held placeholder must stand alone and its count fit the prompt (measured +2 per LF, +1 per absorbed Enter), so text the user typed or an unrelated paste is never submitted. The draft and the held deadline are re-checked after the write guard, right before the retry Enter. The held wait is capped against the paste's ingest, and worker-start shortens its turn observation by any delivery that ran past its client grace.
The screen read can take seconds, so it now runs before the deadline and turn-start checks, leaving nothing awaited between them and the retry Enter. The wait between gated retries is clamped to the remaining held window.
…tail A 32-char fragment from the middle of the prompt could be the user's own text, and the rescue would submit it. A scrolled composer shows the paste's end, so the tail still matches.
ELI5
On Windows, Codex reads a paste one key at a time, and on a slow machine that takes a while. For a ~10 KB task it took about 20 seconds. Orca pressed Enter after well under a second. That Enter reached Codex while it was still reading the paste, so Codex treated it as a newline inside the paste. The task then sat in the composer as
[Pasted Content N chars]and never ran. After the first Enter, Orca now checks the composer. If no turn has started and the composer still holds a draft, Orca presses Enter again. It keeps checking for a window sized to the paste.Root cause
The issue title is out of date. On
main, the paste and the Enter already go out as separate writes (terminal-agent-prompt.ts), except for OMP. What fails now is the timing of that one Enter.KeyCode::Char/KeyCode::Enterevents, andPasteBursttreats an Enter during an active burst, or within 120 ms of its last key, as a newline inside the paste instead of a submit:paste_burst.rs:1-9(Windows pastes arrive as key events; "Ensure Enter is treated as a newline inside the paste")paste_burst.rs:153-164(PASTE_ENTER_SUPPRESS_WINDOW= 120 ms, 60 ms Windows idle flush)paste_burst.rs:323-337andchat_composer.rs:2869-2888(Enter appended to the burst / inserted as\n)submitRetryDelayMs, STA-5379) only ran on thecomposerReadylaunch path. Dispatch preambles,dispatch --inject,worker-startand agent-promptterminal.sendnever got it.What changed
resubmitHeldAgentPrompt(newterminal-agent-prompt-resubmit.ts, replacingresubmitAgentPromptAfterRetryDelay) runs after the first Enter for agents withsubmitRetryDelayMs(codex, qwen-code):getAgentPromptHeldSubmitBudgetMs> 0: a Windows write host andwindowsInputRecordPasteNewline, so Codex): everysubmitRetryDelayMsit waits for a turn start. Turn-start evidence comes fromverifyAgentPromptSubmission: lifecycle or hook, never output bytes. If no turn has started, it presses Enter again only while the composer draft is this prompt (isHeldAgentPromptDraft). That means one of two things. Codex's[Pasted Content N chars]placeholders appear with nothing else beside them, and their sum lies between the prompt's length and that length plus 2 per LF, plus 1 per absorbed Enter, plus 8. That bound was measured: a 10,312-char prompt with 142 LFs showed 10,597. Or the visible text matches the prompt. A rotating placeholder such asExplain this codebase, a question overlay, the user's own text (alone or typed beside the held paste), and an unrelated paste never get an Enter. AfterbeforeWrite, the turn start, permission, held deadline and draft match are all checked again, right before the write. Once the prompt is gone after a gated retry, it stops. The window is 3 ms/char, capped atAGENT_PROMPT_EFFECT_TIMEOUT_MSminus twice the paste's ingest floor. So the render gate (≤ 8 s + ingest), ingest itself and this wait add up to ≤ 38 s of delivery.worker-startshortens its turn-start observation to whatever is left of its 50 s client grace after delivery (min(30 s, 50 s − delivery)). The RPC can no longer time out because of a held wait. A delivery under 20 s, which is every case today, keeps the full 30 s.main's behaviour is unchanged. There is no new wait. The only change: acomposerReadylaunch's one blind retry is now skipped once the first Enter started a turn.How verified
Real Codex CLI 0.162.1 on a low-spec Windows 11 host (
win-lowspec, Orca 1.4.205 as the PTY host), driven from the Orca CLI. Codex was given a throwawayCODEX_HOMEwith a dummy API key, so a submit shows up as a turn that ends in 401.orca orchestration dispatch --injectof a 5.5 KB spec (10,597 chars with the preamble). Dispatch returnedokin ~1.3 s. The composer still held[Pasted Content 10597 chars]40 s later, in 3/3 fresh-worker trials.dispatch --inject, press Enter again only while the composer shows a draft, every 1.2 s. In 4/4 trials there was exactly one extra Enter, about 20-21 s after dispatch, when the placeholder appeared. It submitted the full task every time. Alternating old/new trials: old 2/2 held, new 4/4 submitted. After the final review: 2/2 more real dispatches with the bounded rule were each rescued by one Enter (~22 s). A real held[Pasted Content 10597 chars]with the user'salso fix the readme typotyped beside it resolved to no Enter. After the review redesign: 2/2 real dispatches matched[Pasted Content 10597 chars]against the prompt and were rescued with one Enter (~25 s). A worker with an empty composer and one holding the user's own text (also fix the readme typo) both resolved to no Enter.worker-startobserves only the time left of its grace after a 40 s delivery.pnpm tc:node,pnpm run check:code-quality:changed, andpnpm teston the runtime and orchestration suites all pass (2125 passed). The twoorca-runtime.test.tsfolder-import failures also happen without this change: they come from the macOS/private/vartmp path.Risk
dispatch --injectreply is late by that much, but stays inside its 60 s CLI timeout.unobserved/unverifiable, never as failed.⚠ N warningfooter row. The rescue doesn't fire there, which is today's behaviour.Fixes #11343