MCPcopy Create free account
hub / github.com/coder/coder / normalizeToolCallInput

Function normalizeToolCallInput

coderd/x/chatd/chatprompt/chatprompt.go:619–631  ·  view source on GitHub ↗

normalizeToolCallInput guarantees tool call input is a JSON object string. Anthropic drops assistant tool calls with malformed input, which can leave following tool results orphaned.

(input string)

Source from the content-addressed store, hash-verified

617// Anthropic drops assistant tool calls with malformed input, which can leave
618// following tool results orphaned.
619func normalizeToolCallInput(input string) string {
620 input = strings.TrimSpace(input)
621 if input == "" {
622 return "{}"
623 }
624
625 var object map[string]any
626 if err := json.Unmarshal([]byte(input), &object); err != nil || object == nil {
627 return "{}"
628 }
629
630 return input
631}
632
633// ExtractToolCalls returns all tool call parts as content blocks.
634func ExtractToolCalls(parts []fantasy.MessagePart) []fantasy.ToolCallContent {

Callers 1

Calls 1

UnmarshalMethod · 0.45

Tested by

no test coverage detected