Skip to content

fix: explain how to call deferred tools after a direct call - #201488

Merged
roboclaw-bot merged 2 commits into
mainfrom
openclaw/tool-search-recovery-186716
Nov 21, 2026
Merged

roboclaw-bot merged 2 commits into
mainfrom
openclaw/tool-search-recovery-186716

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #186716

What Problem This Solves

A model that calls a deferred tool directly in structured Tool Search mode gets only “Tool not found,” even though the tool is available through discovery. That gives it no actionable way to recover in the same turn.

User Impact

The embedded harness now tells the model to call dispatch_action with the tool name in id and its parameters in args. The rejected direct call does not execute or expose the tool. Unknown, filtered, ambiguous, and exact-ID-only names keep their existing behavior. No configuration, defaults, permissions, executor, or native-harness behavior changes.

Why This Change Was Made

The existing deferred-tool resolver was installed only for Code Mode and directory mode. It now also handles recovery when the structured dispatcher is actually registered, using the same current catalog lookup and returning guidance before tool adaptation.

The resolver moves intact into one named execution-boundary module so the capped preparation source and test suite do not grow past their limits. Code Mode guidance and directory hydration retain their existing owner and hooks; there is no second execution path or new state. Simplification pass: production +39 net lines (mostly the extracted boundary’s typed input), regression +85 lines, documentation +3 lines.

Evidence

  • Before the fix, the production-wired agent-loop regression received Tool probe_write not found instead of dispatcher guidance. The final focused regression verifies the guidance, no direct execution or provider exposure, unchanged filtered/unknown rejection, and exactly one real file write through dispatch_action.
  • Final resolver and preparation suites: 27 tests passed. The new suite took 11.60 seconds including imports/transforms; the two-shard command took 51.79 seconds including cold worker preparation.
  • Tool Search selection and prompt-prefix stability suites: 37 tests passed.
  • Full pnpm build passed again at published head db16310f5ddf9086622cca30a0a63e5e56357c30 (1m 47.9s; clean build inputs). Core production and agents-other test typecheck leaves passed.
  • Targeted lint, formatting, and git diff --check passed.
  • Independent autoreview of the complete local candidate against c5ef395ba7204c83240074b584e97f550a3aab7d, with the catalog, agent loop, and client-tool assembly supplied as context: GPT-6.1 Sol, P0–P2, scoped-clean; no actionable findings. The reviewer did not run tests. Hosted ClawSweeper also reported no actionable patch findings at the published head.
  • The exact-head CI gate passed.

Real isolated Gateway recovery proof

Passed at the published head through the repository's compiled Gateway test lane, using createOpenClawTestInstance, its standard authenticated synthetic test client, and a local scripted model provider. This exercises the actual Gateway and embedded agent; it is not a live third-party-model test.

The provider first emitted a direct sessions_list call. It received the recovery error, followed that guidance with dispatch_action, and received the real session-list result. The target remained absent from all three provider tool declarations, and the turn completed without rerouting:

head: db16310f5ddf9086622cca30a0a63e5e56357c30
provider requests: 3
sessions_list declared directly: [false, false, false]
dispatch_action declared: [true, true, true]
direct result: Tool sessions_list is deferred and not directly callable. Call dispatch_action with id "sessions_list" and its parameters in args.
dispatch result: count=1
terminal status: ok
terminal reply: PROOF_DONE
rerouted: false

The Gateway proof took 7.064 seconds; its test lane completed in 14.56 seconds including preparation. Earlier source-only startup and operator-CLI attempts hit worker-ownership and attribution guards. The standard compiled synthetic test fixture supplied the successful proof without disabling either safeguard. The previous end-to-end verification gap is resolved; no source push or CI rerun was needed.

Thanks to @xyrolle for the report and proposed recovery approach in #186718, and @vincentkoc for requesting the repair.

Work sessions

Linked for team reference; these sessions aren’t public.

Worked on by

roboclaw-bot and others added 2 commits November 18, 2026 22:21
Return dispatcher recovery guidance without executing or exposing deferred tools in structured Tool Search mode. Keep directory hydration and Code Mode behavior unchanged at the extracted execution boundary.

