agental-openai-agents
Runs an OpenAI Agents SDK SandboxAgent in an agental.io sandbox: a Linux machine of your own. The agent's commands and file edits happen in the sandbox. Your code and the model's calls stay where they are.
pip install agental-openai-agents
Python 3.10 or later. It depends on agental, the agental SDK, and on openai-agents 0.24. Each release of this package supports the Agents SDK versions it was tested with, and allows no others, since that SDK's sandbox interface changes often. This package is made by agental, not by OpenAI.
Start
Make an API key in the agental console and put it in AGENTAL_API_KEY, next to OPENAI_API_KEY.
import asyncio
from agents import Runner
from agents.run import RunConfig
from agents.sandbox import SandboxAgent, SandboxRunConfig
from agental_openai_agents import AgentalSandboxClient, AgentalSandboxClientOptions
agent = SandboxAgent(name="Fixer", instructions="Run the tests in the workspace and fix what fails.")
async def main() -> None:
run_config = RunConfig(
sandbox=SandboxRunConfig(
client=AgentalSandboxClient(), # AGENTAL_API_KEY, or the agental command's sign-in
options=AgentalSandboxClientOptions(size="small"),
),
)
result = await Runner.run(agent, "Make the tests pass.", run_config=run_config)
print(result.final_output)
asyncio.run(main())
Moving from another sandbox client changes only client= and options=. The agent stays as it is.
What happens in a run
- The client makes a sandbox from your account's default template, or the one you name.
- The Agents SDK writes the manifest's files into the workspace,
/opt/agental/workspaceunless the manifest names another root. - Each command the model runs goes to the sandbox, in the workspace and with the manifest's variables, and its output goes back to the model.
- When the run ends, the sandbox is deleted. It is billed for the time it ran.
A sandbox on agental.io has no time limit unless you or its template give it one. If your process dies before the run ends, the sandbox goes on running and is billed until you stop it: set ttl_seconds as a safety net.
Options
| Option | What it does |
|---|---|
size |
tiny, small, medium or large. Left out, the template's. |
template |
The template to make the sandbox from and hold it to, by id or name. Left out, the account's default. |
name |
The sandbox's name. Made up when left out. |
snapshot_id |
Make the sandbox from one of your snapshots. |
allow |
Addresses the sandbox may reach on top of its template's outbound rule. |
ttl_seconds |
Seconds it runs after a start before the API stops it. Left out, the template's start says; with none there, the deployment's default applies, which on agental.io is none, so it runs until it is stopped. |
region |
The region to make it in, as "eu", or several to try in order, as ("eu", "us"): it is made in the first with room. Left out, the default region. |
ssh_keys |
OpenSSH public key lines let in as root, on top of the keys its template lets in. They do not turn SSH on: its template or the agental SDK's ssh.on() does. |
sandbox_id |
Run in a sandbox you already have. It is not deleted at the end, and the options above, which are for a new one, cannot be given with it. |
max_burst_fee_micros |
The most a create, or the start of a stopped sandbox, may pay in burst fees, in millionths of a US dollar. 0 refuses any fee. Left out, what the account's monthly burst budget allows. |
max_burst_wait |
Seconds a create or start refused for its burst fee may wait, when the API names a time it would cost nothing by, to be tried once more. |
stop_on_exit |
Stop the sandbox at the end in place of deleting it, so a later run can pick it up with its files. |
exposed_ports |
Ports that get a public address when the agent asks for one. |
Picking a run up later
With stop_on_exit=True, the sandbox is stopped when the run ends, and its disk is kept at 5% of the running price. A run resumed from its state, after an approval for example, starts that sandbox again with the workspace as it was. Without it, the sandbox is deleted, and a resumed run gets a new one, with the workspace put back from the run's snapshot when you gave SandboxRunConfig one.
A stopped sandbox stays until you delete it, in the console or with agental.sandboxes.get(id).delete().
Ports
A port in exposed_ports gets a public address the first time the agent asks for it. Anyone with the address can open it while the sandbox runs. What listens must listen on 0.0.0.0.
Limits
- A command runs for at most ten minutes. Commands the model runs are left running and read as they go, so it can start a build and come back to it.
- Nothing can be typed into a command once it runs, and there is no terminal. Give a command its input with a pipe or a here-document.
- Files outside
/opt/agentalare read and written through a copy there. It is made and taken away by the same call. - Mounting cloud storage buckets is not supported yet.
Development
pip install -e . pytest mypy
mypy
pytest
The tests are in tests. The live tests, test_live.py, run only inside the agental repository, as they start its API on the local driver: they are not in this public repository. A sandbox on the local driver is a folder, so they give the client files_root, the folder the files API reads and writes, which is /opt/agental on every real sandbox. In the agental repository, install the agental SDK, agental-sdk, from its folder first, pip install -e ../python.
Metadata
Release files for agental-openai-agents 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agental_openai_agents-0.1.0.tar.gz | 21.0 kB | Without provenance | Details for agental_openai_agents-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agental_openai_agents-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for agental_openai_agents-0.1.0-py3-none-any.whl |
Total release size: 37.9 kB
Release files / agental_openai_agents-0.1.0.tar.gz
| Download URL | agental_openai_agents-0.1.0.tar.gz |
|---|---|
| Size | 21.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
71bd23014fe61771d8fbb2755db9eac4413d12610e753d294fdda475250d59af
|
|
BLAKE2b-256 checksum How to use checksums |
cf8af4030fd438578eb3224e41abeea280cc945f5b311841e7e66e6f54158b7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.11
|
Release files / agental_openai_agents-0.1.0-py3-none-any.whl
| Download URL | agental_openai_agents-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5967af67f316067280f3eaaecada3a6c58fca296aae57a505033067c1e4c8f9b
|
|
BLAKE2b-256 checksum How to use checksums |
36e0b506c1b9c3527f715d37b697f457ba7a09218b6cf571ec143622f64acf88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.11
|
Security for agental-openai-agents 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.