mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 09:58:38 +00:00
test(agents): cover tool result media placeholders
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it, vi } from "vitest";
|
||||||
|
import type { EmbeddedPiSubscribeContext } from "./pi-embedded-subscribe.handlers.types.js";
|
||||||
import {
|
import {
|
||||||
handleToolExecutionEnd,
|
handleToolExecutionEnd,
|
||||||
handleToolExecutionStart,
|
handleToolExecutionStart,
|
||||||
} from "./pi-embedded-subscribe.handlers.tools.js";
|
} 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.
|
// Minimal mock context factory. Only the fields needed for the media emission path.
|
||||||
function createMockContext(overrides?: {
|
function createMockContext(overrides?: {
|
||||||
@@ -167,6 +167,28 @@ describe("handleToolExecutionEnd media emission", () => {
|
|||||||
expect(onToolResult).not.toHaveBeenCalled();
|
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 () => {
|
it("emits media from details.path fallback when no MEDIA: text", async () => {
|
||||||
const onToolResult = vi.fn();
|
const onToolResult = vi.fn();
|
||||||
const ctx = createMockContext({ shouldEmitToolOutput: false, onToolResult });
|
const ctx = createMockContext({ shouldEmitToolOutput: false, onToolResult });
|
||||||
|
|||||||
Reference in New Issue
Block a user