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

@@ -371,6 +371,7 @@ export async function compactEmbeddedPiSessionDirect(
agentAccountId: params.agentAccountId,
sessionKey: sandboxSessionKey,
sessionId: params.sessionId,
runId: params.runId,
groupId: params.groupId,
groupChannel: params.groupChannel,
groupSpace: params.groupSpace,

View File

@@ -645,6 +645,7 @@ export async function runEmbeddedAttempt(
senderIsOwner: params.senderIsOwner,
sessionKey: sandboxSessionKey,
sessionId: params.sessionId,
runId: params.runId,
agentDir,
workspaceDir: effectiveWorkspace,
config: params.config,
@@ -920,6 +921,7 @@ export async function runEmbeddedAttempt(
agentId: sessionAgentId,
sessionKey: sandboxSessionKey,
sessionId: params.sessionId,
runId: params.runId,
loopDetection: clientToolLoopDetection,
},
)