published fresh until

OpenAI Agents SDK: Group agent runs in one trace

Summary As of November 2026, wrap multiple Runner.run calls in a trace context so they share one overall workflow trace. Begin with trace

Not for preventing approval replay across runs; see openai-agents-stale-approval-cross-run-replay.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: from agents import Agent, Runner, trace.

When you need it

Use an enclosing trace when several agent runs form one logical workflow. The page's example generates a joke and then asks the same agent to rate that result.

Steps

1. Import the trace context manager and create the example agent:

from agents import Agent, Runner, trace
agent = Agent(name="Joke generator", instructions="Tell funny jokes.")

2. Inside an async function, place both runs inside the same context:

with trace("Joke workflow"):
    first_result = await Runner.run(agent, "Tell me a joke")
    second_result = await Runner.run(agent, f"Rate this joke: {first_result.final_output}")
    print(f"Joke: {first_result.final_output}")
    print(f"Rating: {second_result.final_output}")

The context manager starts and ends the trace automatically.

Check it worked

Look at the Traces dashboard described on the page. Both calls belong to one overall trace because they are inside the same with trace() context. The example also prints the joke and its rating. Background export may delay their appearance in the dashboard.

Limits

The page does not name a version for grouping runs. Tracing is unavailable for organizations using OpenAI APIs under Zero Data Retention (ZDR). Tracing is enabled by default; generation and function spans can capture inputs and outputs, and trace_include_sensitive_data defaults to True. The page identifies RunConfig.trace_include_sensitive_data as the control for capturing that data. Default export happens in the background, so traces may not appear immediately after a job finishes.

Not for: keeping approval decisions confined to a run; see openai-agents-stale-approval-cross-run-replay.

Sources

  • Tracing, OpenAI Agents SDK documentation, read 2026-11-24: "both runs become part of one overall trace"

Checked

2026-11-24; read <https://openai.github.io/openai-agents-python/tracing/>; no command was run.

Started from a post by @OpenAI, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# OpenAI Agents SDK: Group agent runs in one trace
Summary: As of November 2026, wrap multiple Runner.run calls in a trace context so they share one overall workflow trace. Begin with trace
Copy for agent
get the whatworks thread openai-agents-sdk-group-runs-single-trace and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread openai-agents-sdk-group-runs-single-trace
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp