Skip to content

Commit b3f42da

Browse files
ochafikclaude
andcommitted
Fix failing tests for ToolResultContent and CreateMessageRequest schemas
- Use structuredContent instead of content for plain object results in ToolResultContent tests - Use camelCase toolChoice instead of snake_case tool_choice in CreateMessageRequest test 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1df201f commit b3f42da

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/types.test.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,29 +371,31 @@ describe('Types', () => {
371371
const toolResult = {
372372
type: "tool_result",
373373
toolUseId: "call_123",
374-
content: { temperature: 72, condition: "sunny" }
374+
structuredContent: { temperature: 72, condition: "sunny" }
375375
};
376376

377377
const result = ToolResultContentSchema.safeParse(toolResult);
378378
expect(result.success).toBe(true);
379379
if (result.success) {
380380
expect(result.data.type).toBe("tool_result");
381381
expect(result.data.toolUseId).toBe("call_123");
382-
expect(result.data.content).toEqual({ temperature: 72, condition: "sunny" });
382+
expect(result.data.structuredContent).toEqual({ temperature: 72, condition: "sunny" });
383383
}
384384
});
385385

386386
test("should validate tool result with error in content", () => {
387387
const toolResult = {
388388
type: "tool_result",
389389
toolUseId: "call_456",
390-
content: { error: "API_ERROR", message: "Service unavailable" }
390+
structuredContent: { error: "API_ERROR", message: "Service unavailable" },
391+
isError: true
391392
};
392393

393394
const result = ToolResultContentSchema.safeParse(toolResult);
394395
expect(result.success).toBe(true);
395396
if (result.success) {
396-
expect(result.data.content).toEqual({ error: "API_ERROR", message: "Service unavailable" });
397+
expect(result.data.structuredContent).toEqual({ error: "API_ERROR", message: "Service unavailable" });
398+
expect(result.data.isError).toBe(true);
397399
}
398400
});
399401

@@ -615,7 +617,7 @@ describe('Types', () => {
615617
}
616618
}
617619
],
618-
tool_choice: {
620+
toolChoice: {
619621
mode: "auto"
620622
}
621623
}
@@ -625,7 +627,7 @@ describe('Types', () => {
625627
expect(result.success).toBe(true);
626628
if (result.success) {
627629
expect(result.data.params.tools).toHaveLength(1);
628-
expect(result.data.params.tool_choice?.mode).toBe("auto");
630+
expect(result.data.params.toolChoice?.mode).toBe("auto");
629631
}
630632
});
631633

0 commit comments

Comments
 (0)