Repository navigation
fix(agents): keep polling tools visible so the repeat guard reads their own exemption - #206801
Conversation
…ir own exemption - With Tool Search on, agents_wait and subagents were reachable only through dispatch_action, whose missing repeatable declaration let the repeat guard note and then stop ordinary polling at call 20. - isDirectVisibleCatalogTool keeps OpenClaw tools that declare repeatable in the provider tool list unless they are on-demand. Code Mode, the guard, dispatch_action and the worker wire are unchanged.
|
🦞👀 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: passed. What this changesThe PR keeps trusted repeatable tools directly visible under Tool Search so the repeat guard reads their own exemptions. Example: The model makes 25 identical agents_wait calls with ids=["child-1"] and timeoutSeconds=30.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a current polling failure through the existing tool-visibility owner. No introduced correctness defect was found. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherTool Search projects the authorized tool catalog into provider-visible tools and deferred entries; the agent loop checks repeat exemptions on the tool resolved for each model call. flowchart LR
A[Authorized tool catalog] --> B[Tool Search visibility owner]
B --> C[Direct polling tools]
B --> D[Deferred tool catalog]
D --> E[dispatch_action]
C --> F[Agent loop repeat guard]
E --> F
Technical reviewBest possible solution: Keep the focused visibility fix in the existing catalog owner while preserving action-specific exemptions and on-demand loading. Do we have a high-confidence way to reproduce the issue? Source establishes the failure: agents_wait declares repeatable, default Tool Search defers it, and the guard observes dispatch_action instead; the author reports the corresponding base failure, but no reproduction was run during this read-only review. Is this the best way to solve the issue? This is a small repair at the existing visibility owner, preserves the guard and worker protocol, and implements the maintainer's explicitly accepted direct-call approach. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c7ea9f418610. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +3, Tests +102, Docs +3. Total +108 across 3 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. LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 27, 2026, 11:19 AM ET / 16:19 UTC. |
…ir own exemption (#206801) With Tool Search on (the default), `agents_wait` and `subagents` are deferred, so the model can reach them only through `dispatch_action`. The tool repeat guard reads the `repeatable` declaration of the called tool, which is `dispatch_action`, not its target. A model that polls its children with the same `agents_wait` call gets a "stop repeating" note at call 3. At call 20 the turn ends with `tool_repeat_limit`, even though these tools exist to be polled. `isDirectVisibleCatalogTool` (the Tool Search owner of "which trusted tools stay in the provider tool list") now keeps OpenClaw tools that declare `repeatable` visible, unless they are on-demand. The model calls them by name, and the guard reads their own declaration. They stay searchable as before. - The guard, `dispatch_action` and the worker wire are unchanged. A dispatcher-side fix would need either a new `repeatable` shape in the worker tool protocol schema or a function that cannot cross the worker wire, so the visibility owner takes this. - Code Mode is unchanged. Its catalog also requires the tool in `directToolNames`, so guest scripts keep calling `agents_wait` as before. - On-demand tools (`computer`, `github_publish`) stay deferred. - Cost: `agents_wait` (638 B) and `subagents` (638 B) of tool schema join the tool list when those tools are enabled. That is +1,276 B, stable across turns. | Check | Tier | Base (`55f3ed64`) | Head | |---|---|---|---| | Tool Search `tools` and `directory` modes send `agents_wait` and `subagents`, and keep a plain tool deferred (`tool-search.repeatable.test.ts`) | vitest-source | **fails**: both deferred | passes | | 25 identical `agents_wait` polls through the real agent loop and guard | vitest-source | **fails**: the tool is not in the list; the only route is `dispatch_action` | passes: 25 run, no note, the turn ends normally | | Main's only route measured: 25 identical `agents_wait` calls through `dispatch_action` | vitest-source | note at call 3, 19 run, turn ends with `tool_repeat_limit` at call 20 | not the route any more | | A non-repeatable target repeated through `dispatch_action` still stops at call 20 with `tool_repeat_limit` | vitest-source | passes | passes | | Prompt-prefix stability, Tool Search on-demand/agent-loop/discovery/directory/catalog suites, system-prompt inventory and cache-prefix suites | vitest-source | | 13 files, 124 tests pass | A model that still routes a polling tool through `dispatch_action` is counted as `dispatch_action` calls. The tool is now in its tool list, so the dispatcher is not its route. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit afd8195) Backport adaptation: Keep release Tool Search documentation and use its trusted repeatable metadata without importing main-only on-demand catalog behavior. Co-authored-by: RomneyDa <[email protected]>
…ir own exemption (openclaw#206801) ## What Problem This Solves With Tool Search on (the default), `agents_wait` and `subagents` are deferred, so the model can reach them only through `dispatch_action`. The tool repeat guard reads the `repeatable` declaration of the called tool, which is `dispatch_action`, not its target. A model that polls its children with the same `agents_wait` call gets a "stop repeating" note at call 3. At call 20 the turn ends with `tool_repeat_limit`, even though these tools exist to be polled. ## Solution `isDirectVisibleCatalogTool` (the Tool Search owner of "which trusted tools stay in the provider tool list") now keeps OpenClaw tools that declare `repeatable` visible, unless they are on-demand. The model calls them by name, and the guard reads their own declaration. They stay searchable as before. - The guard, `dispatch_action` and the worker wire are unchanged. A dispatcher-side fix would need either a new `repeatable` shape in the worker tool protocol schema or a function that cannot cross the worker wire, so the visibility owner takes this. - Code Mode is unchanged. Its catalog also requires the tool in `directToolNames`, so guest scripts keep calling `agents_wait` as before. - On-demand tools (`computer`, `github_publish`) stay deferred. - Cost: `agents_wait` (638 B) and `subagents` (638 B) of tool schema join the tool list when those tools are enabled. That is +1,276 B, stable across turns. ## Evidence | Check | Tier | Base (`7c16bec3`) | Head | |---|---|---|---| | Tool Search `tools` and `directory` modes send `agents_wait` and `subagents`, and keep a plain tool deferred (`tool-search.repeatable.test.ts`) | vitest-source | **fails**: both deferred | passes | | 25 identical `agents_wait` polls through the real agent loop and guard | vitest-source | **fails**: the tool is not in the list; the only route is `dispatch_action` | passes: 25 run, no note, the turn ends normally | | Main's only route measured: 25 identical `agents_wait` calls through `dispatch_action` | vitest-source | note at call 3, 19 run, turn ends with `tool_repeat_limit` at call 20 | not the route any more | | A non-repeatable target repeated through `dispatch_action` still stops at call 20 with `tool_repeat_limit` | vitest-source | passes | passes | | Prompt-prefix stability, Tool Search on-demand/agent-loop/discovery/directory/catalog suites, system-prompt inventory and cache-prefix suites | vitest-source | | 13 files, 124 tests pass | ## Accepted edge case A model that still routes a polling tool through `dispatch_action` is counted as `dispatch_action` calls. The tool is now in its tool list, so the dispatcher is not its route. Co-authored-by: Ayaan Zaidi <[email protected]>
…ir own exemption (#206801) With Tool Search on (the default), `agents_wait` and `subagents` are deferred, so the model can reach them only through `dispatch_action`. The tool repeat guard reads the `repeatable` declaration of the called tool, which is `dispatch_action`, not its target. A model that polls its children with the same `agents_wait` call gets a "stop repeating" note at call 3. At call 20 the turn ends with `tool_repeat_limit`, even though these tools exist to be polled. `isDirectVisibleCatalogTool` (the Tool Search owner of "which trusted tools stay in the provider tool list") now keeps OpenClaw tools that declare `repeatable` visible, unless they are on-demand. The model calls them by name, and the guard reads their own declaration. They stay searchable as before. - The guard, `dispatch_action` and the worker wire are unchanged. A dispatcher-side fix would need either a new `repeatable` shape in the worker tool protocol schema or a function that cannot cross the worker wire, so the visibility owner takes this. - Code Mode is unchanged. Its catalog also requires the tool in `directToolNames`, so guest scripts keep calling `agents_wait` as before. - On-demand tools (`computer`, `github_publish`) stay deferred. - Cost: `agents_wait` (638 B) and `subagents` (638 B) of tool schema join the tool list when those tools are enabled. That is +1,276 B, stable across turns. | Check | Tier | Base (`55f3ed64`) | Head | |---|---|---|---| | Tool Search `tools` and `directory` modes send `agents_wait` and `subagents`, and keep a plain tool deferred (`tool-search.repeatable.test.ts`) | vitest-source | **fails**: both deferred | passes | | 25 identical `agents_wait` polls through the real agent loop and guard | vitest-source | **fails**: the tool is not in the list; the only route is `dispatch_action` | passes: 25 run, no note, the turn ends normally | | Main's only route measured: 25 identical `agents_wait` calls through `dispatch_action` | vitest-source | note at call 3, 19 run, turn ends with `tool_repeat_limit` at call 20 | not the route any more | | A non-repeatable target repeated through `dispatch_action` still stops at call 20 with `tool_repeat_limit` | vitest-source | passes | passes | | Prompt-prefix stability, Tool Search on-demand/agent-loop/discovery/directory/catalog suites, system-prompt inventory and cache-prefix suites | vitest-source | | 13 files, 124 tests pass | A model that still routes a polling tool through `dispatch_action` is counted as `dispatch_action` calls. The tool is now in its tool list, so the dispatcher is not its route. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit afd8195) Release adaptation: Use an existing trusted OpenClaw catalog predicate to keep repeatable tools model-visible. Stable does not have on-demand catalog tooling, so omit that exclusion and retain the stable directory wording. Keep Code Mode, dispatch_action and the repeat guard unchanged. Follow-ups: No later pinned-main production changes touch this owner; #204805 is an upstream-only prerequisite for the omitted exclusion, not required by the stable predicate. Co-authored-by: RomneyDa <[email protected]>
…elegation family together (#207314) ## Problem With Tool Search on (the default), #206801 made `subagents` and `agents_wait` direct tools. It did that only because the repeat guard read `dispatch_action`'s own `repeatable` declaration, not the declaration of the tool the call names. A model polling its children through `dispatch_action` got a "stop repeating" note at call 3 and `tool_repeat_limit` at call 20. That fix split the delegation family. `subagents` ("Subagent status/cancel") and `agents_wait` were sent with full schemas, while `sessions_spawn` stayed a bare name in the deferred list. gpt-5.4-mini then treated the two visible tools as the whole subagent capability and answered "sessions_spawn isn't available". Behavior-suite history for the subagent-spawn case: 21/21 found the tool before #206801 and 6/20 after. ## Fix The repeat guard now reads the target's declaration, and the polling tools are deferred again, with no added prompt bytes. - **One dispatcher argument reader.** The reader for selectors and input forms moved from `src/agents/tool-search-request.ts` to `packages/agent-core/src/dispatch-call.ts`: - selectors: `id`, `toolId`, `name`; - input: `args`, `input`, `args.<field>`, flattened arguments, and a selector wrapped inside the input. - `dispatch_action` executes through it with catalog matching. The repeat guard classifies through it with target matching. Both see the same target and the same input for every call form. - **Plain-data dispatcher declaration.** `ToolRepeatable` gets `{ dispatch: { targets, aliases } }`. `applyToolCatalogCompaction` builds it from the registered catalog: each trusted tool's own `repeatable` by catalog id, with its name as an alias when the name is unique. - The guard applies the target's own `true | { actions }`. A dispatched poll is exempt exactly as a direct call would be. - A selector that names anything else counts as a different target. A call with disagreeing selectors stays counted, matching the dispatcher, which refuses it as ambiguous. - The declaration is read once per call, on the path the call takes. - **Polling tools deferred again.** The "repeatable → direct" rule is removed. - **One visibility for the delegation family.** The Tool Search owner (`tool-search-catalog-visibility.ts`) lists `sessions_spawn`, `subagents` and `agents_wait` as one family. - If any member is sent directly (caller-required, or kept outside the catalog by a selector), the whole family is sent directly. - A member shown only because of its family never shadows a tool with the same name. - On the default surface the whole family is deferred. ## Why this and not "send `sessions_spawn` directly" The first version of this PR made the family direct: +12,236 B on every request, +35% on the first request. It was held because: - it undoes most of the prompt savings from #206537 and #206801; - reverting it later would change the tool prefix, and so bust deployed caches, twice; - #206801 is only on main, so no released user is affected. This version costs 0 KB. The first request is 1.4 KB smaller than on main, because the polling schemas leave the tool list. ## Evidence | Check | Tier | main `6d8e821a` | This PR | |---|---|---|---| | Both Tool Search modes defer the whole family; every non-empty member subset, with and without an include selector, has one visibility; 25 identical polls of `agents_wait` (name and catalog id) and `subagents list` through `dispatch_action` run with no note and no stop | vitest-source | **7 of 9 fail** | 10/10 pass | | A non-polling action (`subagents cancel`) and a non-repeatable tool repeated through `dispatch_action` still stop at call 20 | vitest-source | pass | pass | | Guard unit test: every dispatcher call form is exempt for a polling target; disagreeing selectors, unknown targets and non-polling actions are counted | vitest-source | n/a | pass | | `agent-tools.prefix-stability.test.ts`, Tool Search and runtime suites, `prompt:snapshots:check` | vitest-source / source | | green / current | Real gpt-5.4-mini runs (low thinking) on the subagent-spawn case, 5 trials per cell, against main `6d8e821a`: | Route | `sessions_spawn` called, main | `sessions_spawn` called, this PR | First request, main → this PR | |---|---|---|---| | Gateway | 9/10 (1 reply: "sessions_spawn isn't available") | **10/10** | 34.6 → 33.2 KB | | `--local` | 4/5 (2/5 and 2/6 in earlier runs) | **10/10** | 33.8 → 32.4 KB | What the user sees: - **Gateway, with a 60 s window for the child's completion:** the child's result reached the user in 5/5 runs on this PR and 4/5 on main. - **How the result arrives:** - With `subagents` deferred, 3 of 5 runs end the turn with `sessions_yield`, and the result arrives in the following completion message. - On main, the model waited inside the turn with the direct `subagents wait`. That pattern only exists since #206801. - Pre-#206801 behavior is the same yield pattern. - A yielded turn returns an empty CLI payload. That is an existing `sessions_yield` presentation gap, not caused by this change. - **No over-delegation:** read-file, shell-command and memory-recall, 3 trials each, both routes: 9/9 on main and on this PR, 0 spawn calls, and the same request count (15). - **`--local` caveat:** every variant's spawn then fails at runtime with "published reply runtime missing". That is a separate open gap, so only the call counts on that route. No worker protocol change. Workers compact Tool Search locally from each tool's own `true | { actions }` declaration, so the dispatcher form never crosses the wire. No change reaches the Control UI bundle either: shared `core-tool-facts.ts` is untouched. Co-authored-by: Ayaan Zaidi <[email protected]>
…elegation family together (openclaw#207314) ## Problem With Tool Search on (the default), openclaw#206801 made `subagents` and `agents_wait` direct tools. It did that only because the repeat guard read `dispatch_action`'s own `repeatable` declaration, not the declaration of the tool the call names. A model polling its children through `dispatch_action` got a "stop repeating" note at call 3 and `tool_repeat_limit` at call 20. That fix split the delegation family. `subagents` ("Subagent status/cancel") and `agents_wait` were sent with full schemas, while `sessions_spawn` stayed a bare name in the deferred list. gpt-5.4-mini then treated the two visible tools as the whole subagent capability and answered "sessions_spawn isn't available". Behavior-suite history for the subagent-spawn case: 21/21 found the tool before openclaw#206801 and 6/20 after. ## Fix The repeat guard now reads the target's declaration, and the polling tools are deferred again, with no added prompt bytes. - **One dispatcher argument reader.** The reader for selectors and input forms moved from `src/agents/tool-search-request.ts` to `packages/agent-core/src/dispatch-call.ts`: - selectors: `id`, `toolId`, `name`; - input: `args`, `input`, `args.<field>`, flattened arguments, and a selector wrapped inside the input. - `dispatch_action` executes through it with catalog matching. The repeat guard classifies through it with target matching. Both see the same target and the same input for every call form. - **Plain-data dispatcher declaration.** `ToolRepeatable` gets `{ dispatch: { targets, aliases } }`. `applyToolCatalogCompaction` builds it from the registered catalog: each trusted tool's own `repeatable` by catalog id, with its name as an alias when the name is unique. - The guard applies the target's own `true | { actions }`. A dispatched poll is exempt exactly as a direct call would be. - A selector that names anything else counts as a different target. A call with disagreeing selectors stays counted, matching the dispatcher, which refuses it as ambiguous. - The declaration is read once per call, on the path the call takes. - **Polling tools deferred again.** The "repeatable → direct" rule is removed. - **One visibility for the delegation family.** The Tool Search owner (`tool-search-catalog-visibility.ts`) lists `sessions_spawn`, `subagents` and `agents_wait` as one family. - If any member is sent directly (caller-required, or kept outside the catalog by a selector), the whole family is sent directly. - A member shown only because of its family never shadows a tool with the same name. - On the default surface the whole family is deferred. ## Why this and not "send `sessions_spawn` directly" The first version of this PR made the family direct: +12,236 B on every request, +35% on the first request. It was held because: - it undoes most of the prompt savings from openclaw#206537 and openclaw#206801; - reverting it later would change the tool prefix, and so bust deployed caches, twice; - openclaw#206801 is only on main, so no released user is affected. This version costs 0 KB. The first request is 1.4 KB smaller than on main, because the polling schemas leave the tool list. ## Evidence | Check | Tier | main `402dc418` | This PR | |---|---|---|---| | Both Tool Search modes defer the whole family; every non-empty member subset, with and without an include selector, has one visibility; 25 identical polls of `agents_wait` (name and catalog id) and `subagents list` through `dispatch_action` run with no note and no stop | vitest-source | **7 of 9 fail** | 10/10 pass | | A non-polling action (`subagents cancel`) and a non-repeatable tool repeated through `dispatch_action` still stop at call 20 | vitest-source | pass | pass | | Guard unit test: every dispatcher call form is exempt for a polling target; disagreeing selectors, unknown targets and non-polling actions are counted | vitest-source | n/a | pass | | `agent-tools.prefix-stability.test.ts`, Tool Search and runtime suites, `prompt:snapshots:check` | vitest-source / source | | green / current | Real gpt-5.4-mini runs (low thinking) on the subagent-spawn case, 5 trials per cell, against main `402dc418`: | Route | `sessions_spawn` called, main | `sessions_spawn` called, this PR | First request, main → this PR | |---|---|---|---| | Gateway | 9/10 (1 reply: "sessions_spawn isn't available") | **10/10** | 34.6 → 33.2 KB | | `--local` | 4/5 (2/5 and 2/6 in earlier runs) | **10/10** | 33.8 → 32.4 KB | What the user sees: - **Gateway, with a 60 s window for the child's completion:** the child's result reached the user in 5/5 runs on this PR and 4/5 on main. - **How the result arrives:** - With `subagents` deferred, 3 of 5 runs end the turn with `sessions_yield`, and the result arrives in the following completion message. - On main, the model waited inside the turn with the direct `subagents wait`. That pattern only exists since openclaw#206801. - Pre-openclaw#206801 behavior is the same yield pattern. - A yielded turn returns an empty CLI payload. That is an existing `sessions_yield` presentation gap, not caused by this change. - **No over-delegation:** read-file, shell-command and memory-recall, 3 trials each, both routes: 9/9 on main and on this PR, 0 spawn calls, and the same request count (15). - **`--local` caveat:** every variant's spawn then fails at runtime with "published reply runtime missing". That is a separate open gap, so only the call counts on that route. No worker protocol change. Workers compact Tool Search locally from each tool's own `true | { actions }` declaration, so the dispatcher form never crosses the wire. No change reaches the Control UI bundle either: shared `core-tool-facts.ts` is untouched. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
With Tool Search on (the default),
agents_waitandsubagentsare deferred, so the model can reach them only throughdispatch_action. The tool repeat guard reads therepeatabledeclaration of the called tool, which isdispatch_action, not its target. A model that polls its children with the sameagents_waitcall gets a "stop repeating" note at call 3. At call 20 the turn ends withtool_repeat_limit, even though these tools exist to be polled.Solution
isDirectVisibleCatalogTool(the Tool Search owner of "which trusted tools stay in the provider tool list") now keeps OpenClaw tools that declarerepeatablevisible, unless they are on-demand. The model calls them by name, and the guard reads their own declaration. They stay searchable as before.dispatch_actionand the worker wire are unchanged. A dispatcher-side fix would need either a newrepeatableshape in the worker tool protocol schema or a function that cannot cross the worker wire, so the visibility owner takes this.directToolNames, so guest scripts keep callingagents_waitas before.computer,github_publish) stay deferred.agents_wait(638 B) andsubagents(638 B) of tool schema join the tool list when those tools are enabled. That is +1,276 B, stable across turns.Evidence
55f3ed64)toolsanddirectorymodes sendagents_waitandsubagents, and keep a plain tool deferred (tool-search.repeatable.test.ts)agents_waitpolls through the real agent loop and guarddispatch_actionagents_waitcalls throughdispatch_actiontool_repeat_limitat call 20dispatch_actionstill stops at call 20 withtool_repeat_limitAccepted edge case
A model that still routes a polling tool through
dispatch_actionis counted asdispatch_actioncalls. The tool is now in its tool list, so the dispatcher is not its route.