Skip to content

docs(plugins): note the factory tool execute signature - #120097

Merged
steipete merged 2 commits into
openclaw:mainfrom
ayaangazali:docs/tool-plugin-factory-execute-signature
Aug 23, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
ayaangazali:docs/tool-plugin-factory-execute-signature

Conversation

@ayaangazali

Copy link
Copy Markdown
Contributor

What Problem This Solves

docs/plugins/tool-plugins.md shows a declarative tool whose handler is execute({ symbol }, config, context), with params first. About thirty lines later, on the same page, it introduces factory tools without saying that a factory's tool uses the opposite argument order.

A plugin author who reads the page top to bottom, then writes a factory tool, gets the tool call ID where they expect their params. That is what #120061 reports: args[0] is "toolu_01FJWJ..." and args[1] is { path: "." }.

The runtime is behaving correctly here, and so is every other page. docs/plugins/building-plugins.md:144 and :260 both show the api.registerTool form as async execute(_id, params), which is right. The gap is only that the tool-plugins page never connects its own factory section to that contract, and it is the page a tool author is most likely to be reading.

Why This Change Was Made

The two argument orders are both real and both intentional, so this documents the seam rather than changing it.

  • Declarative tools go through an adapter. src/plugin-sdk/tool-plugin.ts:230 registers execute: async (toolCallId, params, signal, onUpdate) => ... execute(params, config, { api, signal, toolCallId, onUpdate }), which is what turns the runtime signature into the documented execute(params, config, context) at src/plugin-sdk/tool-plugin.ts:98.
  • Factory tools do not. src/plugin-sdk/tool-plugin.ts:207 passes the factory straight to api.registerTool and continues, so whatever the factory returns keeps the core contract at packages/agent-core/src/types.ts:560: execute(toolCallId, params, signal?, onUpdate?).

So the note says exactly that, points at the api.registerTool examples that already show the same shape, and states the failure mode in the words an author will recognize.

I did not touch the signatures. Changing the core AgentTool argument order would reach every tool in the repo, and the shim suggested in #120061 (passing params at both arg0 and arg1) would add a permanent compatibility branch to a public SDK surface to paper over a docs gap. Documenting the seam is the smaller and more honest fix.

User Impact

Plugin authors reading the tool-plugins walkthrough now learn the factory argument order on the page where they need it, instead of discovering it by logging args.

Docs only. No code, config, schema, or default surface changes.

Evidence

Claims verified against current main at c245cfc19c7 rather than from memory:

  • src/plugin-sdk/tool-plugin.ts:98 declares the declarative handler as (params, config, context).
  • src/plugin-sdk/tool-plugin.ts:207 registers a factory with no execute adapter.
  • src/plugin-sdk/tool-plugin.ts:230 is the adapter the declarative branch uses.
  • packages/agent-core/src/types.ts:560 is the core execute(toolCallId, params, signal?, onUpdate?) contract.
  • docs/plugins/building-plugins.md:144 and :260 already show async execute(_id, params), so the new text agrees with the rest of the docs.

openclaw/plugin-sdk/tool-plugin is a published subpath (package.json exports plus scripts/lib/plugin-sdk-entrypoints.json:313), so this is a public SDK surface and not an internal detail.

git diff --check is clean, the added link /plugins/building-plugins is root-relative with no extension per the docs guide, and the file has no em dashes.

One thing I did not do: I did not build a plugin and observe the argument order at runtime. The claim rests on reading the registration path end to end in the four places cited above. If a maintainer wants a live plugin trace before merging, say so and I will put one together.

AI-assisted: written with AI assistance. I read the registration path, the core tool type, and the existing docs pages myself before writing the note.

Refs #120061. I am deliberately not closing that issue with this PR: it asks for the factory argument order to change, and whether to alter a public SDK contract is a maintainer product decision. This only removes the documentation gap that made the current behavior surprising.

@ayaangazali
ayaangazali marked this pull request as ready for review August 7, 2026 00:55
Copilot AI lite review requested due to automatic review settings August 7, 2026 00:55
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Aug 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 1:49 PM ET / 17:49 UTC.

ClawSweeper review

What this changes

The PR adds a plugin-author note that factory-returned tools receive the tool-call ID before their parameter object.

Merge readiness

✅ Ready for maintainer review

