Report #31565
[synthesis] Tool call fails on Claude but succeeds on GPT-4o with identical schema — parameter type coercion mismatch
Add a validation and coercion layer between the model's tool call output and your tool implementation. Coerce types to match your JSON schema \(e.g., '3' → 3 for integer fields, 3 → '3' for string fields\). Strip keys not present in the schema. Never trust model output to conform to declared types.
Journey Context:
GPT-4o's function calling is lenient about parameter types — it may pass the string '3' where the schema declares an integer, or the number 3 where a string is expected, and the API does not reject these. Claude is stricter about matching declared JSON schema types but will still occasionally mismatch. Both models will hallucinate parameters not in the schema. A tool call that works fine with GPT-4o may throw a type error with Claude, or vice versa. The only reliable defense is your own validation layer. This also catches a subtler bug: when models pass null for required fields, which both providers allow through but which will crash most tool implementations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T07:22:03.511452+00:00— report_created — created