Skip to content

core: add wait_for_environment for starting environments - #29745

Merged
sayan-oai merged 2 commits into
mainfrom
codex/core-wait-for-environment
Jun 24, 2026
Merged

core: add wait_for_environment for starting environments#29745
sayan-oai merged 2 commits into
mainfrom
codex/core-wait-for-environment

Conversation

@sayan-oai

Copy link
Copy Markdown
Contributor

Why

With DeferredExecutor, a sampling request can begin while an environment is still starting. The model can see that pending state, but needs a way to wait for the environment within the same turn before continuing.

Environment startup is owned by Core, so the wait tool should use the same request-frozen StepContext that advertised the starting environment. This keeps tool registration and execution tied to the exact startup operation the model saw, even if live thread state later changes.

Supersedes #29735.

What

  • register wait_for_environment when the current StepContext contains starting environments
  • wait on the selected StartingTurnEnvironment shared resolution and return a bounded ready or failed result
  • rebuild the next request normally, removing the wait tool and exposing ready environment tools, or reporting the environment as unavailable after failure

Testing

  • just test -p codex-core deferred_executor_
    • verifies the wait tool is replaced by environment-backed tools after startup
    • verifies startup failure removes both the wait tool and unavailable environment tools while notifying the model

Comment thread codex-rs/core/src/tools/spec_plan.rs Outdated
Comment thread codex-rs/core/tests/suite/remote_env.rs Outdated
Comment thread codex-rs/core/src/tools/handlers/wait_for_environment.rs Outdated
@sayan-oai
sayan-oai enabled auto-merge (squash) June 24, 2026 00:16
@sayan-oai
sayan-oai merged commit 61ff4d0 into main Jun 24, 2026
46 of 47 checks passed
@sayan-oai
sayan-oai deleted the codex/core-wait-for-environment branch June 24, 2026 00:35
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants