




















@@ -86,13 +86,13 @@ describe("normalizeToolParameterSchema", () => {
8686};
87878888expect(cleaned.$defs).toBeUndefined();
89-expect(cleaned.properties).toMatchObject({
89+expect(cleaned.properties).toEqual({
9090foo: {
9191type: "string",
9292enum: ["a", "b"],
9393},
9494});
95-expect(cleaned.properties?.foo).toMatchObject({
95+expect(cleaned.properties?.foo).toEqual({
9696type: "string",
9797enum: ["a", "b"],
9898});
@@ -428,22 +428,31 @@ describe("normalizeToolParameters", () => {
428428);
429429430430expect(streamCalls).toBe(2);
431-expect(execute).toHaveBeenCalledWith("call-null-args", {}, undefined, expect.any(Function));
431+const executeCall = execute.mock.calls[0];
432+expect(executeCall?.[0]).toBe("call-null-args");
433+expect(executeCall?.[1]).toEqual({});
434+expect(executeCall?.[2]).toBeUndefined();
435+expect(typeof executeCall?.[3]).toBe("function");
432436const toolResult = messages.find((message) => message.role === "toolResult");
433-expect(toolResult).toMatchObject({
434-role: "toolResult",
435-toolCallId: "call-null-args",
436-toolName: "wiki_lint",
437-isError: false,
438-content: [{ type: "text", text: "wiki ok" }],
439-});
437+const toolResultRecord = toolResult as
438+| {
439+role?: string;
440+toolCallId?: string;
441+toolName?: string;
442+isError?: boolean;
443+content?: unknown;
444+}
445+| undefined;
446+expect(toolResultRecord?.role).toBe("toolResult");
447+expect(toolResultRecord?.toolCallId).toBe("call-null-args");
448+expect(toolResultRecord?.toolName).toBe("wiki_lint");
449+expect(toolResultRecord?.isError).toBe(false);
450+expect(toolResultRecord?.content).toEqual([{ type: "text", text: "wiki ok" }]);
440451const endedToolCall = events.find((event) => event.type === "tool_execution_end");
441-expect(endedToolCall).toMatchObject({
442-type: "tool_execution_end",
443-toolCallId: "call-null-args",
444-toolName: "wiki_lint",
445-isError: false,
446-});
452+expect(endedToolCall?.type).toBe("tool_execution_end");
453+expect(endedToolCall?.toolCallId).toBe("call-null-args");
454+expect(endedToolCall?.toolName).toBe("wiki_lint");
455+expect(endedToolCall?.isError).toBe(false);
447456expect(JSON.stringify(messages)).not.toContain("Validation failed for tool");
448457});
449458此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。