( parts []fantasy.MessagePart, )
| 597 | } |
| 598 | |
| 599 | func normalizeAssistantToolCallInputs( |
| 600 | parts []fantasy.MessagePart, |
| 601 | ) []fantasy.MessagePart { |
| 602 | normalized := make([]fantasy.MessagePart, 0, len(parts)) |
| 603 | for _, part := range parts { |
| 604 | toolCall, ok := safeAsToolCallPart(part) |
| 605 | if !ok { |
| 606 | normalized = append(normalized, part) |
| 607 | continue |
| 608 | } |
| 609 | |
| 610 | toolCall.Input = normalizeToolCallInput(toolCall.Input) |
| 611 | normalized = append(normalized, toolCall) |
| 612 | } |
| 613 | return normalized |
| 614 | } |
| 615 | |
| 616 | // normalizeToolCallInput guarantees tool call input is a JSON object string. |
| 617 | // Anthropic drops assistant tool calls with malformed input, which can leave |
no test coverage detected