The function_tool decorator turns an ordinary internal function into an agent-callable tool. It handles the integration plumbing and generates the structured JSON description an agent uses when deciding whether and how to call it. section 2.4.1
Unlike a normal function call, a decorated function becomes part of the agent’s tool interface: its description is supplied to the language model on every call, whether the agent uses the tool or not. section 2.4.1
Expose a research-source function
@function_tool def get_research_sources() -> list[str]: """Provides a list of available research sources.""" return ["internal reports", "public datasets", "technical papers"] Registering this function lets an agent retrieve sources before creating a research plan. A more practical implementation could query available resources dynamically. section 2.4.1
Design decorated tools with these constraints in mind:
- Keep tools distinct and clearly described so the agent can choose among them reliably. section 2.4.1
- Account for token and prompt overhead because every registered JSON description travels with every language-model call. section 2.4.1
- Handle failures explicitly because each additional tool creates another possible failure point. section 2.4.1 section 9.5
