Skip to content
Max Narditdata & ai systems
← Articles
8 mindev

OpenAI Agents SDK 1.0 alpha runs Codex inside Python: what a saved approval checks, and what it leaves to you

A pending Codex command or edit can now wait for a decision and run on another worker. In offline runs of alpha.2, a command was tied to its text, path and permissions but not to the script it starts, failed resumes locked the session, and stable 0.26.0 could not read the saved run state.

Contents

OpenAI’s Agents SDK 1.0 alpha can run Codex inside your Python process. CodexProvider is a model provider for the SDK’s Runner. The wheel bundles Codex Core, the engine behind the Codex CLI, so by the release notes a run starts no separate codex app-server, and you choose the provider per run. Alpha.1 shipped on November 20 and alpha.2 on November 23. Both are GitHub prereleases; PyPI’s latest is 0.26.0.

The part worth testing is in alpha.2. A command or a file edit waiting for a human can now be saved, and another worker can approve and run it later. Whether that is safe depends on what the approval is tied to, and the answer differs for an edit and for a command.

I installed both wheels on Linux and drove them offline: the real provider and the embedded Core, with a local HTTP server standing in for the model and returning scripted tool calls. That says nothing about model behavior, and I made no live call. Where a claim comes from the docs or the source and not from a run, the text says so.

How do you install the OpenAI Agents SDK 1.0 alpha with Codex?

Use a fresh CPython 3.10 to 3.14 environment and the wheel URL with its SHA-256 from the alpha.2 release notes. Pip checks the downloaded file against that hash before installing it. For Linux x86-64 with glibc 2.28 or newer:

shell
python3 -m venv .venv-a2 && . .venv-a2/bin/activate
python -m pip install --only-binary=:all: \
  "https://github.com/openai/openai-agents-python/releases/download/v1.0.0-alpha.2/openai_agents-1.0.0a2-cp310-abi3-manylinux_2_28_x86_64.whl#sha256=1c073472688dfae9ed4b082ad4be3451ceb2cf7913bfb56b1a9af258b63cdf7b"

The wheel is 123 MB, and the environment took about 409 MiB on disk here. Then check it without a login. The script comes from the source at the same tag:

shell
git clone --depth 1 --branch v1.0.0-alpha.2 \
  https://github.com/openai/openai-agents-python agents-a2
python -I agents-a2/native/codex/verify_installed.py

It uses a local server, temporary files and its own CODEX_HOME. My run reported "passed": true with six approval checks: deny, approve, approve with hooks, edit, edit with hooks, and “partial edit stopped”. The last one needs a working filesystem sandbox; by the script’s source, a Linux host without one gets it reported as skipped. The run can also print a Synthetic relay failure traceback. That is the script breaking a hook on purpose.

I hit one failure. My environment and workspace shared a subtree of /tmp, which workspace-write makes writable, and the runs stopped with “Protecting Codex runtime helpers would make the workspace read-only”. Setting exclude_slash_tmp=true under sandbox_workspace_write cleared it. Keeping the environment away from what the sandbox can write is simpler.

For a live run, the docs say the provider reads a saved login from CODEX_HOME (default ~/.codex), which must be writable, or takes CodexProvider(api_key=...). The wheel does not install the CLI. The embedded Core is 0.166.0 with three patches, while the current CLI release is 0.172.0, so a script and your terminal can run different Codex versions on one config directory. I did not test that combination.

Which approvals pause in the Agents SDK Codex provider, and which end the run?

SDK function tools with needs_approval=True pause in both alphas. A native Codex command pauses only in alpha.2, and only when the run has a ResumableSession; otherwise the approval request ends the run with an error. The docs say the same for a native edit, which I ran only with a session.

The same command, marked require_escalated (a request to run outside the sandbox, which triggers the approval), in three setups:

SetupResult
alpha.1“Codex requested interactive approval. This provider supports non-interactive execution only.”
alpha.2, no session“Cannot save this Codex approval. Use session=ResumableSession with a supported local command or file edit.”
alpha.2, ResumableSessionone interruption, nothing executed

The first two raised an error and the command did not execute. So if you move an alpha.1 script to alpha.2 and change nothing else, native approvals still end the run.

Recovery is narrow. The docs allow one pending exec_command or apply_patch, in one local environment, with the same workspace path and permissions. Other native approval types fail the model call. If nobody will be there to answer, the docs’ setting is approval_policy="never" with sandbox_mode="read-only".

On the second worker, with store, session_id, agent and config rebuilt to match the first:

python
session = await ResumableSession.resume(store, session_id)
state = await session.load_state(agent)
(pending,) = state.get_interruptions()
print(pending.tool_name, pending.arguments)
 
if input("approve? [y/N] ").strip().lower() == "y":
    state.approve(pending)
else:
    state.reject(pending)
 
# the loaded state remembers its session
result = await Runner.run(agent, state, run_config=config)

Your store needs two async methods, load and save, and save has to be an atomic compare-and-swap. Treat it as sensitive: my checkpoint for one pending command held the full command text, including a fake token I had put in it.

What does a saved Codex approval actually check?

