Skip to content

feat(plugins): report tool names, skills used and model iterations on agent_end - #190108

Merged
obviyus merged 2 commits into
mainfrom
feat/agent-end-follow-up
Nov 1, 2026
Merged

obviyus merged 2 commits into
mainfrom
feat/agent-end-follow-up

Conversation

@obviyus

@obviyus obviyus commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Skill Workshop is moving from core into the bundled skill-workshop plugin. Its post-turn review needs three facts about the finished run that the public agent_end hook does not carry:

  • which OpenClaw tools the model could call (today a Workshop-only skillWorkshopAvailable flag on the internal side-effects context),
  • which skills the run used (today a core-private per-run receipt),
  • how many model calls the run made (today ctx.modelIterations, set by Codex only).

Fix

  • agent_end event: new optional skillsUsed (name, source, activation) and modelIterations.
  • agent_end context: new optional toolNames: the OpenClaw tools the model could call this turn, after policy.
  • One preparation step: runAgentEndSideEffectsAsync / awaitAgentEndSideEffects consume the run's skill-usage receipt once and give the same event to core and plugin hooks. The hook message loader stays bound to the prepared event.
  • Producers: the embedded runner reports toolNames from the prompt-policy callable surface (after any before_prompt_build toolsAllow, keeping tool-search-deferred tools); Codex reports its dynamic tool names and modelIterations only when it observed responses. agentsapi drops its hard-coded skillWorkshopAvailable: false.
  • An unknown modelIterations is left off the event, never reported as 0.
  • Workshop scheduler reads ctx.toolNames, event.modelIterations and event.skillsUsed; skillWorkshopAvailable is gone from core and bundled callers.
  • Shipped SDK compatibility: ctx.skillWorkshopAvailable and ctx.modelIterations on the agent-end side-effects helpers stay as deprecated aliases (warning, supported through 2026-12-31) that map onto toolNames and event.modelIterations.
  • Privacy: Incognito sessions withhold skillsUsed and modelIterations along with messages.
  • hook-types.ts was at its line cap, so the terminal agent-run payloads moved to hook-agent-finalize.types.ts (re-exported unchanged).
  • Docs: hook reference, Incognito note, harness side-effects page.

No new SDK entry points or named exports. No schema, protocol or stored-data change.

Impact

  • Plugins can see what a finished run did without core-private state. Second consumers: skill-usage analytics, cost or turn-budget plugins, memory plugins checking their tools were exposed.
  • Workshop reviews keep their current behavior on embedded and Codex runs.

Evidence

Check Result
New: plugin hooks get skillsUsed, modelIterations and toolNames; the message loader stays bound; core and plugins see the same event (agent-end-side-effects.test.ts) pass; fails when the loader transfer is removed
New: retired ctx.modelIterations / ctx.skillWorkshopAvailable map onto event.modelIterations / ctx.toolNames and leave the context pass
Incognito agent_end withholds skillsUsed and modelIterations (wired-hooks-llm.test.ts) pass
Workshop scheduler, review admission, embedded attempt lifecycle, Codex agent-end context, CLI skill usage pass (6 files, 66 tests)
All 14 *.workshop-contract suites, unchanged pass (104 tests)
Embedded: a prompt hook narrowing the bundle to read reports toolNames: ["read"] (attempt-phase-lifecycle.test.ts) pass; fails on the bundle-based version
Codex: a turn without per-response notifications leaves modelIterations unknown pass; fails with the old ?? 0
pnpm check:changed (typecheck, lint, boundaries, line-cap ratchet) pass
plugin-sdk:api:diff vs origin/main additive optional fields only; no new or removed exports
git diff --check pass

@clawsweeper

clawsweeper Bot commented Nov 1, 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 extensions: codex extensions: agentsapi size: M labels Nov 1, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 1, 2026
@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR adds available tool names, used skills, and known model-call counts to agent_end hooks.

