Creating a minimal agent with the SDK

At this point in the syllabus, we have already built agents by hand. We have loops, state, tools, and decision logic working together in code we control directly. This lesson exists to show how the OpenAI Agents SDK lets us express the same idea more compactly, using a structured runtime instead of custom scaffolding.

The goal here is not power or flexibility. It is orientation. We want to see the smallest possible agent defined with the SDK, understand what defaults it adopts, and confirm that it can be invoked successfully from code.

Defining an agent using the SDK

In the SDK, an agent is defined declaratively. Instead of writing a loop, we describe the agent’s role and let the SDK manage execution.

A minimal agent definition typically specifies a model and a set of instructions. Everything else is optional at this stage.

from openai import OpenAI
from openai.agents import Agent

client = OpenAI()

agent = Agent(
    name="planet_helper",
    instructions="Answer questions about planets in the solar system."
)

This definition does not include tools, memory configuration, or workflows. It is enough to create an agent that can respond to input using the underlying model.

Supplying the minimum required configuration

The SDK provides sensible defaults so that an agent can exist with very little configuration. If we do not specify a model explicitly, the SDK selects a default model suitable for general reasoning.

Instructions are the key required input. They establish what the agent is for and how it should behave at a high level.

At this stage, we avoid dynamic context, state injection, or runtime inputs. The goal is simply to define something that the SDK recognizes as a valid agent.

Understanding the agent’s default behavior

A minimal agent behaves like a constrained conversational model. It reads the instructions, accepts input, and produces a response guided by those instructions.

There is no memory persistence beyond the current invocation. There are no tools to call. There is no multi-step workflow. The SDK handles prompt construction, model invocation, and response handling automatically.

This default behavior mirrors the simplest possible agent loop: receive input, reason once, respond.

Creating an agent instance in code

Once defined, the agent exists as a regular Python object. We can store it, pass it around, or register it with other parts of a program.

The agent itself does not run until it is invoked. Defining an agent is separate from executing it, which makes it easier to reason about setup versus runtime behavior.

This separation becomes more important as agents grow more complex.

Verifying that the agent can be invoked successfully

To confirm that the agent works, we invoke it with a simple input and inspect the response.

result = agent.run("What is Mars?")
print(result.output_text)

This call hands control to the SDK. The SDK prepares the request, sends it to the model, and returns a structured result.

If this produces a sensible response, we know the agent is correctly defined, configured, and executable. From here, we can begin adding instructions, context, tools, and memory in later lessons.

Conclusion

We now have a concrete starting point: a minimal agent defined using the OpenAI Agents SDK. It has a clear purpose, relies on default behavior, and can be invoked successfully from Python code.

That is enough to be oriented. We understand what the smallest SDK-based agent looks like and where responsibility shifts from our code to the SDK. From this foundation, we can begin shaping agent behavior more deliberately.