No blocking findings. The documentation accurately distinguishes factory-returned core tools from declarative tool-plugin handlers, and current main still lacks this clarification.

Priority: P3
Reviewed head: 81a57949f210ca7028c3f1216a3ff26e9a38d019

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, accurate documentation patch with source-backed wording and no remaining correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: Real behavior proof is not required because this PR only changes files under docs/.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real behavior proof is not required because this PR only changes files under docs/.
Evidence reviewed 6 items Factory contract: The factory type returns one or more AnyAgentTool values or an intentional nullish opt-out; its registration path passes the factory result directly to the plugin API.
Runtime invocation: The plugin tool resolver calls a matched factory-returned tool as execute(toolCallId, executeParams, signal, onUpdate).
Core signature: AgentTool defines execute with toolCallId first, followed by params and optional signal and update callback.
Findings None None.
Security None None.

How this fits together

Tool plugins let plugin authors declare either a declarative handler or a runtime factory. Declarative handlers pass through an SDK adapter, while factory-returned agent tools flow directly into the agent runtime and receive its native execute arguments.

flowchart LR
A[Plugin author] --> B[Tool plugin declaration]
B --> C{Tool form}
C -->|Declarative| D[SDK execution adapter]
C -->|Factory| E[Core agent tool]
D --> F[Parameters-first handler]
E --> G[Tool-call-ID-first handler]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Docs +10. Total +10 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 1 10 0 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 10 0 +10

Review metrics

None.

Technical review

Best possible solution:

Keep the clarification narrow and land it as documentation for the existing public factory-tool contract.

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

Not applicable: this PR documents an existing SDK contract, which current source directly confirms.

Is this the best way to solve the issue?

Yes. Documenting the intentional adapter boundary is the narrowest maintainable solution; changing the core execute signature would alter a broader public SDK contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against bca206d794bd.

Labels

Label justifications:

  • P3: This is a low-risk documentation clarification for plugin authors and changes no runtime behavior or public contract.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Real behavior proof is not required because this PR only changes files under docs/.

Evidence

What I checked:

Likely related people:

  • Jesse Merhi: Available blame associates the current factory and declarative handler contract with this source boundary; shallow history limits stronger ownership attribution. (role: current source-line provenance; confidence: low; commits: 13f0e02de62d; files: src/plugin-sdk/tool-plugin.ts, docs/plugins/tool-plugins.md, docs/plugins/building-plugins.md)
  • obviyus: Merged work on factory tool delivery supplied the immediately preceding factory documentation context referenced by this PR. (role: adjacent feature contributor; confidence: medium; commits: 43c54af3ea90; files: docs/plugins/tool-plugins.md)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (9 earlier review cycles; latest 8 shown)
  • reviewed August 6, 2026, 11:37 PM ET / August 7, 2026, 03:37 UTC sha unknown :: needs changes before merge. :: [P2] State the factory result and execute signature precisely
  • reviewed 2026-08-07T16:50:05.587Z sha bee88751a107b60fc136127c94df5361a0843788 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-16T19:56:33.665Z sha 2fbd35e479daef05f78cec78e64946037e71c41b :: needs maintainer review before merge. :: none
  • reviewed 2026-08-18T03:55:54.744Z sha 7b83b02e9fe3046ed580450e241cad6f6494d7c0 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-18T17:31:09.532Z sha 93e2c6ab2684ea8690350c0cf38f02b5e54ea15e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-21T01:33:23.927Z sha c8f7213077634ad2508c7246d01651c708cd143c :: needs changes before merge. :: [P2] Remove the unrelated config-baseline refresh
  • reviewed 2026-08-21T19:25:31.293Z sha 155cd96a42bd1e44d5f5d5c1558870788b813821 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-22T17:17:00.936Z sha 5546661583a42ee2b7c0cbde7506956e12333d6f :: needs maintainer review before merge. :: none

@ayaangazali
ayaangazali force-pushed the docs/tool-plugin-factory-execute-signature branch from e34c723 to bee8875 Compare August 7, 2026 16:43
@ayaangazali

Copy link
Copy Markdown
Contributor Author

Fixed in bee88751a10. The P2 was right on both counts.

