Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/common/utils/tools/toolDefinitions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,37 @@ describe("TOOL_DEFINITIONS", () => {
expect(parsed.success).toBe(false);
});

it("accepts bash tool calls using description (alias for display_name)", () => {
// DeepSeek v4 emits `description` instead of `display_name`; ensure it normalizes.
const parsed = TOOL_DEFINITIONS.bash.schema.safeParse({
script: "ls",
timeout_secs: 60,
run_in_background: false,
description: "List files",
});

expect(parsed.success).toBe(true);
if (parsed.success) {
expect(parsed.data.display_name).toBe("List files");
expect("description" in parsed.data).toBe(false);
}
});

it("prefers display_name when both display_name and description are provided", () => {
const parsed = TOOL_DEFINITIONS.bash.schema.safeParse({
script: "ls",
timeout_secs: 60,
run_in_background: false,
display_name: "Real Name",
description: "Alias Name",
});

expect(parsed.success).toBe(true);
if (parsed.success) {
expect(parsed.data.display_name).toBe("Real Name");
}
});

const filePathAliasCases = [
{
toolName: "file_read",
Expand Down
16 changes: 11 additions & 5 deletions src/common/utils/tools/toolDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -852,16 +852,22 @@ export const TOOL_DEFINITIONS = {
// Normalize to `script` so downstream code (tool runner + UI) stays consistent.
if (typeof value !== "object" || value === null || Array.isArray(value)) return value;

const obj = value as Record<string, unknown>;
if (typeof obj.script === "string") return value;
let obj = value as Record<string, unknown>;

if (typeof obj.command === "string") {
if (typeof obj.script !== "string" && typeof obj.command === "string") {
// Drop the legacy field to keep tool args canonical (and avoid confusing downstream consumers).
const { command, ...rest } = obj as Record<string, unknown> & { command: string };
return { ...rest, script: command };
obj = { ...rest, script: command };
}

return value;
// Compatibility: DeepSeek v4 emits `description` instead of `display_name`.
// Treat `description` as an undocumented alias so the call still validates.
if (typeof obj.display_name !== "string" && typeof obj.description === "string") {
const { description, ...rest } = obj as Record<string, unknown> & { description: string };
obj = { ...rest, display_name: description };
}

return obj;
},
z.object({
script: z.string().describe("The bash script/command to execute"),
Expand Down
Loading