CalcSnippets Search
AI Frameworks 3 min read

OpenAI Agents SDK in Python: A Real First Project Instead of Another Empty Agent Demo

A practical OpenAI Agents SDK guide that shows how to install the SDK, define an agent, run it from Python, and think about tools and supervision without turning the project into gimmicky “autonomy theater.”

The problem with most agent tutorials: they either pretend autonomy is magic or they show something so tiny that you learn nothing about the actual architecture. A useful first project should teach boundaries, tools, and supervision, not just produce a flashy screenshot.

What the Agents SDK is trying to solve

The OpenAI Agents SDK exists to give developers a cleaner way to structure agent-like workflows in code: instructions, tools, handoffs, memory-like context patterns, and execution flow. That matters because once you go beyond one prompt and one response, ordinary chat code gets messy surprisingly fast.

Install the SDK

The official Python package install is:

pip install openai-agents

Set your API key:

export OPENAI_API_KEY="your_key_here"

If you are on macOS and using zsh, put that export in ~/.zshrc for repeat use.

A simple first agent

Here is a compact starter:

from agents import Agent, Runner

agent = Agent(
    name="DevHelper",
    instructions=(
        "You help developers debug Python and web issues. "
        "Be concrete, short, and action-oriented."
    ),
)

result = Runner.run_sync(
    agent,
    "My FastAPI app starts before Postgres is ready in Docker Compose. What should I change?"
)

print(result.final_output)

That example is deliberately plain. The point is to establish the execution model first.

Add a tool the right way

Agents get interesting when they can use tools, but this is also where many demos become fake-impressive. The rule is simple: add a tool only when it removes a real manual step.

Example conceptually:

from agents import Agent, Runner, function_tool

@function_tool
def lookup_port(service: str) -> str:
    ports = {
        "postgres": "5432",
        "redis": "6379",
        "fastapi": "8000",
    }
    return ports.get(service, "unknown")

agent = Agent(
    name="InfraHelper",
    instructions="Help debug local infra issues. Use tools when needed.",
    tools=[lookup_port],
)

result = Runner.run_sync(
    agent,
    "What port should my FastAPI container expose if the service is named fastapi?"
)

print(result.final_output)

The important part is not the toy function. The important part is the architecture: the agent has instructions, the tool has a clear contract, and the developer can supervise the system.

Where people go wrong fast

They add tools with no boundaries

The wider the tool surface, the more the agent can do wrong. Tool design is a reliability decision, not just a capability decision.

They do not define success

If the agent is supposed to “help with DevOps,” that is too vague. If it is supposed to analyze a Docker Compose file and recommend a startup order fix, now you have a real task.

They confuse agent output with agent completion

An agent sounding competent is not the same thing as the workflow being safe or useful.

A better first real project

Build something bounded, like:

  1. a log triage helper
  2. a code snippet explainer
  3. a docs lookup assistant
  4. a deployment checklist generator

These are much better first projects than “build a fully autonomous software engineer.”

Why this matters now

The current AI market is pushing hard toward agents, but the teams that get value are usually the ones that keep the scope narrow, the tools explicit, and the review step cheap. That is exactly where an SDK helps: structure.

If you want your first agent project to teach something useful, do not optimize for spectacle. Optimize for a workflow where the system can do one meaningful job under human control.

Sources

Keep reading

Related guides