Repository navigation
fix(agents): preserve code mode hook context - #83481
Conversation
|
Codex review: needs real behavior proof before merge. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
Summary Reproducibility: yes. Source inspection shows outer code-mode controls reach toToolDefinitions without ctx on current main, and runBeforeToolCallHook only forwards agentId when args.ctx is present. PR rating Rank-up moves:
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. Real behavior proof Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Land the focused context-threading fix after maintainer/security acceptance, and keep any code-vs-command input-shape alignment as a separate hook-contract decision. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows outer code-mode controls reach toToolDefinitions without ctx on current main, and runBeforeToolCallHook only forwards agentId when args.ctx is present. Is this the best way to solve the issue? Yes for the minimum bug. Passing the already-built run HookContext through splitSdkTools into the adapter is narrower and more maintainable than asking plugins to recover agent identity from sessionKey; the input-shape concern should remain separate. Label justifications:
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 56024b782814. |
Summary
exec/waitdispatches keep agent/session/run/channel metadata.Fixes #83387
Verification
node scripts/run-vitest.mjs src/agents/pi-tools.before-tool-call.integration.e2e.test.ts src/agents/code-mode.test.ts src/agents/tool-search.test.ts src/agents/pi-embedded-runner.splitsdktools.test.ts src/agents/pi-tool-definition-adapter.after-tool-call.test.tspnpm format:fix src/agents/pi-tool-definition-adapter.ts src/agents/pi-embedded-runner/tool-split.ts src/agents/pi-embedded-runner/run/attempt.ts src/agents/pi-embedded-runner/compact.ts src/agents/pi-tools.before-tool-call.integration.e2e.test.ts CHANGELOG.mdgit diff --check.agents/skills/autoreview/scripts/autoreview --mode autoReal behavior proof
Behavior addressed:
before_tool_callhooks now receive agent/session/run/channel context for top-level OpenClaw code-modeexec/waitdispatches instead of seeing an undefinedctx.agentId.Real environment tested: local OpenClaw checkout on macOS with targeted Vitest coverage for the code-mode/tool-search/hook adapter path.
Exact steps or command run after this patch:
node scripts/run-vitest.mjs src/agents/pi-tools.before-tool-call.integration.e2e.test.ts src/agents/code-mode.test.ts src/agents/tool-search.test.ts src/agents/pi-embedded-runner.splitsdktools.test.ts src/agents/pi-tool-definition-adapter.after-tool-call.test.tsEvidence after fix: the new regression executes an unwrapped
exectool definition with hook context and asserts the plugin hook receivesagentId,sessionKey,sessionId,runId, andchannelId; the existing dedupe tests still prove wrapped tools fire once.Observed result after fix: 7 test files passed, 95 tests passed; autoreview reported no accepted/actionable findings.
What was not tested: no live model/gateway run; the failing boundary is covered locally at the adapter and code-mode catalog/tool-search unit level.