Skip to content

Update samples for 1.15 #220

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 7 commits into from
Jul 29, 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
6 changes: 4 additions & 2 deletions openai_agents/run_agents_as_tools_workflow.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio

from temporalio.client import Client
from temporalio.contrib.pydantic import pydantic_data_converter
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin

from openai_agents.workflows.agents_as_tools_workflow import AgentsAsToolsWorkflow

Expand All @@ -10,7 +10,9 @@ async def main():
# Create client connected to server at the given address
client = await Client.connect(
"localhost:7233",
data_converter=pydantic_data_converter,
plugins=[
OpenAIAgentsPlugin(),
],
)

# Execute a workflow
Expand Down
6 changes: 4 additions & 2 deletions openai_agents/run_customer_service_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
WorkflowUpdateFailedError,
)
from temporalio.common import QueryRejectCondition
from temporalio.contrib.pydantic import pydantic_data_converter
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
from temporalio.service import RPCError, RPCStatusCode

from openai_agents.workflows.customer_service_workflow import (
Expand All @@ -24,7 +24,9 @@ async def main():
# Create client connected to server at the given address
client = await Client.connect(
"localhost:7233",
data_converter=pydantic_data_converter,
plugins=[
OpenAIAgentsPlugin(),
],
)

handle = client.get_workflow_handle(args.conversation_id)
Expand Down
6 changes: 4 additions & 2 deletions openai_agents/run_hello_world_workflow.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio

from temporalio.client import Client
from temporalio.contrib.pydantic import pydantic_data_converter
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin

from openai_agents.workflows.hello_world_workflow import HelloWorldAgent

Expand All @@ -10,7 +10,9 @@ async def main():
# Create client connected to server at the given address
client = await Client.connect(
"localhost:7233",
data_converter=pydantic_data_converter,
plugins=[
OpenAIAgentsPlugin(),
],
)

# Execute a workflow
Expand Down
6 changes: 4 additions & 2 deletions openai_agents/run_research_workflow.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio

from temporalio.client import Client
from temporalio.contrib.pydantic import pydantic_data_converter
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin

from openai_agents.workflows.research_bot_workflow import ResearchWorkflow

Expand All @@ -10,7 +10,9 @@ async def main():
# Create client connected to server at the given address
client = await Client.connect(
"localhost:7233",
data_converter=pydantic_data_converter,
plugins=[
OpenAIAgentsPlugin(),
],
)

# Execute a workflow
Expand Down
6 changes: 4 additions & 2 deletions openai_agents/run_tools_workflow.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio

from temporalio.client import Client
from temporalio.contrib.pydantic import pydantic_data_converter
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin

from openai_agents.workflows.tools_workflow import ToolsWorkflow

Expand All @@ -10,7 +10,9 @@ async def main():
# Create client connected to server at the given address
client = await Client.connect(
"localhost:7233",
data_converter=pydantic_data_converter,
plugins=[
OpenAIAgentsPlugin(),
],
)

# Execute a workflow
Expand Down
63 changes: 28 additions & 35 deletions openai_agents/run_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
from datetime import timedelta

from temporalio.client import Client
from temporalio.contrib.openai_agents import (
ModelActivity,
ModelActivityParameters,
OpenAIAgentsTracingInterceptor,
set_open_ai_agent_temporal_overrides,
)
from temporalio.contrib.pydantic import pydantic_data_converter
from temporalio.contrib.openai_agents import ModelActivityParameters, OpenAIAgentsPlugin
from temporalio.worker import Worker

from openai_agents.workflows.agents_as_tools_workflow import AgentsAsToolsWorkflow
Expand All @@ -22,34 +16,33 @@


async def main():
with set_open_ai_agent_temporal_overrides(
model_params=ModelActivityParameters(
start_to_close_timeout=timedelta(seconds=60),
),
):
# Create client connected to server at the given address
client = await Client.connect(
"localhost:7233",
data_converter=pydantic_data_converter,
)

worker = Worker(
client,
task_queue="openai-agents-task-queue",
workflows=[
HelloWorldAgent,
ToolsWorkflow,
ResearchWorkflow,
CustomerServiceWorkflow,
AgentsAsToolsWorkflow,
],
activities=[
ModelActivity().invoke_model_activity,
get_weather,
],
interceptors=[OpenAIAgentsTracingInterceptor()],
)
await worker.run()
# Create client connected to server at the given address
client = await Client.connect(
"localhost:7233",
plugins=[
OpenAIAgentsPlugin(
model_params=ModelActivityParameters(
start_to_close_timeout=timedelta(seconds=120)
)
),
],
)

worker = Worker(
client,
task_queue="openai-agents-task-queue",
workflows=[
HelloWorldAgent,
ToolsWorkflow,
ResearchWorkflow,
CustomerServiceWorkflow,
AgentsAsToolsWorkflow,
],
activities=[
get_weather,
],
)
await worker.run()


if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = [{ name = "Temporal Technologies Inc", email = "sdk@temporal.io" }]
requires-python = ">=3.10"
readme = "README.md"
license = "MIT"
dependencies = ["temporalio>=1.14.1,<2"]
dependencies = ["temporalio>=1.15.0,<2"]

[project.urls]
Homepage = "https://github.com/temporalio/samples-python"
Expand Down Expand Up @@ -55,8 +55,8 @@ open-telemetry = [
"opentelemetry-exporter-otlp-proto-grpc",
]
openai-agents = [
"openai-agents >= 0.0.19",
"temporalio[openai-agents] >= 1.14.1",
"openai-agents[litellm] >= 0.2.3",
"temporalio[openai-agents] >= 1.15.0",
]
pydantic-converter = ["pydantic>=2.10.6,<3"]
sentry = ["sentry-sdk>=1.11.0,<2"]
Expand Down
Loading
Loading