feat(hooks): add agent turn end hook#89152
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 3, 2026, 9:03 AM ET / 13:03 UTC. Summary Reproducibility: not applicable. this is a feature/API PR, not a bug report. Source inspection shows current main lacks the hook, while the PR body demonstrates the proposed behavior only on an older head. Review metrics: 2 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land only after maintainers sponsor the hook contract, the branch is clean, and current-head real ACPX/Codex proof verifies the lifecycle-only, non-durable semantics. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a feature/API PR, not a bug report. Source inspection shows current main lacks the hook, while the PR body demonstrates the proposed behavior only on an older head. Is this the best way to solve the issue? Unclear until maintainer API acceptance: the implementation uses the existing internal hook dispatcher and separates transcript durability into the sibling save-hook work, but current-head proof, clean mergeability, and contract sponsorship remain open. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 153fed790a5c. Label changesLabel justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
9720628 to
9aecd5c
Compare
91a8d86 to
52d2870
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…ook-clean # Conflicts: # src/gateway/server-discovery-runtime.test.ts
…ook-clean # Conflicts: # extensions/slack/src/monitor/send.runtime.ts # src/agents/agent-tools.schema.test.ts # src/commands/onboard-channels.e2e.test.ts
…ook-clean # Conflicts: # scripts/plugin-sdk-surface-report.mjs # test/scripts/plugin-sdk-surface-report.test.ts
|
@osolmaz @steipete @vincentkoc @Drickon ClawSweeper is proposing close here unless a maintainer sponsors the lifecycle hook contract or marks it for human review. From our side, we still think What would you prefer we do with this PR?
Happy to rebase and clean up current-head CI once the direction is clear; the main question seems to be product/API ownership rather than a concrete code blocker. |
|
This pull request has been automatically marked as stale due to inactivity. |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: feat(hooks): add agent turn end hook This is item 1/1 in the current shard. Shard 0/4. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
Summary
Adds a clean
agent:turn:endinternal hook event for ACP runtime turn completion. This split intentionally keeps the event as a runtime lifecycle boundary only; it does not claim transcript/session-write durability.Changes
agent:turn:endhook events withsessionKey,success,durationMs, and optionalerrorCodecontext.agent:turn:endfor pre-runtime session initialization failures such as max-concurrency rejection.Real behavior proof
agent:turn:endfrom an actual ACP runtime turn, while keeping save/write-durability concerns out of this PR and avoiding turn-end emission for pre-runtime init failures./Users/mantis/Projects/openclaw-pr-turn-end-clean, branchfeat/agent-turn-end-hook-clean, rebased onto currentorigin/main, head52d28708c0.acpxruntime plugin, loaded a temporary internal hook throughhooks.internal.load.extraDirs, initialized a real ACPX/Codex persistent session using a temporary copiedCODEX_HOME, ranAcpSessionManager.runTurn()with the promptReply with exactly TURN-END-HOOK-PROOF-OK, then attempted a second runtime session whileacp.maxConcurrentSessionswas1to force a pre-runtimeACP_SESSION_INIT_FAILEDpath.agent:turn:endevent from a live ACPX/Codex turn withsuccess: true; the pre-runtime max-concurrency failure returnedACP_SESSION_INIT_FAILEDand captured zeroagent:turn:endevents for that blocked session.Testing
node scripts/run-vitest.mjs run src/acp/control-plane/manager.test.ts src/hooks/internal-hooks.test.tspnpm check:test-typespnpm exec oxlint src/acp/control-plane/manager.core.ts src/acp/control-plane/manager.turn-runner.ts src/acp/control-plane/manager.test-helpers.ts src/acp/control-plane/manager.test.ts src/acp/control-plane/manager.types.ts src/hooks/internal-hooks.ts src/hooks/internal-hooks.test.tspnpm exec oxfmt --check --threads=1 docs/automation/hooks.md src/acp/control-plane/manager.core.ts src/acp/control-plane/manager.turn-runner.ts src/acp/control-plane/manager.test-helpers.ts src/acp/control-plane/manager.test.ts src/acp/control-plane/manager.types.ts src/hooks/internal-hooks.ts src/hooks/internal-hooks.test.tsgit diff --check origin/main...HEAD && git diff --checkRelated
Related #37833
Split from #71399
Sibling save-write outcome work: #89154
Latest head refresh (2026-06-22)
Current head:
99c51ee900f6e1af2a812ebf54fbf551689c3769Merged current
origin/main(3ff59df960) into the PR branch, resolved Plugin SDK surface report/test conflicts against the merged hook surface, and aligned the slash-command browser-import expectation with the current shared-registry import order.Validation on the current head:
node scripts/run-vitest.mjs run src/acp/control-plane/manager.test.ts src/hooks/internal-hooks.test.ts pnpm exec vitest run ui/src/ui/chat/slash-commands.browser-import.test.ts test/scripts/plugin-sdk-surface-report.test.tsObserved results:
Limitations: I attempted to rerun the existing live ACPX/Codex
agent:turn:endproof harness on this head, but the temporary Gateway run failed withACP_TURN_FAILED/Internal errorbefore producing hook evidence. I am not claiming refreshed live ACP proof for this head; the prior live proof remains from the earlier proof head.