Skip to content

Commit 939b7d9

Browse files
committed
follow openai agents examples more closely
1 parent ad15acd commit 939b7d9

File tree

4 files changed

+11
-18
lines changed

4 files changed

+11
-18
lines changed

openai_agents/workflows/agents_as_tools_workflow.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from agents import gen_trace_id
21
from agents import Agent, ItemHelpers, MessageOutputItem, RunConfig, Runner, trace
32

43
from temporalio import workflow
@@ -68,8 +67,7 @@ async def run(self, msg: str) -> str:
6867
config = RunConfig()
6968

7069
# Run the entire orchestration in a single trace
71-
trace_id = gen_trace_id()
72-
with trace("Orchestrator evaluator", trace_id=trace_id):
70+
with trace("Orchestrator evaluator"):
7371
orchestrator = orchestrator_agent()
7472
synthesizer = synthesizer_agent()
7573

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
from agents import Agent, Runner
2-
from agents import gen_trace_id, trace
32
from temporalio import workflow
43

54

65
@workflow.defn
76
class HelloWorldAgent:
87
@workflow.run
98
async def run(self, prompt: str) -> str:
10-
trace_id = gen_trace_id()
11-
with trace("Hello World", trace_id=trace_id):
12-
agent = Agent(
13-
name="Assistant",
14-
instructions="You only respond in haikus.",
15-
)
9+
agent = Agent(
10+
name="Assistant",
11+
instructions="You only respond in haikus.",
12+
)
1613

17-
result = await Runner.run(agent, input=prompt)
18-
return result.final_output
14+
result = await Runner.run(agent, input=prompt)
15+
return result.final_output

openai_agents/workflows/research_agents/research_manager.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
with workflow.unsafe.imports_passed_through():
88
# TODO: Restore progress updates
9-
from agents import RunConfig, Runner, custom_span, gen_trace_id, trace
9+
from agents import RunConfig, Runner, custom_span, trace
1010

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

3030
async def run(self, query: str) -> str:
31-
trace_id = gen_trace_id()
32-
with trace("Research", trace_id=trace_id):
31+
with trace("Research trace"):
3332
search_plan = await self._plan_searches(query)
3433
search_results = await self._perform_searches(search_plan)
3534
report = await self._write_report(query, search_results)

openai_agents/workflows/tools_workflow.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from datetime import timedelta
44

5-
from agents import gen_trace_id, trace
5+
from agents import trace
66
from agents import Agent, Runner
77
from temporalio import workflow
88
from temporalio.contrib import openai_agents as temporal_agents
@@ -14,8 +14,7 @@
1414
class ToolsWorkflow:
1515
@workflow.run
1616
async def run(self, question: str) -> str:
17-
trace_id = gen_trace_id()
18-
with trace("Activity as tool", trace_id=trace_id):
17+
with trace("Activity as tool"):
1918
agent = Agent(
2019
name="Hello world",
2120
instructions="You are a helpful agent.",

0 commit comments

Comments
 (0)