Introduction
In Lesson 1.1, we introduced a simple agent built with the OpenAI Agents SDK. Now let’s look at how its parts fit together.
Our Product Strategy Research Agent is a small Python application built using the OpenAI Agents SDK. Although the script is relatively simple, it introduces the essential components of an agent-based application.
We’ll examine four parts:
- Agent configuration: What the agent is intended to do and how it should behave.
- Task input: The specific question or objective assigned to the agent.
- Execution: How the Runner coordinates the model’s work.
- Output: How the application receives and displays the result.
1. Configuring the Agent
An agent begins with a configuration.
In our Lab 1 code, we create an agent using the Agent class:
agent = Agent(
name="Product Strategy Research Agent",
instructions="""...""",
)
The name identifies the agent. The instructions establish how it should approach its work.
Our Research Agent’s instructions contain several important elements.
| Element | How it appears in Lab 1 |
|---|---|
| Identity and purpose | A research analyst specializing in product management, AI, software development, and organizational strategy |
| Analytical approach | Restate hypotheses, identify assumptions, examine arguments, consider alternatives, and identify evidence needed |
| Research principles | Remain objective, distinguish hypotheses from verified facts, and challenge assumptions |
| Behavioral constraints | Do not invent research, statistics, or citations; do not treat proposed trends as established facts |
| Writing style | Use clear, professional language, meaningful headings, and accessible explanations |
These elements work together.
The purpose describes the kind of work the agent is expected to perform. The analytical approach tells it how to investigate a question. The research principles and behavioral constraints guide how it handles uncertainty. The writing style shapes how it communicates its findings.
Instructions are not guarantees
Our instructions tell the agent not to invent evidence or present hypotheses as verified facts.
These are prompt-level behavioral constraints. They influence the model’s behavior, but they do not independently verify its claims or guarantee compliance.
Later in the course, we’ll explore additional checks and controls that can help enforce requirements more reliably.
2. Defining the Task
Once the agent is configured, we need to give it something to work on.
In Lab 1, the task is stored in a Python variable called question.
question = """
Analyze the following emerging hypothesis:
Recent advances in AI coding agents ...
may be creating a divergence in the
Product Manager role.
...
"""
The full task describes a hypothesis about how AI coding tools may change product management roles.
It asks the agent to investigate whether two different approaches may be emerging: Strategy PMs, who concentrate on product strategy and organizational decisions, and Builder PMs, who use AI coding tools to take a more hands-on role in software development.
The task also contains nine research objectives. These include examining alternative explanations, evaluating risks, distinguishing prototyping from production development, and identifying evidence needed to test the hypothesis.
Purpose versus task
This is an important distinction.
The agent configuration describes its continuing purpose and expected behavior. The task input describes what it should accomplish in this particular run.
We could give the same Research Agent a different hypothesis tomorrow without rewriting its standing instructions.
The configuration would remain the same, but the task and resulting analysis would change.
Diagram 1 — Anatomy of our Research Agent
Agent configuration
Agent(name=..., instructions=...)Task input
questionRunner
Runner.run_sync(agent, question)Application output
print(result.final_output)lab1_agent.py.Two inputs feed the Runner. The agent configuration, created with Agent(name=..., instructions=...), defines the agent's purpose, analytical approach, research principles, behavioral constraints, and writing style. The task input, the question variable, provides the Builder PM hypothesis and research objectives. The Runner, called with Runner.run_sync(agent, question), produces a result, which the application output displays with print(result.final_output).
This first diagram describes what we configure and how the code is organized. It does not yet explain what happens internally when the agent runs.
3. Running the Agent
Configuring an agent does not automatically execute it.
In Lab 1, execution begins with:
result = Runner.run_sync(agent, question)
This statement passes two things to the Runner:
agent: The configured Research Agent.question: The specific task we want it to perform.
The Runner is part of the OpenAI Agents SDK. It coordinates execution using the agent’s configuration and the supplied task.
In our first lab, the execution is straightforward:
- The Runner starts the agent’s execution.
- The SDK sends the relevant instructions and task input to the language model.
- The model generates an analysis.
- The Runner receives the response and returns a result to the Python application.
The language model generates the analysis. The Runner manages the execution process.
The run_sync() method is synchronous: the Python application waits for the run to finish before proceeding to the next statement.
Diagram 2 — What happens when the agent runs?
Python Application
Supplies the agent and task, and displays the final output.
Runner
Coordinates execution, sends the model request, receives the response, and returns the result.
Language Model
Generates the analysis.
Simplified execution flow for Lab 1, which has no external tools. Three components take part: the Python application, the Runner, and the language model. Step 1: the application passes the agent configuration and task to the Runner. Step 2: the Runner sends a model request to the language model. Step 3: the language model returns a model response to the Runner. Step 4: the Runner returns the final result to the application.
In this diagram, the model appears within the Runner’s execution process to show their relationship. The model is not literally contained inside the Runner. The SDK coordinates the model call.
In later modules, we’ll extend this execution flow. The agent will be able to use tools, receive their results, and continue working before returning its final answer.
Our Lab 1 agent has no external tools, so it cannot independently search for current evidence.
4. Understanding the Output
After the Runner finishes, it returns a result object.
Our application accesses the final response using:
print(result.final_output)
Here, result.final_output contains the agent’s final output from the run.
The print() function displays that output in the terminal.
In Lab 1, we expect an analysis of the product management hypothesis, including assumptions, competing explanations, limitations, evidence requirements, and proposed research questions.
However, the output is model-generated analysis, not independently verified research.
The fact that an agent has completed its execution does not establish that its conclusions are correct.
We’ll examine this distinction more closely in Lesson 1.4.
5. Putting It Together
Our first agent application can be summarized in a few lines:
from agents import Agent, Runner
agent = Agent(
name="Product Strategy Research Agent",
instructions="""...""",
)
question = """..."""
result = Runner.run_sync(agent, question)
print(result.final_output)
This shortened example shows the structure of the application, not the full Lab 1 script.
The complete code includes detailed instructions and research objectives. We’ll work with that code in Lesson 1.3.
Notice that the application itself is responsible for creating the agent, supplying the task, initiating execution, and using the returned result.
The agent configuration guides the model’s behavior, while the Runner coordinates the work.
Key Takeaways
- Agent configuration establishes the agent’s identity, purpose, instructions, and expected behavior.
- Task input defines the particular assignment for an execution.
- Runner coordinates execution and interaction with the language model.
- The language model generates the analysis using the instructions and task it receives.
- The application receives the result and decides how to use it.
- Prompt-level rules can guide behavior, but they do not guarantee accuracy or independently enforce requirements.
Reflection
Suppose we want to use the same Research Agent to investigate a different hypothesis, such as whether AI agents will change how enterprise software is purchased.
Which parts of our Lab 1 code would need to change, and which could remain the same?
Consider the difference between changing the agent’s purpose and assigning it a new research task.
Test Your Understanding
Question 1 of 3
How does the agent configuration differ from the task input?