test(agents): cover tool result media placeholders

This commit is contained in:
Sebastian
2026-02-16 22:16:01 -05:00
parent 68634468f5
commit ecfc5a5ee7

View File

@@ -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 <media:audio> 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: "<media:audio> 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 });