DefinedToolPluginTool.factory is typed (context) => AnyAgentTool | AnyAgentTool[] | null | undefined (src/plugin-sdk/tool-plugin.ts:99-101), and the example directly above the sentence returns null, so promising a singular returned tool contradicted the code and the surrounding page. The core contract also has signal? and onUpdate? optional (packages/agent-core/src/types.ts:560) and I had written them as if required.

It now reads:

A factory may return a core AgentTool, an array of them, or null or undefined to opt out, as the example above does. When it returns a concrete tool, that tool uses the core runtime signature execute(toolCallId, params, signal?, onUpdate?) with the tool call ID first.

Same rebase also picked up current main.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 7, 2026
@ayaangazali
ayaangazali force-pushed the docs/tool-plugin-factory-execute-signature branch from bee8875 to 2fbd35e Compare August 16, 2026 19:51
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 16, 2026
@ayaangazali
ayaangazali force-pushed the docs/tool-plugin-factory-execute-signature branch from 2fbd35e to 7b83b02 Compare August 18, 2026 03:49
@ayaangazali

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (72243fbef08). This branch was 450 commits behind, so its last green run was against a merge base that had drifted a long way. It is now 0 behind and merge-clean.

Before rebasing I checked the change was still worth carrying rather than just replaying cleanly: every file it touches still exists on main, and the behavior it fixes is still present there.

Docs only, one file (docs/plugins/tool-plugins.md).

Still useful from my side, so I have not closed it. Happy to close instead if you would rather not take it.

AI-assisted.

@ayaangazali
ayaangazali force-pushed the docs/tool-plugin-factory-execute-signature branch from 7b83b02 to 93e2c6a Compare August 18, 2026 17:24
@ayaangazali

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (d8c1d90edb4) and removed something that should not have been in this PR.

This branch was carrying a docs/.generated/config-baseline.sha256 diff even though it changes one docs page and no config schema. That came from a blanket regenerate step in my own earlier rebases, not from anything this branch does. Five of my PRs had picked up the byte-identical hash change, which is what gave it away. The generated artifacts now match main exactly, so the diff here is only the files this fix is actually about.

It also removes a recurring nuisance: that generated file is rewritten on main most days, so carrying an unnecessary copy of it made this PR conflict daily for no reason.

Verified at head 93e2c6ab268, 0 behind and merge-clean.

Sorry for the noise in the earlier diff.

AI-assisted.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 18, 2026
@ayaangazali
ayaangazali force-pushed the docs/tool-plugin-factory-execute-signature branch from 93e2c6a to c8f7213 Compare August 21, 2026 01:27
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 21, 2026
@clawsweeper clawsweeper Bot added the status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. label Aug 21, 2026
@ayaangazali

Copy link
Copy Markdown
Contributor Author

Rebased onto current main, 0 behind and merge-clean.

The conflict was a real one this time, not the usual generated-baseline churn: main added a paragraph in the same spot via #127098, documenting toolContext.delivery?.send(...) for factories. Resolved as the union, so that paragraph is kept intact and the signature note follows it. Both commits on this branch touched that block, so I also kept the later, more precise wording rather than the first draft.

I re-verified the claim still holds on current main before keeping the PR, since #126262 changed how code-mode calls tools:

  • packages/agent-core/src/types.ts:570 still declares toolCallId: string as the first parameter of the core tool execute.
  • src/plugins/tools.ts:896 still invokes it as matchedTool.execute(toolCallId, executeParams, signal, onUpdate).
  • docs/plugins/tool-plugins.md still shows only the declarative execute({ symbol }, config, context) form, so the factory ordering remains undocumented.

So the gap this PR fills is unchanged. Docs-only, one file, git diff --check clean.

AI-assisted.

@ayaangazali
ayaangazali force-pushed the docs/tool-plugin-factory-execute-signature branch from c8f7213 to 155cd96 Compare August 21, 2026 19:17
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 21, 2026
@ayaangazali
ayaangazali force-pushed the docs/tool-plugin-factory-execute-signature branch from 155cd96 to 5546661 Compare August 22, 2026 17:05
@ayaangazali
ayaangazali force-pushed the docs/tool-plugin-factory-execute-signature branch from 5546661 to 81a5794 Compare August 23, 2026 17:42
@steipete
steipete merged commit 9cd09fd into openclaw:main Aug 23, 2026
52 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 24, 2026
* docs(plugins): note the factory tool execute signature

* docs(plugins): state the factory tool result and execute signature precisely
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS 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.

3 participants