Skip to content

docs: document the after_tool_call event payload on the tool policy page - #149377

Merged
obviyus merged 4 commits into
openclaw:mainfrom
arpanghoshal:docs-after-tool-call-payload
Oct 7, 2026
Merged

obviyus merged 4 commits into
openclaw:mainfrom
arpanghoshal:docs-after-tool-call-payload

Conversation

@arpanghoshal

@arpanghoshal arpanghoshal commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Closes #149376

What Problem This Solves

The tool policy page tells plugin authors how to gate a tool call but never documents after_tool_call, so the payload a plugin receives when that call finishes is not published anywhere in docs/plugins.

User Impact

Plugin developers writing tool policy can read the after_tool_call event fields on the same page as before_tool_call, and are told that result and error are both optional, so a handler does not infer success from an absent error. No behavior change.

Why This Change Was Made

docs/plugins/hooks/tool-policy.md lists every before_tool_call field and the full BeforeToolCallResult type. after_tool_call is the other half of that pair for any plugin that records what a gated call did, and its only published description is one row in the hook catalog:

| after_tool_call | Observe | Observe tool results, errors, and duration |

An author who pairs the two hooks has to open src/plugins/hook-types.ts to find the field names. Guessing them fails quietly: a handler that tests the wrong property records every call as successful.

The new section documents the type as declared, the observation execution contract already stated in the hook reference, and the optionality of result and error. It deliberately does not describe what result carries at runtime for exec and bash-family tools, because that is open in #102961 with needs-product-decision; it links there instead, so this page does not have to change again when that lands.

Evidence

Verified against main at 1349c4c:

  • Event type as documented: src/plugins/hook-types.ts L754-L762
  • Context type is the same one before_tool_call receives, PluginHookToolContext: src/plugins/hook-types.ts L1302-L1305
  • Execution contract quoted from the hook reference (Observe: handlers run concurrently, return values ignored; on error, log and continue)
  • Coverage gap: after_tool_call occurs in docs/plugins/** only in hooks/reference.md (2 table rows), codex-harness-runtime/hooks.md, codex-harness-runtime/v1-support-contract.md and copilot.md, and in none of them as an event-field list. It does not occur in hooks/tool-policy.md at all.

Docs-only change: one new ### Tool call observation section and one added read_when line. No code, no config, no tests affected.

Maintainer verification: No overlap with Pash/Sarah changes.
Verified all event fields against current main src/plugins/hook-types.ts:585-593 and emitters src/agents/embedded-agent-subscribe.handlers.tools.completion.ts:640-658 and src/agents/harness/hook-helpers.ts:26-57. Clarified context type versus available fields and optional-error wording. Scoped Oxfmt and MDX checks passed; standard link audit checked 13,788 links with zero broken. Optional whole-tree anchor audit found 54 pre-existing broken anchors outside this page. Stale-base merge-tree is clean; main changes in the page concern unrelated policy examples. git diff --check passed.

The tool policy page documents every before_tool_call event field and the full
BeforeToolCallResult type, but never mentions after_tool_call, so its payload is
not published anywhere in docs/plugins. The hook catalog in the hook reference
carries one descriptive row and no fields.

Adds a Tool call observation section with the event shape declared in
src/plugins/hook-types.ts, the observation execution contract, and a note that
result and error are both optional, so an event carrying neither is not evidence
of success.

Documents the declared type rather than the observed payload: what result
carries for exec and bash-family tools is open in openclaw#102961 and is left to that
issue.

Closes openclaw#149376
@clawsweeper

clawsweeper Bot commented Sep 15, 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 size: XS labels Sep 15, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 10:09 PM ET / October 7, 2026, 02:09 UTC (Revision 4).

ClawSweeper review

What this changes

Documents the after_tool_call observation hook’s event fields, optional outcomes, context availability, and execution rules on the tool policy page.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still lacks the payload documentation, and the added wording accurately describes the existing contract without deciding the separate runtime-payload question. No blocking defect was found.

Priority: P3
Reviewed head: edda5671635f86f2d89393cf9d3be0a9c36520e4

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-consistent documentation patch with no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: Real behavior proof is not required because this PR only changes files under docs/.
Patch quality 🐚 platinum hermit (4/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 8 items Verified introduced documentation: The pinned introduction delta adds the observation section and discovery hint only; its event shape matches the declared hook type.
Current-main payload contract: Current main declares toolName and params, with optional runId, toolCallId, result, error, and durationMs, exactly as documented.
Emitter semantics: The harness helper consumes adjusted arguments, conditionally includes outcome fields and timing, supplies available context, and catches observation failures. This supports the documentation’s qualified context and optional-outcome wording.
Findings None None.
Security None None.

How this fits together

OpenClaw’s plugin hooks let plugins gate tool execution and observe completed calls. Harnesses supply completion events to the hook runner, which dispatches them to registered plugin handlers.

flowchart LR
  A[Tool arguments] --> B[Before-call policy]
  B --> C[Tool execution]
  C --> D[Harness completion event]
  D --> E[Observation hook runner]
  E --> F[Plugin outcome records]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Docs +46. Total +46 across 1 file.

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

Review metrics

None.

Technical review

Best possible solution:

Keep the observation contract beside tool policy guidance while leaving runtime result-format changes to the separately tracked work.

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

Not applicable to a runtime defect; direct inspection confirms that current main’s tool policy page lacks this payload section.

Is this the best way to solve the issue?

Yes. Documenting the existing type and observation rules on the existing policy page is a focused solution that avoids promising a particular harness result format.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 07e9a2519420.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is a focused documentation improvement with no runtime or configuration change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • 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:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (3 earlier review cycles)
  • reviewed 2026-09-15T19:50:41.120Z sha 3c7abc4 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T20:15:25.254Z sha 979edce :: needs maintainer review before merge. :: none
  • reviewed 2026-10-06T00:23:58.753Z sha 979edce :: needs maintainer review before merge. :: none

@obviyus

obviyus commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus
obviyus merged commit 2ba33cb into openclaw:main Oct 7, 2026
69 checks passed
@obviyus

obviyus commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Landed in 2ba33cb. Thanks @arpanghoshal! We verified every field against hook-types.ts and the emitters, and tightened a few semantics (context type vs. available fields, when a missing error can mislead).

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: 🐚 platinum hermit Good normal PR readiness with ordinary 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.

[Docs Bug]: after_tool_call event payload is not documented on the tool policy page

2 participants