Repository navigation
Conversation
The turn-end todo nudge (#6720) advertised only todo_write. The tools block sits first in the Anthropic prompt cache, so each nudge rewrote the whole cached history twice: once for the nudge turn and once for the next turn. The request builder now strips the nudge's trailing rules from the caller policy before agent resolution, so the nudge turn advertises the same tools, system prompt and provider options as the turn before it. Tool assembly enforces the nudge rules at execution through a new execution gate: every tool except todo_write keeps its definition but returns a refusal before any side effect, on direct calls, inside code_execution (PTC) and for MCP tools. Provider-executed tools (native web_search/web_fetch) have no local execute, so they stay usable; they cannot run commands or edit files. The nudge rules stay in the persisted toolPolicy, so retried, restarted or compacted nudges (and older Xum builds) still narrow. --- _Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_ <!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=high --> (cherry picked from commit 6e1f806b3244082f413b000a9b2970d4c339c8a5)
The turn-end todo nudge queues its turn with the caller policy plus a todo_write-only rule. That rule governs the nudge turn alone, but later turns inherited it: - TaskService's terminal-wake walk (sub-agent report, workflow and idle drain wakes) adopted the nudge row's whole policy as the conversation's restriction, so every later wake ran with todo_write only until the next manual send. - AgentSession handed the nudge turn's options to the goal continuation and to a plugin turn.stop continuation after the nudge. With the previous commit's execution gate, these turns would advertise every tool and refuse all but todo_write. The wake walk now adopts only the caller part of a nudge row's policy (an empty caller part restricts nothing, like any synthetic row without a policy), and AgentSession strips the nudge's rule from the options later turns inherit. The nudge turn itself, including its retries and compaction follow-ups, keeps the rule. --- _Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_ <!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=high --> (cherry picked from commit 1eef5a91d582e01affdec4a967994274ecaee840)
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (1)ℹ️ 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 765000623d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
Review round 1 on #7011: - The request builder, AgentSession and the TaskService wake walk inferred a nudge turn from a policy that ends with the nudge's todo_write-only rule. A caller that sent that rule itself was then treated as a nudge, and the rule was stripped from what later turns and wakes inherited, so they regained bash and file edits. A nudge turn is now proven by its own row: synthetic, with exactly the nudge's text (the transcript renders it by the same test). The builder and AgentSession read the newest user row that carries a tool policy in the request's history; the wake walk checks the row it adopts. Any other turn keeps its whole policy. - A nudge turn's stream policy kept the agent's require rules, so a required tool the gate refuses kept the turn stepping. Require rules become plain enables in the nudge's stream policy; the advertised tools are unchanged. - Frontier Grok with xAI search mode "on" forced a paid search on the nudge's first step. The nudge turn now forces no search. --- _Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_ <!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=high -->
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 118fec8ec3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
Review round 2 on #7011: the nudge gate refused each bridged tool's execute, but RLM kernel methods reach the host without it. mux.load reads files through the kernel file loader whenever file_read is bridged, so code_execution could read workspace files during the nudge. On a gated turn code_execution itself now returns the gate's refusal, so no bridge or kernel path runs: mux.load, task_spawn, mux.events, kernel vars and every bridged tool. It stays advertised, so the tools block is unchanged. todo_write is PTC-excluded, so it stays a direct tool and the nudge still works. --- _Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_ <!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=high -->
There was a problem hiding this comment.
🛡️ Codex Security Review · Automatically triggered
Here are some automated security review suggestions for this pull request.
Reviewed commit: b0145f1572
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
Review round 3 on #7011: the nudge gate kept every provider-executed tool, because the provider runs it and Xum cannot refuse it. Where tool hooks cannot run, Claude 4.6+ gets Anthropic's native web_fetch and Gemini 3 gets url_context. Both fetch any URL server-side, past local hooks, so a prompt injection could make the todo-only nudge turn send source or chat data to an attacker's URL. Before this PR the nudge hid them. The gate now keeps only an allow-list of provider-executed searches (Anthropic web_search, Google google_search, OpenAI web_search, xAI web_search and x_search): they take a query, not a URL the model picks. Every other provider-executed tool, unknown ones included, is omitted on the nudge turn (fail closed). Native fetches exist only where hooks cannot run, so only there does a nudge cost a cache miss; trusted projects use Xum's local web_fetch, which the gate refuses, and keep the tools block. --- _Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_ <!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=high -->
…e turn OpenAI web_search can open live pages (open_page action) and xAI web_search browses web pages, so a prompt injection could make the todo-only turn reach a URL the model picks. Keep only query-only searches on the nudge turn.
|
Closing as superseded by #7027 and #7029, which merged on main while this PR was in review.
Residual, not fixed: a nudge row stored by a build from #6720 to before #7027 still has the The security findings from rounds 2 and 3 (code_execution, native fetch and page-opening searches during the nudge) applied only to this PR's execution gate, so they do not apply to main. |
Summary
The turn-end TODO nudge (#6720) no longer breaks the Anthropic prompt cache, and its tool limit no longer leaks into later turns. Before this PR, the nudge turn advertised only
todo_write, so the tools section (the first part of the cached prefix) changed, and the next turn changed it back: two full history rewrites per nudge. Now the nudge turn sends the previous turn's tools, system prompt and options unchanged, and every tool excepttodo_writerefuses at execution. One exception: provider-run tools that can open a URL the model picks are omitted on the nudge turn (see below). Report wakes, goal continuations and plugin continuations after a nudge get the caller's tools back. Before, they inheritedtodo_writeonly.Background
Measured on one host after the 10-15 prompt-cache fixes (10-17 16:16 to 10-18 12:58 UTC, about 926 Anthropic turns): 72 of 116 prefix breaks were the tools section flipping between 249 tools and exactly one tool,
todo_write. That was about 5.7 of 6.2 rewritten histories per 100 turns in the clean window. Turn envelopes show 1-tool manifests (todo_write) between 249-tool requests.A second bug showed up live: after a nudge, a sub-agent report wake ran with only
todo_write("Model tried to call unavailable tool 'bash'. Available tools: todo_write.").TaskService.resolveTerminalWakeCallerSendRestrictionsadopts the newest user row'stoolPolicyas the conversation's restriction. It already skipped compaction rows, whose policy is per-turn, but not the synthetic nudge row.Implementation
splitTodoTurnEndNudgePolicyrecognizes the nudge's trailing rule and strips it from the caller policy before agent resolution. Tools, tool search and the memory guidance are then computed exactly as in a normal turn. The nudge sets notoolChoice.TODO_TURN_END_NUDGEtext (the transcript's own test). Any other turn, including a manual send with the same todo_write-only rule, keeps its whole policy, and later turns inherit it. No new persisted field.executionGatein tool assembly turns every tool excepttodo_writeinto a refusing stub with the same definition, before the code_execution bridge is built. It covers direct calls, MCP tools and computer-use tools. On a nudge turncode_executionitself refuses, so no sandbox path (bridged tools,mux.load,mux.task_spawn,mux.events, kernel vars) can run.todo_writeis PTC-excluded, so it is always a direct tool. The gate applies only on a proven nudge turn. Its stream policy turns require rules into plain enables, so no required tool that the gate refuses keeps the turn stepping, and forced xAI search is off.readPersistedCallerToolPolicy). AgentSession passes options without the nudge rule to turn.stop hooks, goal advancement and the goal continuation (withoutTodoTurnEndNudge).toolPolicy. Retries and compaction follow-ups of the nudge turn itself still narrow, and older builds keep the old behavior. No new persisted field.Provider-run tools in the nudge turn
A tool that the provider runs on its own servers has no local execute, so Xum cannot refuse it at execution. The nudge turn keeps only searches that take a query and cannot open a page the model picks: Anthropic
web_search, Googlegoogle_searchand xAIx_search. Every other provider-run tool is omitted on the nudge turn, unknown ones included (fail closed). That drops native fetches (Anthropicweb_fetch, Googleurl_context) and the searches that also open live pages (OpenAIweb_searchwith itsopen_pageaction, xAIweb_search). A prompt injection could otherwise make the todo-only turn send chat data to a URL it picks.Cache cost: native fetches exist only where tool hooks cannot run (untrusted projects), so only there does a nudge drop a tool. OpenAI and xAI searches exist in every project, so a nudge on those providers costs one cache miss. Trusted Anthropic and Google projects keep a byte-identical tools block. The nudge turn can now search the web with the kept searches, which it could not before.
Validation
Each test fails with its change reverted:
aiService.test.ts: an untrusted Claude 4.6+ nudge drops nativeweb_fetchand keeps nativeweb_search. A trusted normal turn, then the nudge, through the real request path. The tools section, cached system row, system tail and provider options are identical, and no forced tool choice is set.bash,file_edit_insert,memoryand an MCP tool are refused, no file is created, andtodo_writesucceeds.toolAssembly.test.ts: the gate keeps the query-only searches and omits nativeweb_fetch,url_context, OpenAI and xAIweb_searchand an unknown provider tool. With code_execution on,code_executionis refused on the nudge turn andtodo_writestill runs. With RLM on,mux.loadthrough code_execution gets the refusal and the kernel loader is never called.taskService.autoResume.test.ts: after a nudge row, a child report wake gets the caller's policy (unrestricted, and a caller that disablesbash), and no execution gate.agentSession.turnStopHooks.test.ts: a plugin continuation and a goal continuation after the nudge get no nudge rule.Risks
Medium-low. The change touches tool assembly for the nudge turn and the wake restriction walk.
todo_writeonly. Compaction rows have the same gap today. Telling "the nudge turn itself" from "a later turn with no new row" is a larger change.Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high• Cost:$532.41