Both kinds check the saved call, the workspace path and the permissions. A patch also gets its files checked; a command does not get the script it runs checked. I paused in one process, changed something, then approved in another:

Changed between pause and approvalWhat happened
Nothing (command)ran
Nothing (patch)applied
The file a patch editsrefused, patch not applied
The workspace pathrefused, command not run
The sandbox moderefused, command not run
The script behind python3 job.pyran the new script

The last row follows from the source: the restore check validates file contents only for apply_patch requests. The release notes put “Affected files must match their saved state” next to both call types. The provider guide is more precise and says “for edits”.

It matters because the command was escalated, so it ran outside the sandbox: in a second run the swapped script wrote a file outside the workspace. The request read python3 job.py the whole time, and nothing on the restored request told the second worker that the file had changed. Any approval of a command that runs a mutable file has this gap, an interactive one included. There it is open while the prompt is on screen. A saved approval can keep it open for hours and across workers.

If the command runs a file, put the hash of the reviewed version into the command before it is submitted for approval:

shell
echo '<sha256>  job.py' | sha256sum -c --quiet - && python3 job.py

With the hash in place, the swapped script did not run and the unchanged one did. It covers the bytes sha256sum read. Python opens the file again and loads its own imports. The stronger version keeps the script and its dependencies immutable from review until the command has finished. The docs leave that to you as well: the application must “prevent concurrent edits”.

What happens when the Agents SDK refuses to resume a saved Codex approval?

In my runs the session stayed marked active, and the pending approval could not be loaded again. That held for every refusal in the table, including the wrong workspace path, which by the source is the first thing the provider checks before it replays the call. Reopening the session gave:

ResumableSessionError (reason: active)
The resumable session has an unfinished attempt with an unknown outcome.
Reconcile external effects before retrying.

Where the failure happens inside Core that is the safe direction, since the SDK can’t know whether something ran. But a deploy with the wrong path uses up the pending approval too. So before calling Runner.run with an approved state, compare cwd and permissions with the values you stored at pause time. The docs add hooks to that list, and say a missing required hook leaves the approval pending; I did not test that. If a session is stuck on active, check that the old worker has stopped and inspect the workspace before you start a new session.

Nothing is rolled back. The docs say cancellation and output guardrails do not undo native commands, and a partial edit stays on disk. Resuming can’t restart a command that died with its worker. If approvals can wait a long time, you also need an expiry and a rule for late answers, which I covered in the always-on agent inbox.

What runs outside the Codex sandbox in the Agents SDK?

Your Python tools do: they are ordinary functions in your process. The docs put Codex Core there too (“Core runs inside Python”), along with any hooks you configure. Codex’s permissions apply to native commands and edits, unless an approval lets one out. With sandbox_mode="read-only" and approval_policy="never", two separate runs on each wheel tried to write:

CallerAttemptResult
native exec_commandwrite a file in the workspace“Read-only file system”
SDK @tool functionwrite a file in the workspacewritten

So read-only limits Codex’s native tools and leaves your own functions alone. The examples README says as much: register only functions whose effects your application permits. What the native side does and does not wall off is in Codex sandbox permission profiles.

Hooks are where one of the three patches matters. Stock Codex 0.166.0 “reports a failed PreToolUse hook but can still start the tool”, in the words of the patch notes. Alpha.2 blocks native dispatch when a synchronous PreToolUse hook fails or times out. The verification script covers a crashing hook on a command and a hung one on an edit, asserts that the target is unchanged, and passed here. The alpha.1 release notes say it embeds an unmodified 0.166.0, so by the patch notes it has the older behavior. I did not run that case. Claude Code makes this a setting, and I went through where its hooks fail open.

Can you go back from Agents SDK alpha.2 to an older version?

Not with the run state alpha.2 saves. It reads older state and always writes RunState schema 1.24, which neither alpha.1 nor stable 0.26.0 reads. I paused an SDK tool call in each version and loaded the saved state in all three. “Yes” means the pending call came back:

Written byRead by 1.0.0a1Read by 1.0.0a2Read by 0.26.0
1.0.0a1 (schema 1.22)yesyesyes
1.0.0a2 (schema 1.24)noyesno
0.26.0 (schema 1.22)yesyesyes

The release notes warn about alpha.1. Stable 0.26.0 came out about seven hours after alpha.2 and still refuses 1.24, so a run saved by alpha.2 can’t be picked up by stable either.

The release notes put it as readers before writers. For a rollback, finish the runs that still need their 1.24 state while an alpha.2 worker is up, then start fresh sessions. And don’t point stable and alpha workers at the same store.

Should you build on the OpenAI Agents SDK 1.0 alpha now?

Try it for native read-only runs whose SDK tools don’t write. I would not put a production approval queue on it yet. A saved approval for a command doesn’t cover the file it runs, a failed resume can take the pending approval with it, and the state format changed between two alphas three days apart. The recovery also depends on patches to Core that OpenAI’s notes say to remove one by one as upstream catches up.

If you do test it, the cheap parts come first: keep reviewed scripts immutable (or hash them in the command), check path and permissions before resuming, and give the alpha its own state store.

01 / Discussion

No comment section here — all discussions happen on X.

Max Nardit@mnardit

02 / More articles