fix(hooks): propagate run/tool IDs for tool hook correlation (#32360)

* Plugin SDK: add run and tool call fields to tool hooks

* Agents: propagate runId and toolCallId in before_tool_call

* Agents: thread runId through tool wrapper context

* Runner: pass runId into tool hook context

* Compaction: pass runId into tool hook context

* Agents: scope after_tool_call start data by run

* Tests: cover run and tool IDs in before_tool_call hooks

* Tests: add run-scoped after_tool_call collision coverage

* Hooks: scope adjusted tool params by run

* Tests: cover run-scoped adjusted param collisions

* Hooks: preserve active tool start metadata until end

* Changelog: add tool-hook correlation note
This commit is contained in:
Vincent Koc
2026-03-02 17:23:08 -08:00
committed by GitHub
parent 61adcea68e
commit 747902a26a
9 changed files with 200 additions and 19 deletions

View File

@@ -190,6 +190,8 @@ export function createOpenClawCodingTools(options?: {
sessionKey?: string;
/** Ephemeral session UUID — regenerated on /new and /reset. */
sessionId?: string;
/** Stable run identifier for this agent invocation. */
runId?: string;
agentDir?: string;
workspaceDir?: string;
config?: OpenClawConfig;
@@ -537,6 +539,7 @@ export function createOpenClawCodingTools(options?: {
agentId,
sessionKey: options?.sessionKey,
sessionId: options?.sessionId,
runId: options?.runId,
loopDetection: resolveToolLoopDetectionConfig({ cfg: options?.config, agentId }),
}),
);