Agent Wealth HubFree public resources
中文 EN العربية

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

  1. State the tool’s single task and forbidden side effects first. [openai-tools]
  2. Expose a narrowly scoped function with @function_tool or @tool; use Python type hints/Pydantic BaseModel to generate and validate its argument schema. [openai-tools]
  3. Use Field(ge=..., le=...) for numeric bounds and Literal[...] for choices; recheck business constraints at the handler boundary. [openai-tools]
  4. Register the function only with agents that need it and document its visible description. [openai-tools]
  5. 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

Permissions

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

https://github.com/openai/openai-agents-python/blob/f53c62451c7f34c15f0c87fa745e05404025420f/docs/tools.md

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

Related resources