mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-08-10 14:58:46 +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>
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
import { expect, test } from "@rstest/core";
|
|
|
|
import { sanitizeRunStreamOptions } from "@/core/api/stream-mode";
|
|
|
|
test("rejects mixed supported and unsupported stream modes", () => {
|
|
expect(() =>
|
|
sanitizeRunStreamOptions({
|
|
streamMode: ["values", "events", "tools"],
|
|
}),
|
|
).toThrow("Unsupported LangGraph stream mode(s): events, tools");
|
|
});
|
|
|
|
test("rejects payloads when every requested stream mode is unsupported", () => {
|
|
expect(() =>
|
|
sanitizeRunStreamOptions({
|
|
streamMode: ["events", "tools"],
|
|
}),
|
|
).toThrow("Unsupported LangGraph stream mode(s): events, tools");
|
|
|
|
expect(() =>
|
|
sanitizeRunStreamOptions({
|
|
streamMode: "tools",
|
|
}),
|
|
).toThrow("Unsupported LangGraph stream mode(s): tools");
|
|
});
|
|
|
|
test("rejects messages because the Gateway only supports messages-tuple framing", () => {
|
|
expect(() =>
|
|
sanitizeRunStreamOptions({
|
|
streamMode: "messages",
|
|
}),
|
|
).toThrow("Unsupported LangGraph stream mode(s): messages");
|
|
});
|
|
|
|
test("keeps payloads without streamMode untouched", () => {
|
|
const options = {
|
|
streamSubgraphs: true,
|
|
};
|
|
|
|
expect(sanitizeRunStreamOptions(options)).toBe(options);
|
|
});
|
|
|
|
test("strips streamResumable before sending run options to the API", () => {
|
|
const sanitized = sanitizeRunStreamOptions({
|
|
streamResumable: true,
|
|
streamSubgraphs: true,
|
|
});
|
|
|
|
expect(sanitized).toEqual({
|
|
streamSubgraphs: true,
|
|
});
|
|
});
|
|
|
|
test("sanitizes streamResumable while preserving valid stream modes", () => {
|
|
const sanitized = sanitizeRunStreamOptions({
|
|
streamResumable: true,
|
|
streamMode: ["values", "custom"],
|
|
});
|
|
|
|
expect(sanitized).toEqual({
|
|
streamMode: ["values", "custom"],
|
|
});
|
|
});
|