Back to catalog / Agent tools
Define a validated function tool for an agent
Expose a narrowly scoped application function as a tool with an explicit parameter contract.
Goal
Give an agent a tool with constrained, predictable inputs.
Steps
- State the tool’s single task and forbidden side effects first. [openai-tools]
- Expose a narrowly scoped function with
@function_toolor@tool; use Python type hints/PydanticBaseModelto generate and validate its argument schema. [openai-tools] - Use
Field(ge=..., le=...)for numeric bounds andLiteral[...]for choices; recheck business constraints at the handler boundary. [openai-tools] - Register the function only with agents that need it and document its visible description. [openai-tools]
- Check the schema and rejection behavior with valid, missing-field, and out-of-range inputs. [openai-tools]
How to verify
Confirm the generated tool schema has the intended fields and invalid inputs trigger no side effects.
Troubleshooting
If the schema is too broad, split the task into narrower tools and validate again at the function boundary.
Permissions
Prerequisites
- Python 3.10+, openai-agents compatible with the pinned revision, and authorized model-provider credentials (except local mock tests)
Permissions
- Use a local or isolated test environment; use least privilege and approval for external data or side effects
Limitations
SDK behavior varies by version. Check the pinned revision against your agent or client, then review data retention, authorization, and side effects before production use.
Pinned upstream source
- Repository
- openai/openai-agents-python
- File path
- docs/tools.md
- Pinned commit
f53c62451c7f34c15f0c87fa745e05404025420f- Source checked
- 2026-10-14 · Reviewed against the pinned upstream source
Repository metrics
These values describe the upstream repository, not popularity or likes for an individual skill or playbook.
- Stars
- Not collected
- Forks
- Not collected
- Observed at
- Not collected
No metrics snapshot is available yet.
License: MIT
Main topic
Take a coding Agent change from context to verification