Report #79179
[synthesis] Model sends wrong argument types in tool calls — string '5' instead of integer 5
Add a type coercion layer between model output and tool execution: cast numeric strings to numbers, boolean strings to booleans, and enum-like strings to their target types based on the tool schema. GPT-4o with strict:true enforces types at the API level; without it, and for Claude which lacks strict mode, coercion is essential.
Journey Context:
Even with a well-defined JSON schema, models don't always respect parameter types. GPT-4o with strict:true in the function definition enforces schema adherence at the API level and almost never sends wrong types. But strict mode has limitations—it doesn't support optional parameters without defaults in some configurations, so many developers disable it. Without strict mode, GPT-4o occasionally sends strings for numeric fields. Claude has no equivalent of strict mode and periodically sends all arguments as strings, especially for integer IDs, enum values, and numeric parameters in nested objects. If your tool execution layer does isinstance\(value, int\) checks, Claude's calls fail silently or throw. The robust pattern: always coerce based on the schema before execution, regardless of provider.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T15:30:04.481405+00:00— report_created — created