refactor tool-call detail contract for unknown tools
This commit is contained in:
@@ -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", () => {
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user