We shifted our project to Agents SDK but the tracing is not working correctly. The trace of the last agent is not showing completely.
Issue Description
The trace of the last agent is not showing completely when using the OpenAI Agents SDK for a multi-agent workflow. As shown in your screenshot, the traces appear to be incomplete for the final agent in the sequence.
Environment Details
-
FastAPI web framework
-
openai-agents 0.0.8 SDK version
-
Python version: (Include your Python version)
-
OS: macOS (darwin 23.6.0)
Tracing Setup
from agents import set_tracing_export_api_key, trace
# Setting the API key for tracing
set_tracing_export_api_key("sk-proj-xxx...")
# Using the trace context manager
with trace(f"{ticket_record_id}"):
# Agent execution code
qe_output = await Runner.run(question_extractor, "work on the issue of the customer")
l1_response_generation_output = await Runner.run(l1_support_agent, qe_output.final_output)
l1_email_generation_output = await Runner.run(l1_email_writer, l1_response_generation_output.final_output)
Agent Workflow
Our implementation consists of multiple agents that run in sequence:
-
Question Extracting Agent: Analyzes customer interactions and extracts key information
-
L1 Support Agent: Processes the extracted questions and generates responses
-
L1 Email Writer: Takes the responses and formats them into an email
The trace for the last agent (L1 Email Writer) is not showing completely, as indicated in your screenshot.
Steps to Reproduce
-
Set up a multi-agent workflow using the OpenAI Agents SDK
-
Configure tracing with set_tracing_export_api_key
-
Use the trace context manager to wrap multiple sequential Runner.run() calls
-
Observe that the trace for the last agent is incomplete
Additional Context
-
We moved from a previous framework to the OpenAI Agents SDK recently
-
The tracing works for earlier agents in the sequence but fails to completely trace the last agent
-
Our application uses Redis queues for task processing
Previous Workarounds Attempted
- Tried using other functions instead of Runner.run
run_sync won’t work well since we’re using FastAPI as mentioned in the documentation as well. - run_streamed is not working for us. Gives Empty response.
- Tried running agents SDK on a small project, faced the same issue.
- Tried using
trace.start()
+trace.finish()
but it showed error
Importance/Impact
The incomplete tracing prevents proper debugging and monitoring of the complete agent workflow, especially for the final email generation step which is critical for customer communication.