Example: A Codex turn reads the workspace skill deploy and makes 3 model calls with read and skill_workshop available.

  • Before: Plugins receive no structured skill usage, tool availability, or model-call count.
  • After: Plugins receive skillsUsed containing deploy, modelIterations: 3, and toolNames containing read and skill_workshop.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A useful, focused patch with both prior defects repaired and passing exact-head CI; behavioral evidence remains harness-based.
Proof confidence 🦐 gold shrimp (3/6) This collaborator-authored PR is outside the ordinary contributor proof gate; inspected harness tests cover producer facts, SDK aliases, loader transfer, and Incognito projection.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Plugin developers cannot implement post-turn learning or analytics using the structured run facts currently available only to core.
Reason: The maintainer-authored proposal supplies a demonstrated missing hook contract, adopts it in the existing consumer, and avoids the broader extraction's policy and storage changes.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR provides a useful plugin contract, resolves both prior findings, and has passing checks on the reviewed head; no actionable defect remains.

Priority: P2
Reviewed head: 17193182b11290347e9a0c730c1f986afad3c928

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped Gateway or CLI demonstration shows a plugin receiving the new facts after a real turn; supplied evidence consists of focused tests and CI.
Agent review details

How this fits together

Agent finalizers pass completed-run facts through the shared harness side-effects owner to Skill Workshop scheduling and plugin observation hooks.

flowchart TD
  A[Embedded runner] --> C[Agent end preparation]
  B[Codex runtime] --> C
  D[Run skill receipts] --> C
  C --> E[Workshop scheduler]
  C --> F[Plugin hook dispatch]
  F --> G[Incognito projection]
Loading

Technical review

Best possible solution:

Use the existing agent-end preparation owner to publish optional run facts while preserving SDK aliases, Workshop behavior, and Incognito filtering.

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

This is a capability addition; current-main source confirms the facts remain private, and review inspected source and supplied tests without running target code.

Is this the best way to solve the issue?

The change extends existing hook and receipt owners, migrates bundled callers together, and preserves shipped input compatibility without adding a parallel subsystem.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4475bed8cf50.

