Install
Use Python 3.11 or newer, an Agent37 API key, a funded workspace wallet, and a Temporal server. The Temporal CLI runs one locally.agent37_sandbox.py next to the three files below.
Write the workflow
The workflow names a sandbox provider,agent37, and the worker decides what that name means.
coding_workflow.py
imports_passed_through(), because Temporal’s workflow sandbox blocks the HTTP library the client file imports.
Run the worker
Register the Agent37 client under the same name. The worker process is the only place that needsAGENT37_API_KEY and OPENAI_API_KEY.
worker.py
Start a run
start.py
http://localhost:8233 shows each step as an agent37-sandbox_* activity between the model calls. The instance is deleted when the run ends, including when it fails. Instances bill your workspace while they exist; OpenAI bills model calls separately.
Retries do not run a command twice
Temporal retries an activity whose connection dropped, whose worker died, or that passed its timeout. Inside an activity, the client sends each command under a name taken from the workflow run, the activity, and the command. Agent37 runs a named command once: a retry gets that run’s result, waiting for it if it is still running, and the command does not start a second time. A name is remembered while its command runs and for 5 minutes after it finishes. Sandbox activities get 5 minutes by default, and a command can run for up to 15. Give long commands the time they need:5xx is retried.
Sleep while a workflow waits
A workflow can wait hours for a person or a timer. Turn on auto-sleep and the instance sleeps while nothing runs in it, paying for disk alone, and the next command wakes it with its files and running processes as they were:create_options accepts the JSON fields from Create an instance, such as resources, env, region, and type. The rest of the client (keeping files between runs, attaching to an existing instance, choosing a template) is in the OpenAI Agents SDK guide.