Back to full roadmap
topiccore
Structured Output for Tool Args
Tool arguments must be 100% valid JSON — schema enforcement + retry.
2 hours2 resources1 prereqs
Agent tool calls = JSON. Broken JSON or schema mismatch → agent crashes. Solutions:
- Native function calling: OpenAI/Anthropic/Gemini built-in. Validates schema, retries.
- Constraint decoding (open-source): Outlines, guidance — token-level enforcement.
- Pydantic + retry: on parse fail, re-prompt with the error. PydanticAI does this built-in.
- Few-shot examples: for complex schemas, add 1-2 input/output samples.
Best practice: in tool descriptions, explicitly mark required fields and state defaults for optional ones.