mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-10-26 21:26:39 +00:00
* fix(sandbox): make tool descriptions optional * fix(sandbox): address optional description review * test(sandbox): pin optional description contracts
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import { formatTokenCount, type TokenUsage } from "@/core/messages/usage";
|
|
import type { Model } from "@/core/models/types";
|
|
|
|
/** Resolve the card label when a provider omits the task tool's optional description. */
|
|
export function resolveSubtaskDescription(
|
|
description: unknown,
|
|
prompt: unknown,
|
|
fallback: string,
|
|
): string {
|
|
if (typeof description === "string" && description.trim()) {
|
|
return description.trim();
|
|
}
|
|
if (typeof prompt === "string" && prompt.trim()) {
|
|
return prompt.trim();
|
|
}
|
|
return fallback;
|
|
}
|
|
|
|
/** Return the user-facing label for a configured subagent model. */
|
|
export function resolveSubtaskModelLabel(
|
|
modelName: string | undefined,
|
|
models: Model[],
|
|
): string | undefined {
|
|
if (!modelName) {
|
|
return undefined;
|
|
}
|
|
return (
|
|
models.find((model) => model.name === modelName)?.display_name ?? modelName
|
|
);
|
|
}
|
|
|
|
export function formatSubtaskTokenUsage(
|
|
usage: TokenUsage | undefined,
|
|
): string | undefined {
|
|
return usage ? formatTokenCount(usage.totalTokens) : undefined;
|
|
}
|