feat(examples): OpenAI Agents SDK local-sandbox tutorials (sync + async + temporal)#377
Merged
Merged
Conversation
Sync FastACP tutorial demonstrating the OpenAI Agents SDK with a LOCAL sandbox (UnixLocalSandboxClient): a SandboxAgent with the Shell capability runs real shell commands on the host via Runner.run. Mirrors 040_pydantic_ai; tests exercise the sandbox (python version + compute). Uses openai-agents>=0.14.3 (already on next via #375). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tutorials
Companion to the sync 050 example, covering all three execution modes:
- 10_async/00_base/120: async (non-Temporal) FastACP
- 10_async/10_temporal/120: Temporal — OpenAIAgentsPlugin + SandboxClientProvider("local", UnixLocalSandboxClient()) + temporal_sandbox_client("local"); uses NoopSnapshotSpec to skip the per-turn workspace snapshot and relies on the streaming model to emit the assistant message (no double-post).
Each mirrors its family's sibling (110_pydantic_ai / 060_open_ai_agents_sdk) and has integration tests exercising the sandbox.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Expanded to cover all three execution modes, each with integration tests:
All use the OpenAI Agents SDK |
…50 test helper - New 'agentex init' template 'sync-openai-agents-local-sandbox' (registered in init.py: TemplateType enum + project_files + menu) that scaffolds an OpenAI Agents SDK agent on the local (unix_local) sandbox, based on the 050 tutorial. - Fix 050 sync test's _response_text helper to dig through TaskMessage->TextContent (it previously dropped non-str .content; verified locally the agent returns the correct answer). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Local verification (Scale LiteLLM proxy, gpt-4o-mini — the proxy serves the Responses API the OpenAI Agents SDK needs):
Also added an |
…ard, temporal instructions - Add max_turns=10 to all Runner.run calls (sync/async/temporal + template) so an agent with shell access can't loop unbounded. - LITELLM_API_KEY only sets OPENAI_API_KEY when one isn't already set (don't clobber a real key). - Temporal workflow: instructions no longer call .format(timestamp=...) (the placeholder was missing -> no-op, and datetime.now() is non-deterministic inside a Temporal workflow); use the static instructions and drop the unused import. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Addressed Greptile's review (commit
Also merged latest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
examples/tutorials/00_sync/050_openai_agents_local_sandbox/— a sync FastACP tutorial demonstrating the OpenAI Agents SDK with a LOCAL sandbox.Pattern
A
SandboxAgent(OpenAI Agents SDK) with theShellcapability runs real shell commands on the host viaRunner.run, using the built-inUnixLocalSandboxClient(backend_id="unix_local") — no Docker, Temporal, or remote infra. The SDK runs its tool-call loop internally; this sync handler returns the final answer.Structure
Mirrors
040_pydantic_ai:project/{acp,agent,tools}.py,manifest.yaml,Dockerfile,pyproject.toml,README.md, andtests/test_agent.py(exercises the sandbox: realpython3 --version+ a compute).set_tracing_disabled(True)+OPENAI_AGENTS_DISABLE_TRACING=1to avoid api.openai.com tracing 401s behind a gateway.Uses
openai-agents>=0.14.3(now onnextvia #375).Refs: https://developers.openai.com/api/docs/guides/agents , https://openai.com/index/the-next-evolution-of-the-agents-sdk/
🤖 Generated with Claude Code
Greptile Summary
Adds three new tutorial variants — sync, async-base, and Temporal — that demonstrate running an OpenAI Agents SDK
SandboxAgentwith theUnixLocalSandboxClientlocal sandbox. Each variant ships a complete project (acp.py,agent.py,tools.py),manifest.yaml,Dockerfile, and integration tests; a newsync-openai-agents-local-sandboxCLI template is also registered ininit.py.Shell-capableSandboxAgentviaRunner.runwithmax_turns=10; multi-turn memory for the async variant is persisted throughadk.state.SandboxClientProviderso shell tool calls execute as durable Temporal activities, usingTemporalStreamingModelProviderandContextInterceptorfor real-time streaming.acp.pyand Temporalworkflow.pyregister the SGP tracing processor unconditionally (even whenSGP_API_KEY/SGP_ACCOUNT_IDare empty), unlike the guarded pattern used in the sync variant and the CLI template.Confidence Score: 5/5
Safe to merge; all changes are additive tutorial examples and a new CLI template with no modifications to core library code.
The change is purely additive — new example directories and a template scaffold. Core SDK and library code is untouched. The two tracing-guard inconsistencies and the wrong return-type annotation are cosmetic/style issues that don't affect runtime correctness in typical deployments.
examples/tutorials/10_async/00_base/120_openai_agents_local_sandbox/project/acp.py and examples/tutorials/10_async/10_temporal/120_openai_agents_local_sandbox/project/workflow.py — unconditional SGP tracing registration should be guarded the same way the sync tutorial does it.
Important Files Changed
max_turns=10limit; correctly disables SDK tracing and constructs RunConfig with local Unix sandbox.-> "Runner"is wrong (returns RunResult, not a Runner); otherwise functionally correct with max_turns=10.Sequence Diagram
sequenceDiagram participant User participant FastACP participant RunAgent participant OpenAIAgentsSDK as OpenAI Agents SDK (Runner.run) participant UnixLocalSandbox as UnixLocalSandboxClient User->>FastACP: send_message / task_event_send FastACP->>RunAgent: run_agent(user_message / input_list) RunAgent->>OpenAIAgentsSDK: "Runner.run(agent, input, run_config, max_turns=10)" loop Tool-call loop (max 10 turns) OpenAIAgentsSDK->>UnixLocalSandbox: execute shell command UnixLocalSandbox-->>OpenAIAgentsSDK: stdout / stderr end OpenAIAgentsSDK-->>RunAgent: RunResult (final_output) RunAgent-->>FastACP: final text FastACP-->>User: TextContent responsePrompt To Fix All With AI
Reviews (3): Last reviewed commit: "Merge remote-tracking branch 'origin/nex..." | Re-trigger Greptile