Skip to content

Commit efdfe28

Browse files
brianstrauchclaude
andcommitted
Add a sandbox sample and snipsync markers for the docs guide
The Python OpenAI Agents SDK integration guide on docs.temporal.io currently sends readers to the SDK contrib README. Give it code to pull from here instead. Adds openai_agents/sandbox, covering SandboxAgent through the plugin. It uses UnixLocalSandboxClient, so it runs with only OPENAI_API_KEY and no sandbox account — at the cost of giving the agent a shell on the worker host, which the README calls out. Note the class lives in agents.sandbox.sandboxes.unix_local, not the agents.extensions.sandbox.unix_local path the contrib README shows. Adds snipsync markers to the samples that guide walks through, scoped to exactly the code it shows so no block needs selectedLines. Markers around indented code sit at that code's indent level, keeping snipsync's dedent working (see #346). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 05070f6 commit efdfe28

22 files changed

Lines changed: 265 additions & 0 deletions

‎openai_agents/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ Each directory contains a complete example with its own README for detailed inst
3939
- **[Customer Service](./customer_service/README.md)** - Interactive customer service agent with escalation capabilities, demonstrating conversational workflows.
4040
- **[Reasoning Content](./reasoning_content/README.md)** - Example of how to retrieve the thought process of reasoning models.
4141
- **[Financial Research Agent](./financial_research_agent/README.md)** - Multi-agent financial research system with planner, search, analyst, writer, and verifier agents collaborating.
42+
- **[Sandbox](./sandbox/README.md)** - `SandboxAgent` with a shell and filesystem, where every sandbox operation runs as a Temporal activity. **Pre-release.**
4243
- **[Streaming](./streaming/README.md)** - `Runner.run_streamed` with buffered token streaming to external subscribers via `temporalio.contrib.workflow_streams`. **Experimental.**

‎openai_agents/agent_patterns/workflows/agents_as_tools_workflow.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99

1010

11+
# @@@SNIPSTART python-openai-agents-agent-as-tool-workflow
1112
def orchestrator_agent() -> Agent:
1213
spanish_agent = Agent(
1314
name="spanish_agent",
@@ -52,6 +53,9 @@ def orchestrator_agent() -> Agent:
5253
return orchestrator_agent
5354

5455

56+
# @@@SNIPEND
57+
58+
5559
def synthesizer_agent() -> Agent:
5660
return Agent(
5761
name="synthesizer_agent",

‎openai_agents/basic/activities/get_weather_activity.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# @@@SNIPSTART python-openai-agents-weather-activity
12
from dataclasses import dataclass
23

34
from temporalio import activity
@@ -16,3 +17,6 @@ async def get_weather(city: str) -> Weather:
1617
Get the weather for a given city.
1718
"""
1819
return Weather(city=city, temperature_range="14-20C", conditions="Sunny with wind.")
20+
21+
22+
# @@@SNIPEND

‎openai_agents/basic/run_hello_world_workflow.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
async def main():
1010
# Create client connected to server at the given address
11+
# @@@SNIPSTART python-openai-agents-hello-world-client
1112
client = await Client.connect(
1213
"localhost:7233",
1314
plugins=[
@@ -23,6 +24,7 @@ async def main():
2324
task_queue="openai-agents-basic-task-queue",
2425
)
2526
print(f"Result: {result}")
27+
# @@@SNIPEND
2628

2729

2830
if __name__ == "__main__":

‎openai_agents/basic/run_worker.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
async def main():
3636
# Create client connected to server at the given address
37+
# @@@SNIPSTART python-openai-agents-hello-world-worker
3738
client = await Client.connect(
3839
"localhost:7233",
3940
plugins=[
@@ -44,6 +45,7 @@ async def main():
4445
),
4546
],
4647
)
48+
# @@@SNIPEND
4749

4850
worker = Worker(
4951
client,

‎openai_agents/basic/workflows/hello_world_workflow.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# @@@SNIPSTART python-openai-agents-hello-world-workflow
12
from agents import Agent, Runner
23
from temporalio import workflow
34

@@ -13,3 +14,6 @@ async def run(self, prompt: str) -> str:
1314

1415
result = await Runner.run(agent, input=prompt)
1516
return result.final_output
17+
18+
19+
# @@@SNIPEND

‎openai_agents/basic/workflows/tools_workflow.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from openai_agents.basic.activities.get_weather_activity import get_weather
1010

1111

12+
# @@@SNIPSTART python-openai-agents-activity-tool-workflow
1213
@workflow.defn
1314
class ToolsWorkflow:
1415
@workflow.run
@@ -25,3 +26,6 @@ async def run(self, question: str) -> str:
2526

2627
result = await Runner.run(agent, input=question)
2728
return result.final_output
29+
30+
31+
# @@@SNIPEND

‎openai_agents/customer_service/workflows/customer_service_workflow.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def __init__(
5656
customer_service_state.input_items if customer_service_state else []
5757
)
5858

59+
# @@@SNIPSTART python-openai-agents-continue-as-new-workflow
5960
@workflow.run
6061
async def run(
6162
self, customer_service_state: CustomerServiceWorkflowState | None = None
@@ -73,6 +74,8 @@ async def run(
7374
)
7475
)
7576

77+
# @@@SNIPEND
78+
7679
@workflow.query
7780
def get_chat_history(self) -> list[str]:
7881
return self.printed_history

‎openai_agents/hosted_mcp/workflows/approval_mcp_workflow.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from temporalio import workflow
1111

1212

13+
# @@@SNIPSTART python-openai-agents-hosted-mcp-approval-workflow
1314
def approval_callback(request: MCPToolApprovalRequest) -> MCPToolApprovalFunctionResult:
1415
"""Simple approval callback that logs the request and approves by default.
1516
@@ -23,6 +24,9 @@ def approval_callback(request: MCPToolApprovalRequest) -> MCPToolApprovalFunctio
2324
return result
2425

2526

27+
# @@@SNIPEND
28+
29+
2630
@workflow.defn
2731
class ApprovalMCPWorkflow:
2832
@workflow.run

‎openai_agents/hosted_mcp/workflows/simple_mcp_workflow.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from temporalio import workflow
55

66

7+
# @@@SNIPSTART python-openai-agents-hosted-mcp-workflow
78
@workflow.defn
89
class SimpleMCPWorkflow:
910
@workflow.run
@@ -26,3 +27,6 @@ async def run(
2627

2728
result = await Runner.run(agent, question)
2829
return result.final_output
30+
31+
32+
# @@@SNIPEND

0 commit comments

Comments
 (0)