Task progression in SDK-managed agents

As agents move beyond single responses, they need a way to carry work forward over time. In the Agents SDK, this shows up as task progression: the ability for an agent to move through a goal in steps, remember where it is, and keep reasoning and acting until the task is done. This lesson exists to orient us to how the SDK supports that kind of structured, multi-step work.

Representing a task in an SDK-managed agent

In the SDK, a task is usually represented as a goal plus some evolving state. The goal describes what should be achieved, while the state captures what has already happened and what remains.

Rather than writing our own task objects and control loops, we describe the task through agent instructions and structured inputs. The SDK keeps track of the conversation and uses it as the backbone of the task’s representation.

from openai import OpenAI
from openai.agents import Agent

client = OpenAI()

agent = Agent(
    name="SiteBuilder",
    instructions=(
        "Build HTML pages for planets in the solar system. "
        "Work step by step and finish only when all pages are written."
    ),
)

At this point, the task exists as an intention held by the agent, not as a custom data structure we manage ourselves.

Progressing through a task over multiple steps

Task progression happens as the agent is invoked repeatedly. Each invocation moves the task forward by reasoning about what to do next, given what has already occurred.

We do not manually advance a step counter. Instead, we provide new input or context, and the SDK incorporates it into the ongoing task.

result = agent.run(
    input="Generate the next planet page."
)

Each call builds on prior interactions. The SDK ensures that earlier decisions and outputs remain available to the agent as it continues working.

Using SDK mechanisms to track task state

The SDK tracks task state implicitly through managed conversation history and internal bookkeeping. From our perspective, state is something we inspect and influence, not something we fully control.

We can examine the agent’s outputs to see what progress has been made and decide whether to continue invoking it.

for message in result.messages:
    print(message.content)

This gives us visibility into how the task is evolving without requiring us to store or replay intermediate steps ourselves.

Coordinating reasoning and action across steps

Within each step, the agent reasons about the task and may decide to act by invoking tools. The SDK coordinates this automatically, presenting tool results back to the agent so it can plan the next move.

Reasoning and action are not separate phases we wire together. They are part of a single, SDK-managed cycle that repeats as the task progresses.

result = agent.run(
    input="Continue until all planet pages are complete."
)

Each iteration tightens the loop between thinking and doing, while we remain focused on high-level intent.

Completing a task using SDK-managed control flow

A task is complete when the agent determines that the goal has been satisfied. The SDK does not force a fixed number of steps or a predefined endpoint.

Instead, completion emerges from the agent’s reasoning, guided by our instructions and the accumulated task state.

if "all pages written" in result.final_output.lower():
    print("Task complete.")

At this point, we can stop invoking the agent, confident that the SDK-managed workflow has reached a natural conclusion.

Conclusion

The Agents SDK gives us a structured way to think about tasks that unfold over time. By representing goals as instructions, progressing through repeated invocations, and relying on the SDK to track state and coordinate reasoning with action, we gain multi-step behavior without writing our own workflow engine. We are now oriented to how task progression works inside SDK-managed agents.