Skip to content

improve tracing for openai agents #205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion openai_agents/run_customer_service_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ async def main():
# Query the workflow for the chat history
# If the workflow is not open, start a new one
start = False
history = []
try:
history = await handle.query(
CustomerServiceWorkflow.get_chat_history,
reject_condition=QueryRejectCondition.NOT_OPEN,
)
except WorkflowQueryRejectedError as e:
except WorkflowQueryRejectedError:
start = True
except RPCError as e:
if e.status == RPCStatusCode.NOT_FOUND:
Expand Down
1 change: 0 additions & 1 deletion openai_agents/run_hello_world_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from temporalio.contrib.pydantic import pydantic_data_converter

from openai_agents.workflows.hello_world_workflow import HelloWorldAgent
from openai_agents.workflows.research_bot_workflow import ResearchWorkflow


async def main():
Expand Down
2 changes: 2 additions & 0 deletions openai_agents/run_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from temporalio.contrib.openai_agents import (
ModelActivity,
ModelActivityParameters,
OpenAIAgentsTracingInterceptor,
set_open_ai_agent_temporal_overrides,
)
from temporalio.contrib.pydantic import pydantic_data_converter
Expand Down Expand Up @@ -46,6 +47,7 @@ async def main():
ModelActivity().invoke_model_activity,
get_weather,
],
interceptors=[OpenAIAgentsTracingInterceptor()],
)
await worker.run()

Expand Down
5 changes: 2 additions & 3 deletions openai_agents/workflows/research_agents/research_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

with workflow.unsafe.imports_passed_through():
# TODO: Restore progress updates
from agents import RunConfig, Runner, custom_span, gen_trace_id, trace
from agents import RunConfig, Runner, custom_span, trace

from openai_agents.workflows.research_agents.planner_agent import (
WebSearchItem,
Expand All @@ -28,8 +28,7 @@ def __init__(self):
self.writer_agent = new_writer_agent()

async def run(self, query: str) -> str:
trace_id = gen_trace_id()
with trace("Research trace", trace_id=trace_id):
with trace("Research trace"):
search_plan = await self._plan_searches(query)
search_results = await self._perform_searches(search_plan)
report = await self._write_report(query, search_results)
Expand Down
Loading