Provenance checked

  • Workshop review inputs and iteration fallback keeps the original intent (cfee851: The versioned learning loop uses completed-turn facts and falls back to assistant-message counting when Codex reports no response count.)
  • Agent-end anchor preparation and hook ordering keeps the original intent (f9dfa9a: Prepare transcript anchors through the history reader while retaining current writer authority and keeping interactive plugin hooks nonblocking.)
  • Terminal hook type extraction keeps the original intent (f3accc7: Expose a typed final-answer review boundary distinct from user cancellation; this PR moves those existing types without changing their contract.)
  • Incognito terminal observations keeps the original intent (bab3136: Withhold private conversation evidence while preserving terminal cleanup observations.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +69, Tests +107, Docs +18. Total +194 across 18 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 9 140 71 +69
Tests 6 124 17 +107
Docs 3 19 1 +18
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 18 283 89 +194

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a useful plugin capability expansion with limited immediate user impact.
  • merge-risk: 🚨 compatibility: The public hook payload and SDK input guidance change; the maintainer-authored direction retains optional fields and compatible legacy input mappings.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp 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.

  • Record a redacted Gateway or CLI turn showing an observing plugin receiving the new run facts.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-01T06:21:06.841Z sha f8bcd13 :: needs changes before merge. :: [P2] Report the embedded runner's post-policy callable tools | [P2] Preserve unknown Codex iteration counts as absent

Reviewed November 1, 2026, 2:30 AM ET / 07:30 UTC (Revision 2).

@obviyus

obviyus commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 1, 2026
@obviyus
obviyus merged commit 1621a2d into main Nov 1, 2026
139 checks passed
@obviyus
obviyus deleted the feat/agent-end-follow-up branch November 1, 2026 07:32
@obviyus

obviyus commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in 1621a2d.

  • Problem: plugins could not see what a finished run did (tools it could call, skills it used, model calls) without core-private state.
  • Fix: agent_end now carries ctx.toolNames (post-policy), event.skillsUsed and event.modelIterations (only when known). The Workshop-only skillWorkshopAvailable flag is gone; the old SDK fields remain as deprecated aliases through 2026-12-31.
  • Proof: new side-effects, lifecycle and Codex regression tests (each fails on the old code), Incognito withholding, and all 14 Workshop contract suites unchanged.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 2, 2026
… agent_end (openclaw#190108)

## Problem

Skill Workshop is moving from core into the bundled `skill-workshop` plugin. Its post-turn review needs three facts about the finished run that the public `agent_end` hook does not carry:

- which OpenClaw tools the model could call (today a Workshop-only `skillWorkshopAvailable` flag on the internal side-effects context),
- which skills the run used (today a core-private per-run receipt),
- how many model calls the run made (today `ctx.modelIterations`, set by Codex only).

## Fix

- **`agent_end` event:** new optional `skillsUsed` (`name`, `source`, `activation`) and `modelIterations`.
- **`agent_end` context:** new optional `toolNames`: the OpenClaw tools the model could call this turn, after policy.
- **One preparation step:** `runAgentEndSideEffectsAsync` / `awaitAgentEndSideEffects` consume the run's skill-usage receipt once and give the same event to core and plugin hooks. The hook message loader stays bound to the prepared event.
- **Producers:** the embedded runner reports `toolNames` from the prompt-policy callable surface (after any `before_prompt_build` `toolsAllow`, keeping tool-search-deferred tools); Codex reports its dynamic tool names and `modelIterations` only when it observed responses. agentsapi drops its hard-coded `skillWorkshopAvailable: false`.
- An unknown `modelIterations` is left off the event, never reported as `0`.
- **Workshop scheduler** reads `ctx.toolNames`, `event.modelIterations` and `event.skillsUsed`; `skillWorkshopAvailable` is gone from core and bundled callers.
- **Shipped SDK compatibility:** `ctx.skillWorkshopAvailable` and `ctx.modelIterations` on the agent-end side-effects helpers stay as deprecated aliases (warning, supported through 2026-12-31) that map onto `toolNames` and `event.modelIterations`.
- **Privacy:** Incognito sessions withhold `skillsUsed` and `modelIterations` along with messages.
- `hook-types.ts` was at its line cap, so the terminal agent-run payloads moved to `hook-agent-finalize.types.ts` (re-exported unchanged).
- Docs: hook reference, Incognito note, harness side-effects page.

No new SDK entry points or named exports. No schema, protocol or stored-data change.

## Impact

- Plugins can see what a finished run did without core-private state. Second consumers: skill-usage analytics, cost or turn-budget plugins, memory plugins checking their tools were exposed.
- Workshop reviews keep their current behavior on embedded and Codex runs.

## Evidence

| Check | Result |
| --- | --- |
| New: plugin hooks get `skillsUsed`, `modelIterations` and `toolNames`; the message loader stays bound; core and plugins see the same event (`agent-end-side-effects.test.ts`) | pass; fails when the loader transfer is removed |
| New: retired `ctx.modelIterations` / `ctx.skillWorkshopAvailable` map onto `event.modelIterations` / `ctx.toolNames` and leave the context | pass |
| Incognito `agent_end` withholds `skillsUsed` and `modelIterations` (`wired-hooks-llm.test.ts`) | pass |
| Workshop scheduler, review admission, embedded attempt lifecycle, Codex agent-end context, CLI skill usage | pass (6 files, 66 tests) |
| All 14 `*.workshop-contract` suites, unchanged | pass (104 tests) |
| Embedded: a prompt hook narrowing the bundle to `read` reports `toolNames: ["read"]` (`attempt-phase-lifecycle.test.ts`) | pass; fails on the bundle-based version |
| Codex: a turn without per-response notifications leaves `modelIterations` unknown | pass; fails with the old `?? 0` |
| `pnpm check:changed` (typecheck, lint, boundaries, line-cap ratchet) | pass |
| `plugin-sdk:api:diff` vs `origin/main` | additive optional fields only; no new or removed exports |
| `git diff --check` | pass |

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 extensions: agentsapi extensions: codex merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

1 participant