Co-authored-by: vincentkoc <[email protected]>
Worked on by:
- @vincentkoc

Co-authored-by: vincentkoc <[email protected]>
OpenClaw-Publication: 47f1dc88-d37c-473f-9bf1-55e3840c6ed0
@clawsweeper

clawsweeper Bot commented Nov 18, 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: M labels Nov 18, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review November 18, 2026 22:23
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 18, 2026
@clawsweeper

clawsweeper Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR directs models that call deferred tools directly to retry through dispatch_action.

Example: In structured Tool Search mode, a model calls sessions_list({}) directly.

  • Before: The model receives “Tool sessions_list not found.”
  • After: The model receives guidance to call dispatch_action with id "sessions_list" and its parameters in args.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused repair appears correct and has meaningful integration coverage, but required product proof remains 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 receives a missing-tool error for an available deferred capability without instructions for recovering.
Reason: The maintainer-authored repair restores actionable guidance for documented behavior without adding configuration, changing permissions, or creating another execution path.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it repairs a current diagnostic gap through the existing resolver, preserves execution ownership, and introduces no concrete correctness defect.

Priority: P2
Reviewed head: db16310f5ddf9086622cca30a0a63e5e56357c30

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supply redacted CLI or Gateway output from this implementation showing a deferred direct call receiving guidance and a subsequent dispatch_action succeeding without direct execution or exposure.
Agent review details

How this fits together

The embedded agent runner resolves structured model tool calls against registered tools and the current deferred catalog, returning recovery errors while dispatch_action retains deferred execution.

flowchart TD
  A[Model tool call] --> B[Agent loop]
  B --> C[Registered tool lookup]
  C --> D[Deferred resolver]
  D --> E[Current catalog lookup]
  E --> F[Recovery guidance]
  F --> A
  A --> G[dispatch_action]
  G --> H[Existing tool execution]
Loading

Technical review

Best possible solution:

Retain the focused resolver repair and existing dispatcher execution path, crediting the earlier contribution.

Do we have a high-confidence way to reproduce the issue?

Current-main resolver wiring and the agent-loop fallback establish the failure path; the linked issue supplies deterministic CLI and Gateway reproductions, inspected without execution.

Is this the best way to solve the issue?

The existing deferred-resolution hook is the appropriate owner: the added branch explains the documented dispatcher route without executing the target, and the extracted module preserves the existing recovery and hydration boundary.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6615c148e4b7.

Provenance checked

  • Directory-mode deferred hydration keeps the original intent (965fa05: Expose a compact directory while hydrating exact authorized names through normal policy and hook execution.)
  • Code Mode direct-call recovery keeps the original intent (90ecba1: Explain recovery through Code Mode without executing or exposing a hidden tool.)
  • Captured permission signal during hydration keeps the original intent (67433ff: Apply workspace permission changes to active runs and prevent approvals from surviving their captured permission lifecycle.)
  • Deferred invocation documentation keeps the original intent (b3dcb2d: Preserve capabilities while explaining invocation through the selected Tool Search surface.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +39, Tests +85, Docs +3. Total +127 across 4 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 85 46 +39
Tests 1 85 0 +85
Docs 1 4 1 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 174 47 +127

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.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #186716
Summary: This PR and the earlier contributor PR address the same structured Tool Search deferred-call diagnostic gap.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Misleading errors can prevent an agent from using an available capability, while the existing dispatcher remains functional.
  • 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.

  • Attach sanitized terminal output or logs showing the changed recovery path succeeding through the CLI or Gateway.

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 18, 2026, 5:40 PM ET / 22:40 UTC.

@roboclaw-bot
roboclaw-bot merged commit 76b4b18 into main Nov 21, 2026
220 checks passed
@roboclaw-bot
roboclaw-bot deleted the openclaw/tool-search-recovery-186716 branch November 21, 2026 01:54
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 P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M 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.

[Bug]: Tool Search tools mode answers a direct call to a deferred tool with a bare "Tool <name> not found"

1 participant