mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 08:21:26 +00:00
chore: Fix types in tests 5/N.
This commit is contained in:
@@ -24,7 +24,7 @@ describe("sanitizeToolUseResultPairing", () => {
|
||||
content: [{ type: "text", text: "ok" }],
|
||||
isError: false,
|
||||
},
|
||||
] satisfies AgentMessage[];
|
||||
] as unknown as AgentMessage[];
|
||||
|
||||
const out = sanitizeToolUseResultPairing(input);
|
||||
expect(out[0]?.role).toBe("assistant");
|
||||
@@ -56,7 +56,7 @@ describe("sanitizeToolUseResultPairing", () => {
|
||||
isError: false,
|
||||
},
|
||||
{ role: "user", content: "ok" },
|
||||
] satisfies AgentMessage[];
|
||||
] as unknown as AgentMessage[];
|
||||
|
||||
const out = sanitizeToolUseResultPairing(input);
|
||||
expect(out.filter((m) => m.role === "toolResult")).toHaveLength(1);
|
||||
@@ -83,7 +83,7 @@ describe("sanitizeToolUseResultPairing", () => {
|
||||
content: [{ type: "text", text: "second (duplicate)" }],
|
||||
isError: false,
|
||||
},
|
||||
] satisfies AgentMessage[];
|
||||
] as unknown as AgentMessage[];
|
||||
|
||||
const out = sanitizeToolUseResultPairing(input);
|
||||
const results = out.filter((m) => m.role === "toolResult") as Array<{
|
||||
@@ -107,7 +107,7 @@ describe("sanitizeToolUseResultPairing", () => {
|
||||
role: "assistant",
|
||||
content: [{ type: "text", text: "ok" }],
|
||||
},
|
||||
] satisfies AgentMessage[];
|
||||
] as unknown as AgentMessage[];
|
||||
|
||||
const out = sanitizeToolUseResultPairing(input);
|
||||
expect(out.some((m) => m.role === "toolResult")).toBe(false);
|
||||
@@ -125,7 +125,7 @@ describe("sanitizeToolUseResultPairing", () => {
|
||||
stopReason: "error",
|
||||
},
|
||||
{ role: "user", content: "something went wrong" },
|
||||
] as AgentMessage[];
|
||||
] as unknown as AgentMessage[];
|
||||
|
||||
const result = repairToolUseResultPairing(input);
|
||||
|
||||
@@ -147,7 +147,7 @@ describe("sanitizeToolUseResultPairing", () => {
|
||||
stopReason: "aborted",
|
||||
},
|
||||
{ role: "user", content: "retrying after abort" },
|
||||
] as AgentMessage[];
|
||||
] as unknown as AgentMessage[];
|
||||
|
||||
const result = repairToolUseResultPairing(input);
|
||||
|
||||
@@ -168,7 +168,7 @@ describe("sanitizeToolUseResultPairing", () => {
|
||||
stopReason: "toolUse",
|
||||
},
|
||||
{ role: "user", content: "user message" },
|
||||
] as AgentMessage[];
|
||||
] as unknown as AgentMessage[];
|
||||
|
||||
const result = repairToolUseResultPairing(input);
|
||||
|
||||
@@ -195,7 +195,7 @@ describe("sanitizeToolUseResultPairing", () => {
|
||||
isError: false,
|
||||
},
|
||||
{ role: "user", content: "retrying" },
|
||||
] as AgentMessage[];
|
||||
] as unknown as AgentMessage[];
|
||||
|
||||
const result = repairToolUseResultPairing(input);
|
||||
|
||||
@@ -211,20 +211,20 @@ describe("sanitizeToolUseResultPairing", () => {
|
||||
|
||||
describe("sanitizeToolCallInputs", () => {
|
||||
it("drops tool calls missing input or arguments", () => {
|
||||
const input: AgentMessage[] = [
|
||||
const input = [
|
||||
{
|
||||
role: "assistant",
|
||||
content: [{ type: "toolCall", id: "call_1", name: "read" }],
|
||||
},
|
||||
{ role: "user", content: "hello" },
|
||||
];
|
||||
] as unknown as AgentMessage[];
|
||||
|
||||
const out = sanitizeToolCallInputs(input);
|
||||
expect(out.map((m) => m.role)).toEqual(["user"]);
|
||||
});
|
||||
|
||||
it("drops tool calls with missing or blank name/id", () => {
|
||||
const input: AgentMessage[] = [
|
||||
const input = [
|
||||
{
|
||||
role: "assistant",
|
||||
content: [
|
||||
@@ -234,7 +234,7 @@ describe("sanitizeToolCallInputs", () => {
|
||||
{ type: "functionCall", id: "", name: "exec", arguments: {} },
|
||||
],
|
||||
},
|
||||
];
|
||||
] as unknown as AgentMessage[];
|
||||
|
||||
const out = sanitizeToolCallInputs(input);
|
||||
const assistant = out[0] as Extract<AgentMessage, { role: "assistant" }>;
|
||||
@@ -250,7 +250,7 @@ describe("sanitizeToolCallInputs", () => {
|
||||
});
|
||||
|
||||
it("keeps valid tool calls and preserves text blocks", () => {
|
||||
const input: AgentMessage[] = [
|
||||
const input = [
|
||||
{
|
||||
role: "assistant",
|
||||
content: [
|
||||
@@ -259,7 +259,7 @@ describe("sanitizeToolCallInputs", () => {
|
||||
{ type: "toolCall", id: "call_drop", name: "read" },
|
||||
],
|
||||
},
|
||||
];
|
||||
] as unknown as AgentMessage[];
|
||||
|
||||
const out = sanitizeToolCallInputs(input);
|
||||
const assistant = out[0] as Extract<AgentMessage, { role: "assistant" }>;
|
||||
|
||||
Reference in New Issue
Block a user