Report #14193
[agent\_craft] Function calling fails with 'Invalid schema' or 'trailing comma' error when defining tools
Validate JSON schema with strict mode before sending; use JSON.stringify\(\) or json.dumps\(\) with ensure\_ascii=False; programmatically strip comments and trailing commas from OpenAPI specs before injection.
Journey Context:
Many developers copy-paste OpenAPI specs or hand-write JSON schemas with trailing commas or comments \(// description\). OpenAI's strict mode and Anthropic's tool use require strict RFC 8259 JSON. The error appears cryptic: 'Invalid schema'. Common mistake: Python multiline strings with trailing commas on the last item. Alternative: Use YAML-to-JSON conversion, but adds dependency overhead. Why this: Schema validation happens at the API gateway before the model sees it; it's a hard stop that looks like model failure but is actually client-side formatting.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:51:16.414141+00:00— report_created — created