chore(vendor): import pi 1.3.0
Imported as a linear vendor commit so forge rebases do not replay the upstream root tree. git-subtree-dir: third_party/pi git-subtree-split: 71023aec1546d6d677a65669c5665c0927ce0dd0
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Type } from "typebox";
|
||||
import { Compile } from "typebox/compile";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { Tool, ToolCall } from "../src/types.ts";
|
||||
import type { JsonValue, Tool, ToolCall } from "../src/types.ts";
|
||||
import { validateToolArguments } from "../src/utils/validation.ts";
|
||||
|
||||
function createToolCallWithPlainSchema(
|
||||
@@ -27,7 +27,7 @@ function createToolCallWithPlainSchema(
|
||||
type: "toolCall",
|
||||
id: "tool-1",
|
||||
name: "echo",
|
||||
arguments: { value },
|
||||
arguments: { value: value as JsonValue },
|
||||
};
|
||||
|
||||
return { tool, toolCall };
|
||||
@@ -207,4 +207,23 @@ describe("validateToolArguments", () => {
|
||||
expect(() => validateToolArguments(tool, toolCall)).toThrow("Validation failed");
|
||||
}
|
||||
});
|
||||
// #10897
|
||||
it("reports malformed arguments JSON instead of validating empty arguments", () => {
|
||||
const tool: Tool = {
|
||||
name: "echo",
|
||||
description: "Echo tool",
|
||||
parameters: Type.Object({ value: Type.Optional(Type.String()) }),
|
||||
};
|
||||
const toolCall: ToolCall = {
|
||||
type: "toolCall",
|
||||
id: "tool-1",
|
||||
name: "echo",
|
||||
arguments: {},
|
||||
argumentsError: "Unexpected token",
|
||||
};
|
||||
|
||||
expect(() => validateToolArguments(tool, toolCall)).toThrow(
|
||||
'Invalid arguments for tool "echo": Unexpected token',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user