Report #82331
[synthesis] Type errors in downstream code from inconsistent null handling in optional tool parameters
Design downstream tool execution logic to handle both missing keys and null values identically. For Gemini, add an explicit instruction in the system prompt: 'If an optional parameter is not needed, omit the key entirely. Do not output the string null or None.'
Journey Context:
Standard JSON allows omitting optional keys or setting them to null. GPT-4o prefers omission. Claude prefers explicit nulls. Gemini sometimes confuses the Python concept of None with JSON null, outputting strings. If downstream code strictly checks for null it will fail if the key is omitted \(KeyError\), and if it checks for key existence, it will fail if it is null. The cross-model diff shows that you cannot rely on standard JSON optional behavior; you must normalize the parsed dictionary \(e.g., dict.pop\('key', None\)\) and explicitly constrain Gemini's string representations of null.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T20:47:13.073965+00:00— report_created — created