Skip to main content
Run an OpenAI-hosted agent on a Blaxel computer to turn a source report into a summary. Then use Agent Drive to let a fresh agent review the saved file after the first computer is deleted.

Prerequisites

  • Python 3.11 through 3.14 and Git
  • An OpenAI project with Agents API access and two keys in the same organization, project, and owner:
    • OPENAI_API_KEY, the project key. It stays with your application.
    • OPENAI_EXECUTOR_API_KEY, a separate restricted executor key created in the same project by the same owner. It is required in every agent mode and is the only OpenAI key passed to worker Sandboxes.
  • A Blaxel workspace, using an installed Blaxel CLI with bl login, or provided as BL_WORKSPACE and BL_API_KEY (API keys)
  • Public PyPI access to install the cookbook dependencies with ./run.sh
Agent Drive access in us-was-1 is optional for the first run and required for the optional fresh-session handoff.
The Agents API is a public beta. This walkthrough uses the public openai package and client.beta.agents. It is separate from the OpenAI Agents SDK tutorial.
Create OPENAI_API_KEY on the API keys page with Agents read/write and Responses write permissions. Create a separate OPENAI_EXECUTOR_API_KEY on the Agents environment-key page, in the same organization, project, and user or service account as the session. Set all other permissions to None. The environment key permits connecting the executor only; a generic restricted API key with List models access does not establish that permission. Both keys are required. Missing or identical keys fail before a worker is provisioned. The application key stays outside workers; only the environment key is passed as CODEX_API_KEY to codex exec-server. Follow the OpenAI self-hosted setup for the current dashboard flow. These examples create hosted resources and invoke a model. Your local script creates a session and a computer, runs the file task, verifies the result, and deletes the temporary resources.

1. Configure and run the cookbook

The default auto mode uses Agent Drive when available. Set BL_AGENT_DRIVE_MODE=off before the run for completely disposable storage.
The launcher creates a virtual environment and installs public dependencies. The source is a fictional billing incident with counts, owners, deadlines, and a missing-data caveat. The agent reads sample_report.txt and writes summary.md. OpenAI manages the agent session. Blaxel supplies the computer that runs its commands. The executor connects outbound to OpenAI; the first run requires no webhook deployment or public worker port.

2. Open your summary

Open the printed outputs/<run-id>/summary.md path in your editor. Check how the agent summarizes the failures, assigns follow-up work, and handles the missing-data caveat. The script verifies file use before saving the local copy. It also confirms that its new turn completed and both temporary resources were deleted. These are selected output lines; the run also prints the local output and retained Drive paths:
Generated analysis still needs your judgment. The automated check confirms that the agent recovered a fresh verification marker from the source file. Without Agent Drive access, the baseline uses temporary storage and still saves your local summary before deleting the computer.

3. Continue in a fresh session

Agent Drive becomes most useful when another agent continues from an explicit file instead of copied conversation history.
This command runs the full two-stage example; an earlier baseline run is not required. The first session writes summary.md, then its session and Sandbox are deleted. A fresh session and Sandbox mount the same Drive, read that file, and write review.md:
Both summary.md and review.md remain in the same Agent Drive run directory. The second agent must read the original verification marker before its review passes.
Agent Drive shares inspectable files. It does not copy model memory, conversation history, or session state.
Open outputs/<run-id>/summary.md and outputs/<run-id>/review.md from this run. Both local copies share the original run’s directory. The handoff requires Agent Drive in us-was-1. It refuses BL_AGENT_DRIVE_MODE=off and reports an access or region error when persistence is unavailable.

4. Adapt the task

Replace sample_report.txt with your own document. Change the first agent’s prompt and output check in main.py, and the follow-up task in handoff.py. Keep a check tied to your input so a completed turn alone cannot pass as useful work. The cookbook keeps session creation, computer setup, the task, verification, and cleanup visible. The baseline uses one session and computer. Handoff adds a second pair only after the first is gone.

Prompt your coding agent

After configuring the credentials above, you can give a coding agent this task:

5. Review cleanup

The scripts delete their temporary sessions and computers. Local files in outputs/ and files on Agent Drive are retained intentionally. Inspect or export the Drive’s files before deleting it. For an interrupted run, use the exact printed receipt from the same Blaxel workspace and endpoint:
Recovery preserves local output and Agent Drive. Verify session and worker deletion in its result. Keep the receipt if cleanup fails; a computer’s expiration time is a backstop, not confirmation of cleanup.

Troubleshooting

Resources

OpenAI Agents API integration reference

Review credentials, storage policy, execution modes, and lifecycle behavior.

Cookbook and optional examples

Adapt the baseline, or explore the separate team and webhook guides.

Agent Drive

Configure persistent files and access permissions.
Last modified on September 11, 2026