refactor tool-call detail contract for unknown tools

This commit is contained in:
Mohamed Boudra
2026-02-09 16:50:04 +07:00
parent ef29319baf
commit 7ec3f2d3cf
31 changed files with 228 additions and 177 deletions
@@ -64,8 +64,17 @@ describe("shared messages tool_call schema", () => {
error: null,
});
const withTopLevelInputOutput = AgentTimelineItemPayloadSchema.safeParse({
...canonicalBase(),
status: "running",
error: null,
input: { command: "pwd" },
output: { exitCode: 0 },
});
expect(missingCallId.success).toBe(false);
expect(unknownStatus.success).toBe(false);
expect(withTopLevelInputOutput.success).toBe(false);
});
it("rejects legacy status/error combinations without normalization", () => {
+3 -3
View File
@@ -190,8 +190,8 @@ const ToolCallDetailPayloadSchema: z.ZodType<ToolCallDetail> = z.discriminatedUn
}),
z.object({
type: z.literal("unknown"),
rawInput: UnknownValueSchema,
rawOutput: UnknownValueSchema,
input: UnknownValueSchema,
output: UnknownValueSchema,
}),
]);
@@ -201,7 +201,7 @@ const ToolCallBasePayloadSchema = z.object({
name: z.string(),
detail: ToolCallDetailPayloadSchema,
metadata: z.record(z.unknown()).optional(),
});
}).strict();
const ToolCallRunningPayloadSchema = ToolCallBasePayloadSchema.extend({
status: z.literal("running"),
@@ -28,8 +28,8 @@ describe("shared tool-call display mapping", () => {
error: null,
detail: {
type: "unknown",
rawInput: { command: "npm test" },
rawOutput: null,
input: { command: "npm test" },
output: null,
},
});
@@ -45,8 +45,8 @@ describe("shared tool-call display mapping", () => {
error: null,
detail: {
type: "unknown",
rawInput: null,
rawOutput: null,
input: null,
output: null,
},
metadata: {
subAgentActivity: "Running tests",
@@ -66,8 +66,8 @@ describe("shared tool-call display mapping", () => {
error: { message: "boom" },
detail: {
type: "unknown",
rawInput: null,
rawOutput: null,
input: null,
output: null,
},
});