Metadata-Version: 2.4
Name: openai-agents-floo
Version: 0.1.0
Summary: Run OpenAI Agents SDK sandbox sessions on floo.
Project-URL: Documentation, https://getfloo.com/docs/guides/openai-agents-sdk
Project-URL: Repository, https://github.com/getfloo/floo-cli/tree/main/python/openai-agents-floo
Project-URL: Issues, https://github.com/getfloo/floo-cli/issues
Author: floo
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: floo-sandbox==0.2.0
Requires-Dist: openai-agents==0.26.0
Description-Content-Type: text/markdown

# openai-agents-floo

Run the OpenAI Agents SDK shell and filesystem tools in a floo sandbox. This package targets `openai-agents==0.26.0` and `floo-sandbox==0.2.0`.

Install with Python 3.11 or newer.

```sh
python -m pip install openai-agents-floo==0.1.0
```

[floo quickstart](https://getfloo.com/docs/guides/openai-agents-sdk)

Set `FLOO_API_KEY` in the application environment and `FLOO_APP_NAME` to an existing app. Set `FLOO_ORG_ID` to select an org when using a personal key. The floo SDK manages its shared transport. The provider captures that transport when you construct the client.

```python
import asyncio
import os

from agents import RunConfig, Runner
from agents.sandbox import SandboxAgent, SandboxRunConfig
from openai_agents_floo import FlooSandboxClient, FlooSandboxOptions


async def main():
    agent = SandboxAgent(name="Analyst", instructions="Use the sandbox to check your work.")
    config = RunConfig(sandbox=SandboxRunConfig(
        client=FlooSandboxClient(os.environ["FLOO_APP_NAME"]),
        options=FlooSandboxOptions(lifetime_seconds=300),
    ))
    result = await Runner.run(agent, "Write and run a Python program that sums 1 through 100.", run_config=config)
    print(result.final_output)


asyncio.run(main())
```

This example uses the application's configured model. The live tests below use scripted turns and need only floo credentials.

## Workspace and lifecycle

Commands run with `/workspace` as their working directory. SDK file operations accept binary files and stay within that directory. Manifests support inline `File` and `Dir` entries, including nested and ephemeral entries. Commands run as the guest's default user with outbound networking blocked. The provider supports one-shot commands. PTYs, user switching, ports, host files, mounts, extra path grants, and manifest environment variables are unsupported.

With `SandboxRunConfig(client=...)`, the runner starts and cleans up the sandbox. With `SandboxRunConfig(session=...)`, the application owns the session. Call `await session.aclose()` to persist its configured snapshot and terminate it. Use `await client.delete(session)` in a cleanup `finally` block to terminate a partially initialized session. Deletion is idempotent.

Import `openai_agents_floo` in each resume worker. Save the SDK run state in trusted application storage. For a standalone session, use `client.serialize_session_state(session.state)`, then `await client.resume(client.deserialize_session_state(payload))`. Resuming a live sandbox transfers lifecycle ownership to the resumed handle.

Version 0.1.0 records the `floo` backend ID, SDK session UUID, app name, floo sandbox ID, creation options, manifest, and SDK snapshot metadata. Resume with the same app and org. After termination, recovery requires the persisted snapshot. The runner selects its local snapshot directory by default. For a custom directory, pass the same absolute path to `FlooSandboxClient(snapshot_dir=...)` and `LocalSnapshotSpec(base_path=...)`. All resume workers need access to those archives. Direct `client.create()` uses a no-op snapshot by default and can reconnect only while the sandbox exists.

Workspace files survive consecutive commands on the same sandbox. A replacement sandbox restores the workspace archive, including file modes. System packages, files outside the workspace, and background processes are outside the archive. Long-running processes require their original guest to remain running. Use a workspace-local dependency directory for dependencies that must survive restore.

## Verify

From this directory, build the wheel with `python -m build --wheel`, install it into a fresh environment, and run the following with that environment's Python. Set `FLOO_AGENTS_TEST_APP` to an existing app for the two live checks.

```sh
python -m unittest discover -s tests -v
python tests/live_session.py
python tests/live_runner.py
```

The live checks allocate short-lived floo sandboxes and verify their final status. They use temporary local directories for snapshots.

[OpenAI custom sandbox provider contract](https://openai.github.io/openai-agents-python/sandbox/custom-providers/)
