Registering functions as tools
As agents become capable of taking actions, we need a clear way to expose those actions to the agent runtime. In the OpenAI Agents SDK, actions are represented as tools. This lesson exists to show how ordinary Python functions are turned into tools that an SDK-managed agent can discover and use while it is running.
The goal is not to master the SDK’s full tool system, but to understand how your own code becomes executable capability inside an agent.
What a tool represents in the Agents SDK
In the SDK, a tool represents something the agent can do, not something it can reason about internally. Tools usually involve side effects, such as reading files, generating output, or querying external systems.
From a Python perspective, a tool starts life as a normal function. What changes is how that function is described and exposed so the agent knows when it is allowed to use it.
Defining a Python function as a tool
A tool is defined using a regular Python function with a clear purpose and well-defined inputs and outputs. Simplicity matters here, because the agent must be able to reason about what the function does.
def render_planet_page(name: str, radius_km: int) -> str:
return f"<h1>{name}</h1><p>Radius: {radius_km} km</p>"
This function already has the key properties of a tool: explicit inputs, a single responsibility, and a predictable result.
Declaring tool inputs and outputs
For the SDK, function signatures are more than documentation. They describe how the agent can supply arguments and what kind of result it should expect.
Type hints are used to declare inputs and outputs in a structured way. This makes the tool understandable to both the SDK and the model that selects it.
def render_planet_page(name: str, radius_km: int) -> str:
...
The SDK uses this information to construct a machine-readable description of the tool.
Registering tools with an agent
Defining a function is not enough. The function must be registered with an agent so the SDK knows it is available.
from openai import Agent
agent = Agent(
name="site_builder",
tools=[render_planet_page]
)
Registration is an explicit step. Only registered tools can be selected and invoked during agent execution.
Making tools discoverable to the agent
Once registered, tools become part of the agent’s declared capabilities. The SDK presents these tools to the model in a structured format, based on the function signature and metadata.
From this point on, the agent can reason about when a tool is useful, even though it does not see the function’s internal implementation.
Conclusion
At this point, we know what a tool represents in the Agents SDK and how a plain Python function becomes an executable capability. We have seen how inputs and outputs are declared, how tools are registered, and how they are made discoverable to an agent.
That orientation is enough to recognize how your own code fits into the SDK’s tool system and prepares us to understand how tools are selected and invoked at runtime.