From d5453b0c72bc023379e3f57de6a3e0913b12422c Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 2 Mar 2026 17:34:38 -0800 Subject: [PATCH] fix(hooks): reuse shared hook context for post-prompt hooks --- src/agents/pi-embedded-runner/run/attempt.ts | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/agents/pi-embedded-runner/run/attempt.ts b/src/agents/pi-embedded-runner/run/attempt.ts index a84896f8b26..117a7f0a9b2 100644 --- a/src/agents/pi-embedded-runner/run/attempt.ts +++ b/src/agents/pi-embedded-runner/run/attempt.ts @@ -1595,13 +1595,7 @@ export async function runEmbeddedAttempt( error: promptError ? describeUnknownError(promptError) : undefined, durationMs: Date.now() - promptStartedAt, }, - { - agentId: hookAgentId, - sessionKey: params.sessionKey, - sessionId: params.sessionId, - workspaceDir: params.workspaceDir, - messageProvider: params.messageProvider ?? undefined, - }, + hookCtx, ) .catch((err) => { log.warn(`agent_end hook failed: ${err}`); @@ -1655,13 +1649,7 @@ export async function runEmbeddedAttempt( lastAssistant, usage: getUsageTotals(), }, - { - agentId: hookAgentId, - sessionKey: params.sessionKey, - sessionId: params.sessionId, - workspaceDir: params.workspaceDir, - messageProvider: params.messageProvider ?? undefined, - }, + hookCtx, ) .catch((err) => { log.warn(`llm_output hook failed: ${String(err)}`);