Summary of work
• I read the agent-sdk repository and the examples directory, and prepared clear steps to run the SDK in headless (non-interactive) mode, using GPT-5-codex, with the conversation running inside a Docker sandbox via DockerWorkspace.
How to run headless with GPT-5-codex and DockerWorkspace
1. Prerequisites
• Docker installed and daemon running.
• API key available:
◦ OpenAI direct: export OPENAI_API_KEY=...
◦ LiteLLM proxy: export LITELLM_API_KEY=... and have a proxy base_url.
2. Setup
• From repo root: make build
3. Model and environment choice
• OpenAI direct:
◦ LLM model: openai/gpt-5-codex
◦ Env: OPENAI_API_KEY
• LiteLLM proxy:
◦ LLM model: litellm_proxy/openai/gpt-5-codex
◦ Env: LITELLM_API_KEY
◦ base_url: your LiteLLM proxy URL
4. Minimal headless flow (what the script does)
• Detect platform: linux/arm64 on Apple Silicon, else linux/amd64.
• Create LLM with the GPT-5-codex model and your key.
• Start DockerWorkspace with:
◦ server_image="
ghcr.io/all-hands-ai/agent-server:latest-python"
◦ host_port=None (auto-pick)
◦ platform=detect_platform()
◦ forward_env=["OPENAI_API_KEY"] or ["LITELLM_API_KEY"]
◦ mount_dir=os.getcwd() (so files like FACTS.txt persist on your host)
◦ extra_ports=False (headless)
• Create agent via get_default_agent(llm=..., cli_mode=True) to disable browser tools.
• Create a Conversation with the workspace, send your task, run, close.
5. Running
• Put the minimal script above in a file (e.g., run_headless_docker.py) and:
◦ uv run python run_headless_docker.py
• Or run inline with a heredoc via uv run python - <<'PY' ... if preferred.
Notes and gotchas
• Headless behavior: cli_mode=True and extra_ports=False keep it non-interactive.
• Persistence: mount_dir=os.getcwd() ensures files created inside the container appear on the host.
• Platform: Apple Silicon should use linux/arm64; others linux/amd64.
• Docker must be available and running; ports must be free (auto-picked if host_port=None).
• GPT-5 family is automatically routed through the OpenAI Responses API and encrypted reasoning is enabled by the SDK, no extra config needed.
Examples suitable for this use case
• Best match: examples/02_remote_agent_server/02_convo_with_docker_sandboxed_server.py
◦ Adapt its LLM block to model="openai/gpt-5-codex" (or litellm_proxy/openai/gpt-5-codex) and forward the matching env var. This runs a DockerWorkspace conversation non-interactively.
• Equivalent pattern: examples/remote_execution_and_sandbox/2_remote_convo_with_docker_sandboxed_server.py
• GPT-5 behavior reference: examples/01_standalone_sdk/23_responses_reasoning.py
◦ Shows Responses API behavior for GPT-5 models (not Docker-based), useful for understanding how the SDK routes GPT-5.
<sub>
View full conversation</sub>