mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-07-28 00:48:07 +00:00
* fix(runtime): reject unsupported run options * fix(runtime): align SDK run compatibility * fix(frontend): avoid unsupported events stream mode --------- Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
import type { Message } from "@langchain/langgraph-sdk";
|
|
import { expect, test } from "@rstest/core";
|
|
|
|
import { hasToolResult } from "@/core/threads/hooks";
|
|
|
|
test("recognizes a completed tool from its ToolMessage", () => {
|
|
const messages = [
|
|
{
|
|
type: "ai",
|
|
content: "",
|
|
tool_calls: [{ id: "call-1", name: "setup_agent", args: {} }],
|
|
},
|
|
{
|
|
type: "tool",
|
|
content: "Agent saved",
|
|
name: "setup_agent",
|
|
tool_call_id: "call-1",
|
|
},
|
|
] as Message[];
|
|
|
|
expect(hasToolResult(messages, "setup_agent")).toBe(true);
|
|
});
|
|
|
|
test("does not treat a pending call or another tool result as completed", () => {
|
|
const pending = [
|
|
{
|
|
type: "ai",
|
|
content: "",
|
|
tool_calls: [{ id: "call-1", name: "setup_agent", args: {} }],
|
|
},
|
|
] as Message[];
|
|
const otherTool = [
|
|
{
|
|
type: "tool",
|
|
content: "Done",
|
|
name: "web_search",
|
|
tool_call_id: "call-2",
|
|
},
|
|
] as Message[];
|
|
|
|
expect(hasToolResult(pending, "setup_agent")).toBe(false);
|
|
expect(hasToolResult(otherTool, "setup_agent")).toBe(false);
|
|
});
|
|
|
|
test("matches a ToolMessage without a name through its tool call id", () => {
|
|
const messages = [
|
|
{
|
|
type: "ai",
|
|
content: "",
|
|
tool_calls: [{ id: "call-1", name: "setup_agent", args: {} }],
|
|
},
|
|
{
|
|
type: "tool",
|
|
content: "Agent saved",
|
|
tool_call_id: "call-1",
|
|
},
|
|
] as Message[];
|
|
|
|
expect(hasToolResult(messages, "setup_agent")).toBe(true);
|
|
});
|