Repository navigation
fix(agents): keep tool catalogs stable across completion wake turns - #182191
Conversation
Record operator client capabilities in session metadata and reuse that fact for tool definitions and the Code Mode catalog across wakes and recovery. Keep current-client execution gates and live browser recipient checks, with actionable guidance when a wake cannot invoke a client-bound tool. Document declaration replacement and reset lifecycle. Add regressions for stable WebChat catalogs and refused unbound screen calls.
Keep sessions_create in the offered tool surface when a WebChat operator turn becomes a senderless wake or recovery turn. Gate unauthorized execution with the existing tool refusal helper and retain live creation-owner checks. This prevents the deferred Code Mode catalog count from changing with the current turn's session-write authority, including CLI chat.send sessions. Extend the prefix-stability regression for browser and CLI clients carrying real admitted operator authority, and verify that a denied constructor cannot gain authority from a later caller context. Keep the existing session-owned client capability and screen enforcement fix. Validation: the new operator/wake cases fail on 34f94e4 with exactly sessions_create missing. Focused prefix and session-create suites pass.
Use the requester session ceiling for plugin listing and keep the child-completion policy in execution and descendant authority. Preserve a subagent requester own inherited restrictions and give denied completion calls an explicit refusal. Prove stable plugin definitions and Code Mode catalog, denied execution, and nested requester listing. The exact regression fails on ca48d43 and passes with this change; focused policy/plugin suites, repeated touched tests, lint, agent typecheck, and independent review pass.
|
🦞👀 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 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. |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 199c2a0484
ℹ️ 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".
| const inlineWidgetClientAvailable = | ||
| (options?.listingClientCaps ?? options?.clientCaps)?.includes("inline-widgets") === true; |
There was a problem hiding this comment.
Preserve pinned widget authoring during restart recovery
When a Control UI session with recorded inline-widgets capabilities resumes after a restart, resolveAgentRestartRecoveryContext explicitly enables pinnedWidgetAuthoring without a current inline client. Using the recorded capabilities here makes inlineWidgetClientAvailable true, which disables pinnedWidgetOnly below. Consequently, show_widget acquires an inline-widgets requirement and filterToolsByClientCaps refuses every call, including pin=true dashboard updates that recovery previously supported. Keep recorded capabilities for catalog stability without removing the recovery path's client-independent pinned authoring capability.
AGENTS.md reference: src/agents/AGENTS.md:L21-L21
Useful? React with 👍 / 👎.
Update existing session-creation integration assertions for the stable catalog contract. Require unauthorized calls to return the execution gate refusal, never dispatch to the creation handler, and preserve the session key set. Keep explicit policy-deny coverage.
Assert the exact schema-bearing worker set while retaining all collector completion-order checks. Initial calls below maxConcurrent may race; only overflow children queue FIFO.
Satisfy typed sort-comparator lint while preserving the exact schema-bearing worker set and all completion-order assertions.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Since #182191 the tool catalog follows the session's recorded client capabilities so wake and recovery turns keep a stable prefix. A recovered Control UI turn with no inline-widgets client therefore received the full inline show_widget schema, and the current-caps execution gate refused every call, including pin=true. The dashboard update was silently dropped while the run still finished ok (test/gateway-widget-restart.e2e.test.ts failed deterministically on main). Keep the recorded schema, but when pinned authoring is admitted and the current turn lacks an inline client, execute pinned calls and refuse inline ones with an actionable message instead of the generic client gate. Proof: new openclaw-tools.scheduled-widget regression fails on the base (board.widget.put never called) and passes with the fix; the widget restart e2e failed 2/2 on main and passes 5/5 with the fix under the pinned Bun runtime.
…penclaw#182191) * fix(agents): retain session client capabilities across wake turns Record operator client capabilities in session metadata and reuse that fact for tool definitions and the Code Mode catalog across wakes and recovery. Keep current-client execution gates and live browser recipient checks, with actionable guidance when a wake cannot invoke a client-bound tool. Document declaration replacement and reset lifecycle. Add regressions for stable WebChat catalogs and refused unbound screen calls. * fix(agents): keep session creation catalogs stable across wakes Keep sessions_create in the offered tool surface when a WebChat operator turn becomes a senderless wake or recovery turn. Gate unauthorized execution with the existing tool refusal helper and retain live creation-owner checks. This prevents the deferred Code Mode catalog count from changing with the current turn's session-write authority, including CLI chat.send sessions. Extend the prefix-stability regression for browser and CLI clients carrying real admitted operator authority, and verify that a denied constructor cannot gain authority from a later caller context. Keep the existing session-owned client capability and screen enforcement fix. Validation: the new operator/wake cases fail on 34f94e4 with exactly sessions_create missing. Focused prefix and session-create suites pass. * fix(agents): gate completion tool denies without changing catalogs Use the requester session ceiling for plugin listing and keep the child-completion policy in execution and descendant authority. Preserve a subagent requester own inherited restrictions and give denied completion calls an explicit refusal. Prove stable plugin definitions and Code Mode catalog, denied execution, and nested requester listing. The exact regression fails on ca48d43 and passes with this change; focused policy/plugin suites, repeated touched tests, lint, agent typecheck, and independent review pass. * test(agents): assert creation authority at execution Update existing session-creation integration assertions for the stable catalog contract. Require unauthorized calls to return the execution gate refusal, never dispatch to the creation handler, and preserve the session key set. Keep explicit policy-deny coverage. * test(agents): allow concurrent swarm startup calls Assert the exact schema-bearing worker set while retaining all collector completion-order checks. Initial calls below maxConcurrent may race; only overflow children queue FIFO. * test(agents): use explicit swarm call comparator Satisfy typed sort-comparator lint while preserving the exact schema-bearing worker set and all completion-order assertions.
Since openclaw#182191 the tool catalog follows the session's recorded client capabilities so wake and recovery turns keep a stable prefix. A recovered Control UI turn with no inline-widgets client therefore received the full inline show_widget schema, and the current-caps execution gate refused every call, including pin=true. The dashboard update was silently dropped while the run still finished ok (test/gateway-widget-restart.e2e.test.ts failed deterministically on main). Keep the recorded schema, but when pinned authoring is admitted and the current turn lacks an inline client, execute pinned calls and refuse inline ones with an actionable message instead of the generic client gate. Proof: new openclaw-tools.scheduled-widget regression fails on the base (board.widget.put never called) and passes with the fix; the widget restart e2e failed 2/2 on main and passes 5/5 with the fix under the pinned Bun runtime.
…183286) Narrow slice of #179363. Keep native Codex tool declarations stable across completion turns and enforce current owner authority when tools execute. Preserve the existing four-name fingerprint workaround and the fixes from #182191 and #183059. Validated with the factory regression red on base and green on this head, 104 targeted tests, and exact-head CI. Live transport proof remains a documented gap. Co-authored-by: Marvinthebored <[email protected]> Co-authored-by: Dallin Romney <[email protected]>
…183286) Narrow slice of #179363. Keep native Codex tool declarations stable across completion turns and enforce current owner authority when tools execute. Preserve the existing four-name fingerprint workaround and the fixes from #182191 and #183059. Validated with the factory regression red on base and green on this head, 104 targeted tests, and exact-head CI. Live transport proof remains a documented gap. Co-authored-by: Marvinthebored <[email protected]> Co-authored-by: Dallin Romney <[email protected]> (cherry picked from commit 6a62821) Adapted for 2026.9.x: native-thread-tool.ts resolved by hand against the 9.x execute layout (owner check at execute entry, in the request-options assertCurrent, and as the binding-clear commit guard; 9.x has no separate prepared session-entry guard). Tests rewritten onto the 9.x fixtures (sync createTool, 9.x supervision registration test).
…penclaw#183286) Narrow slice of openclaw#179363. Keep native Codex tool declarations stable across completion turns and enforce current owner authority when tools execute. Preserve the existing four-name fingerprint workaround and the fixes from openclaw#182191 and openclaw#183059. Validated with the factory regression red on base and green on this head, 104 targeted tests, and exact-head CI. Live transport proof remains a documented gap. Co-authored-by: Marvinthebored <[email protected]> Co-authored-by: Dallin Romney <[email protected]>
…183286) Narrow slice of #179363. Keep native Codex tool declarations stable across completion turns and enforce current owner authority when tools execute. Preserve the existing four-name fingerprint workaround and the fixes from #182191 and #183059. Validated with the factory regression red on base and green on this head, 104 targeted tests, and exact-head CI. Live transport proof remains a documented gap. Co-authored-by: Marvinthebored <[email protected]> Co-authored-by: Dallin Romney <[email protected]> (cherry picked from commit 6a62821) Adapted: applied the native-plugin-tool.test.ts owner-denial hunk inside the release describe block.
…183286) Narrow slice of #179363. Keep native Codex tool declarations stable across completion turns and enforce current owner authority when tools execute. Preserve the existing four-name fingerprint workaround and the fixes from #182191 and #183059. Validated with the factory regression red on base and green on this head, 104 targeted tests, and exact-head CI. Live transport proof remains a documented gap. Co-authored-by: Marvinthebored <[email protected]> Co-authored-by: Dallin Romney <[email protected]> Release adaptation: stable's thread tool lacks main's session-entry current-check capture; applied only the owner-authority move (declare unconditionally, assert owner at execute/commit). Ported the owner-denial cases into stable's test fixtures. (cherry picked from commit 6a62821)
What Problem This Solves
In a session with subagents, the requester's internal completion wake turns listed fewer tools than its operator turns. The Code Mode catalog changed mid-session ("43 additional tools omitted" became "42") and the request instructions were rewritten in place, breaking the provider prompt prefix on every switch between operator and wake turns. On some builds it showed up as an appended "System prompt update" replacing the whole
## Toolingsection, about 5 KB per flip. The AGENTS.md contract is that within a session, tool definitions depend only on session and config facts, and per-turn authority gates calls.User Impact
Tool definitions and the Code Mode catalog remain stable across operator and internal completion wake turns in the same session. Current-turn execution authority remains enforced; this does not grant completion turns additional tool authority. No configuration changes or migration steps are required.
Why This Change Was Made
Root cause
Three per-turn facts leaked into tool listing:
screenrequiresui-commands, andfilterToolsByClientCapsfiltered on the current turn's client. Internal completion dispatch uses a synthetic client with no capability list (subagent-announce-completion-delivery.ts,forceSyntheticClient).sessions_create's constructor returnednullwhen the current Gateway caller lacked session-write authority (sessions-create-tool.ts).intent,screen,gateway,nodes…) into the requester's tool construction (requester-tool-policy.ts).agent-tools.tspassed it into plugin construction, andsrc/plugins/tools.tsskipped denied registrations before their factories ran. This was the flip observed live: memory-core'sintentwas built on operator turns and never on wakes.Fix
ui-command.ts, with an actionable Control UI refusal.sessions_createis always defined. Unauthorized calls are refused by the existing execution gate, and creation-owner checks are unchanged.sessionInheritedToolPolicy). The replayed child policy gates execution instead: a denied call reports that the tool "is not available during a child-completion turn because it is outside the authority carried from its requester", throughresolveTurnToolSurface/gateAgentToolExecution. A subagent requester's own inherited restrictions still remove tools from its listing, and spawn/descendant ceilings are unchanged. This followsdocs/tools/subagents/tool-policy.md, which keeps captured restrictions at execution; the doc is updated.Security notes
This change separates session-stable tool discovery from per-turn authorization. Current client capability checks, the live-browser recipient check, session creation-owner checks, completion execution restrictions, and spawn/descendant ceilings remain enforced. It touches tool policy and authority and retains the repository's applicable security review gates.
Evidence
agent-tools.prefix-stability.test.ts(operator vs internal wake in WebChat sessions, browser and CLI clients: identical tool definitions and catalog; base lostscreen, thensessions_create) and the newopenclaw-plugin-tools.wake.test.ts(base: the wake listing lacksintent; fixed: stable listing, refused execution on the completion turn, and a subagent requester's own deny still applied). Also green:agent-tools.turn-authority,requester-tool-policy,scheduled-message-invocation,tools.optional,tools.inspection,agent-tools.plugin-policyandsessions-create-tool— 161 tests across the focused suites.chat.sendon dashboard keys, with a debug probe in the built catalog formatter (not committed):intent) on the operator turn and 63 (without) on the first wake; the instructions changed 43 → 42 mid-session.64+intent; both parents' instructions carry a constant "43 additional tools omitted" across all requests (10 and 9); fleets 2/2 at 35/35.github_publishlisting still depends on current authority whengithubPublicationAvailable === false(openclaw-tools.ts); it wasn't the observed flip. Separately, a profile change restarting the prompt series (route key includes the bootstrap profile, a79e29e) rewrites instructions instead of appending a delta.CI follow-up
Initial CI found two existing session-creation tests that still expected unauthorized tools to be absent. The follow-up test-only commit preserves their security contract with assertions for stable listing, gated execution, no creation-handler dispatch, and an unchanged session key set. Both focused files pass on the provided Crabbox host (28 tests), and the repair passed independent review plus formatting, lint, and whitespace checks.
CI also exposed a swarm fixture that assumed the first structured model calls finish in startup order. Its three collectors start concurrently below the group’s
maxConcurrent; only excess children queue FIFO (docs/tools/swarm.md). The test now sorts those calls before requiring exactly[1, 3], still excluding worker 2, and all completion-order assertions remain unchanged. This is a test-only contract correction. The focusedswarm-tools.integration.test.tsrun passes on the supplied AWS Crabbox host (1/1 test; Vitest 33.07s, wrapper wall time 71.05s, mostly existing transform/setup work). Independent review found no actionable P0/P1 issues; formatting, lint, and whitespace checks pass.The separate stop-followup failure reproduces on clean main
3bcc91708d8at the same line with the same missingkillReconciliationerror (10 tests passed, 1 failed). It is unrelated to this change and remains eligible for the authorized inherited-failure route; failed CI is not claimed as green.The next CI attempt required an explicit numeric comparator for
toSortedundertypescript/require-array-sort-compare. That one-line test-only repair passes typed lint (0 warnings/errors), the focused swarm test, and independent review. The expected worker set and completion-order assertions are unchanged.CI run 40063420932 also reported
session-accessor.recovery.test.ts/preserves recovery success after committed owner retirement(unexpected database-execution captures). The full file passed on the PR source and on the exact clean CI base4188c9e09cb; the failing case then passed three targeted Bun runs on that base. Its cause remains unresolved; no inherited-failure exception is claimed for it and passing replays are not a repair.On final head
236b246e49e, CI run 40064355273 reports the same stop-followup failure inchecks-node-changed-compact-small-19. Scheduled main run 40062828625 reports the same test and missingkillReconciliationerror. The test and persistence-owner files are unchanged by this PR. All jobs finished with this sole root failure; the PR landed through the authorized native inherited-failure route ase4d101a4916281a5b0f2be4ae633db7a750fdb55. CI remains recorded as failed. The prior recovery assertion did not recur on the final head.