Skip to content

fix(agents): keep polling tools visible so the repeat guard reads their own exemption - #206801

Merged
obviyus merged 1 commit into
mainfrom
core/repeatable-on-demand
Nov 27, 2026
Merged

obviyus merged 1 commit into
mainfrom
core/repeatable-on-demand

Conversation

@obviyus

@obviyus obviyus commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

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 (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

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.

…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.
@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S labels Nov 27, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

The 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.

  • Before: Calls routed through dispatch_action receive a warning on call 3 and stop the turn on call 20.
  • After: Direct agents_wait calls retain their repeat exemption and can continue through all 25 polls.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is focused and source-supported, but the required shipped-entry-point proof is absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An agent waiting repeatedly for child work can receive an inappropriate repetition warning and have its turn terminated.
Reason: The patch restores the established polling exemption with one condition in the existing owner, and its maintainer author explicitly accepts the schema cost and dispatcher edge case.

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: 3816287bf7bc77093a104bf5d284c462badd6c91

Before merge

None.

Findings

None.

Agent review details

How this fits together

Tool 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
Loading

Technical review

Best 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

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit ab8fd94 adds src/agents/tool-search-catalog.ts:262 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ab8fd9466418; files: src/agents/tool-search-catalog.ts)
  • Peter Steinberger: Raw commit f405852 adds src/agents/tool-search-catalog.ts:295 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f4058528e5db; files: src/agents/tool-search-catalog.ts)

PR surface

Source +3, Tests +102, Docs +3. Total +108 across 3 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 7 4 +3
Tests 1 102 0 +102
Docs 1 6 3 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 115 7 +108

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Capture the polling scenario identified in testingReview through the shipped product, redacting IPs, API keys, phone numbers, and non-public endpoints.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 27, 2026, 11:19 AM ET / 16:19 UTC.

@obviyus
obviyus merged commit afd8195 into main Nov 27, 2026
203 of 205 checks passed
@obviyus
obviyus deleted the core/repeatable-on-demand branch November 27, 2026 17:41
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
…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]>
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
…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]>
obviyus added a commit that referenced this pull request Nov 28, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 29, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant