From 06c13c266eeb80bd7f5fc5613f3cd749ee4e78d9 Mon Sep 17 00:00:00 2001 From: zhoulf1006 Date: Wed, 11 Mar 2026 00:45:32 +0800 Subject: [PATCH] fix(hooks): add missing trigger and channelId to agent_end, llm_input, and llm_output hook contexts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #28623 added trigger and channelId to PluginHookAgentContext and threaded them through hookCtx for before_prompt_build, but missed the separate context objects constructed for agent_end (line ~1974), llm_input (line ~1766), and llm_output (line ~2034). This caused ctx.trigger and ctx.channelId to always be undefined in those hook handlers, breaking plugins that rely on trigger to distinguish user-initiated vs memory/cron/heartbeat runs. Aligns all hook context objects with hookCtx (line ~1636) so every hook phase receives identical context fields. 🤖 AI-assisted --- src/agents/pi-embedded-runner/run/attempt.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/agents/pi-embedded-runner/run/attempt.ts b/src/agents/pi-embedded-runner/run/attempt.ts index 0014475a880..2f5f3d04d5f 100644 --- a/src/agents/pi-embedded-runner/run/attempt.ts +++ b/src/agents/pi-embedded-runner/run/attempt.ts @@ -1774,6 +1774,8 @@ export async function runEmbeddedAttempt( sessionId: params.sessionId, workspaceDir: params.workspaceDir, messageProvider: params.messageProvider ?? undefined, + trigger: params.trigger, + channelId: params.messageChannel ?? params.messageProvider ?? undefined, }, ) .catch((err) => { @@ -1982,6 +1984,8 @@ export async function runEmbeddedAttempt( sessionId: params.sessionId, workspaceDir: params.workspaceDir, messageProvider: params.messageProvider ?? undefined, + trigger: params.trigger, + channelId: params.messageChannel ?? params.messageProvider ?? undefined, }, ) .catch((err) => { @@ -2042,6 +2046,8 @@ export async function runEmbeddedAttempt( sessionId: params.sessionId, workspaceDir: params.workspaceDir, messageProvider: params.messageProvider ?? undefined, + trigger: params.trigger, + channelId: params.messageChannel ?? params.messageProvider ?? undefined, }, ) .catch((err) => {