langchain-agent37. Your application runs the agent loop and calls your model provider. Agent37 runs its commands and stores its files in a persistent instance.
The package implements Deep Agents’ sandbox backend over the public Agent37 REST API. It works with the plain agent37-base template; you do not need an agent harness or the Agent API inside the instance.
Install and run
Use Python 3.11 or newer, an Agent37 API key, and a funded workspace wallet. This example uses your own OpenAI key for the model.await agent.ainvoke(...); async backend methods use worker threads.
Commands and files
/workspace by default. Each command starts a fresh shell; files persist, but shell variables and cd do not. Upload and download paths must be absolute. Transfers support binary files and report errors per file.
The default command timeout is 120 seconds. Set timeout on the constructor or call sandbox.execute(command, timeout=300). Values range from 1 to 840 seconds. A command that reaches its deadline is terminated and returns exit code 124, or 137 if it must be force-killed.
HTTP failures raise httpx.HTTPError. The package does not retry commands: after a network failure, a command might still be running.
Keep files between runs
close() releases HTTP connections without deleting the instance. A context manager that attaches to an existing instance also leaves it running. Call sandbox.destroy() when you want to delete an instance, including one you attached to. Deep Agents’ sandbox.delete(path) deletes a file instead.
Attached instances must be running or sleeping. Exec wakes a sleeping instance automatically. Start a stopped instance before using the backend.
Choose resources and a template
create_options accepts the JSON fields from Create an instance. Custom templates need Python 3, a POSIX shell, and GNU coreutils. workdir changes the command directory; it does not restrict the agent to that directory inside the sandbox.
Deep Agents Code
Install the package alongside Deep Agents Code to add--sandbox agent37. The current CLI requires Python 3.14:
dcode --sandbox agent37 --sandbox-id <instance-id> to reconnect. The CLI starts a stopped instance when reconnecting and deletes instances it creates when the session ends. You can also use DEEPAGENTS_CODE_AGENT37_API_KEY through the CLI’s environment settings.
See the package README for the full interface, development commands, and integration tests.