diff --git a/src/agents/pi-embedded-subscribe.handlers.tools.media.test.ts b/src/agents/pi-embedded-subscribe.handlers.tools.media.test.ts index 1c9599bc50..0677a525fc 100644 --- a/src/agents/pi-embedded-subscribe.handlers.tools.media.test.ts +++ b/src/agents/pi-embedded-subscribe.handlers.tools.media.test.ts @@ -1,9 +1,9 @@ import { describe, expect, it, vi } from "vitest"; +import type { EmbeddedPiSubscribeContext } from "./pi-embedded-subscribe.handlers.types.js"; import { handleToolExecutionEnd, handleToolExecutionStart, } from "./pi-embedded-subscribe.handlers.tools.js"; -import type { EmbeddedPiSubscribeContext } from "./pi-embedded-subscribe.handlers.types.js"; // Minimal mock context factory. Only the fields needed for the media emission path. function createMockContext(overrides?: { @@ -167,6 +167,28 @@ describe("handleToolExecutionEnd media emission", () => { expect(onToolResult).not.toHaveBeenCalled(); }); + it("does NOT emit media for placeholder text", async () => { + const onToolResult = vi.fn(); + const ctx = createMockContext({ shouldEmitToolOutput: false, onToolResult }); + + await handleToolExecutionEnd(ctx, { + type: "tool_execution_end", + toolName: "tts", + toolCallId: "tc-1", + isError: false, + result: { + content: [ + { + type: "text", + text: " placeholder with successful preflight voice transcript", + }, + ], + }, + }); + + expect(onToolResult).not.toHaveBeenCalled(); + }); + it("emits media from details.path fallback when no MEDIA: text", async () => { const onToolResult = vi.fn(); const ctx = createMockContext({ shouldEmitToolOutput: false, onToolResult });