Function Calling & JSON Schemas That Don’t Break in Agentic AI
Function Calling & JSON Schemas That Don’t Break
Why schemas matter more than prompts
Prompting can suggest structure, but schemas enforce it. When you define tool inputs with a JSON schema, you dramatically reduce “creative” malformed payloads.
Designing robust schemas
Practical tips:
- Use enums for limited choices (priority, status)
- Validate string lengths (titles, descriptions)
- Require identifiers (tenant_id, user_id) via server-side injection
- Keep optional fields truly optional
Server-side validation is non-negotiable
Even if the model “follows” the schema, always validate again on the server. Treat model outputs like untrusted user input.
Output formats
Prefer outputs like:
{"ok": true, "data": {...}, "warnings": []}Avoid returning large text blobs unless necessary.

