mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-09-16 17:46:20 +00:00
* fix(sandbox): make tool descriptions optional * fix(sandbox): address optional description review * test(sandbox): pin optional description contracts
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "@rstest/core";
|
|
|
|
import {
|
|
formatSubtaskTokenUsage,
|
|
resolveSubtaskDescription,
|
|
resolveSubtaskModelLabel,
|
|
} from "@/core/tasks/presentation";
|
|
|
|
describe("resolveSubtaskDescription", () => {
|
|
it("prefers the short label and falls back to the required prompt", () => {
|
|
expect(
|
|
resolveSubtaskDescription(" Research auth ", "long prompt", "Subtask"),
|
|
).toBe("Research auth");
|
|
expect(resolveSubtaskDescription("", " Investigate auth ", "Subtask")).toBe(
|
|
"Investigate auth",
|
|
);
|
|
expect(resolveSubtaskDescription(undefined, undefined, "Subtask")).toBe(
|
|
"Subtask",
|
|
);
|
|
});
|
|
});
|
|
|
|
describe("resolveSubtaskModelLabel", () => {
|
|
it("prefers the configured display name and falls back to the model identifier", () => {
|
|
expect(
|
|
resolveSubtaskModelLabel("claude-3-7-sonnet", [
|
|
{
|
|
id: "model-1",
|
|
name: "claude-3-7-sonnet",
|
|
model: "claude-3-7-sonnet@20250219",
|
|
display_name: "Claude 3.7 Sonnet",
|
|
},
|
|
]),
|
|
).toBe("Claude 3.7 Sonnet");
|
|
|
|
expect(resolveSubtaskModelLabel("unlisted-model", [])).toBe(
|
|
"unlisted-model",
|
|
);
|
|
});
|
|
|
|
it("formats only reported cumulative token usage", () => {
|
|
expect(formatSubtaskTokenUsage(undefined)).toBeUndefined();
|
|
expect(
|
|
formatSubtaskTokenUsage({
|
|
inputTokens: 10_000,
|
|
outputTokens: 2_345,
|
|
totalTokens: 12_345,
|
|
}),
|
|
).toBe("12.3K");
|
|
});
|
|
});
|