Repository navigation
🤖 fix: keep the end of the reply in the turn-stop text - #7833
Conversation
A completion promise such as <promise>DONE</promise> sits at the end of a reply, so a long turn-stop text must keep its last 16,384 UTF-16 units, not its first. The cut drops a leading lone low surrogate. Signed-off-by: Thomas Kosiewski <tk@coder.com>
Name the leading low-surrogate regex instead of narrating it, keep the constant's original doc comment, and make the high-surrogate test input asymmetric so it also fails when the head is kept. --- _Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_ <!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=xhigh -->
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
🟢 e2e stories (Haiku): 14 passed22 agent steps · 7 replayed from cache · 15 model calls · 46.3k tokens (24% cached) All 14 tests in 9 files
e2e 0.20.0 · 1m 9s · web · run artifacts 🟢 e2e Electron stories (Haiku): 3 passed3 agent steps · 3 model calls · 8.0k tokens (22% cached) All 3 tests in 3 files
e2e 0.20.0 · 20.7s · electron · run artifacts 🟢 e2e agent repros (Haiku): no tests selectedSpend: $0.00 of the $1.00 cap (proxy ledger) e2e 0.20.0 · 5.4s · 2 targets (web, phone) · run artifacts |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
…quests skill (coder#7885) ## Summary The `pull-requests` skill now explains the Codex security review receipt that the `Codex Comments` check needs, when `wait_pr_codex.sh` requests it, and why each pushed head costs two Codex review rounds. ## Background During the Cursor plugin stack (coder#7833 to coder#7847, follow-ups in coder#7858), agents on nine PRs hit the same stop: Codex approved the head, but `Codex Comments` exited 10 with "No Codex security review was requested for <head>: request one". Owners did not know the gate needed a comment-triggered security review, or that `wait_pr_codex.sh` posts that request only after a person has asked Codex for a review in a PR comment. Each pushed head also used two of the six allowed rounds, which owners did not budget for. ## Implementation A new subsection under "Handling Codex Comments" states three facts, each read from the current scripts: 1. Codex posts a security receipt only for a comment-triggered review (`scripts/wait_pr_codex.sh` cites coder#7731). 2. `request_security_review_if_needed` posts a Codex security review request that names the head, once per head. `CHECK_CODEX_STATUS_ONCE` stops before that when no person has asked Codex for a review in a PR comment. 3. So each pushed head costs two rounds. Batch fixes per push. --- _Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `high` • Cost: `$125.78`_ <!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=high costs=125.78 -->
Summary
Codex
Stophooks now receive the end of a long reply aslast_assistant_message, not its start.lastAssistantTextkeeps the last 16 × 1024 UTF-16 units of the reply's trailing text run. If the cut starts on the low half of a surrogate pair, it drops that one unit, so the text never starts with a lone surrogate. The #6067 rule is unchanged: the text is the trailing text run, and it isnullwhen the turn ends on a tool part.This is the bottom PR of stack C for the Cursor plugin RFC (#7829). The later Cursor
afterAgentResponseandstophooks use this text.Background
A stop-loop hook (for example a "ralph loop") ends the loop when the reply contains a completion promise such as
<promise>DONE</promise>. That promise sits at the end of a reply. Today Xum keeps the first 16 × 1024 characters, so a reply longer than that loses the promise, and the hook keeps the loop running.RFC:
rfc/20261030_cursor-plugin-support.md(on the RFC branch of #7829), section "PR 5: Turn-stop text", decision D22, and the section 8 row for the turn-stop text.Implementation
src/node/services/agentPlugins/promptHooks.ts:text.slice(0, N)becomestext.slice(-N).replace(LEADING_LONE_LOW_SURROGATE, ""). The whitespace-onlynullcheck still runs on the whole run, as before. The doc comment says the end is kept and why.src/node/services/agentPlugins/promptHooks.test.ts: four tests forlastAssistantText:null.lastAssistantTexthas one production caller (agentSession.ts, which fillsTurnStopContext.lastAssistantMessage). Its only reader is the CodexStophook input incodexHookRunner.ts. No caller needs the start of the text.Validation
AgentSessionand a real CodexStophook (registerCodexPluginHookson the event spine). It recorded the hook's${last_assistant_message}for a 20,000-character reply that comes after a tool call:yyyy…, so the promise is lost.…<promise>DONE</promise>. A turn that ends on a tool part givesnull.make crap-check,make dry-checkandmake mutate-check(10 killed, 0 survived) pass on the changed function.Risks
Low. Only the Codex
Stophook input changes, and only for replies longer than 16 × 1024 characters in their trailing text run. A hook that parsed the start of a long reply now sees its end. Shorter replies are unchanged. Two known edge cases remain, and both need malformed or unusual model output:Release note
The turn-stop text passed to hooks keeps the last 16 × 1024 characters of the reply's trailing text run instead of the first. Codex
Stophooks receive the same text.Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:xhigh• Cost:$4.69