diff --git a/src/hooks/atlas/index.test.ts b/src/hooks/atlas/index.test.ts index 533bd2ffe..2db8a5ef1 100644 --- a/src/hooks/atlas/index.test.ts +++ b/src/hooks/atlas/index.test.ts @@ -66,6 +66,20 @@ describe("atlas hook", () => { }) describe("tool.execute.after handler", () => { + test("should handle undefined output gracefully (issue #1035)", async () => { + // #given - hook and undefined output (e.g., from /review command) + const hook = createAtlasHook(createMockPluginInput()) + + // #when - calling with undefined output + const result = await hook["tool.execute.after"]( + { tool: "delegate_task", sessionID: "session-123" }, + undefined as unknown as { title: string; output: string; metadata: Record } + ) + + // #then - returns undefined without throwing + expect(result).toBeUndefined() + }) + test("should ignore non-delegate_task tools", async () => { // #given - hook and non-delegate_task tool const hook = createAtlasHook(createMockPluginInput()) diff --git a/src/hooks/atlas/index.ts b/src/hooks/atlas/index.ts index bd20168be..786ba4004 100644 --- a/src/hooks/atlas/index.ts +++ b/src/hooks/atlas/index.ts @@ -663,6 +663,11 @@ export function createAtlasHook( input: ToolExecuteAfterInput, output: ToolExecuteAfterOutput ): Promise => { + // Guard against undefined output (e.g., from /review command - see issue #1035) + if (!output) { + return + } + if (!isCallerOrchestrator(input.sessionID)) { return } diff --git a/src/hooks/claude-code-hooks/index.ts b/src/hooks/claude-code-hooks/index.ts index da4d62080..2ff745558 100644 --- a/src/hooks/claude-code-hooks/index.ts +++ b/src/hooks/claude-code-hooks/index.ts @@ -237,6 +237,11 @@ export function createClaudeCodeHooksHook( input: { tool: string; sessionID: string; callID: string }, output: { title: string; output: string; metadata: unknown } ): Promise => { + // Guard against undefined output (e.g., from /review command - see issue #1035) + if (!output) { + return + } + const claudeConfig = await loadClaudeHooksConfig() const extendedConfig = await loadPluginExtendedConfig() diff --git a/src/index.ts b/src/index.ts index 7319ec34e..3d83bc66b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -657,6 +657,10 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => { }, "tool.execute.after": async (input, output) => { + // Guard against undefined output (e.g., from /review command - see issue #1035) + if (!output) { + return; + } await claudeCodeHooks["tool.execute.after"](input, output); await toolOutputTruncator?.["tool.execute.after"](input, output); await contextWindowMonitor?.["tool.execute.after"](input, output);