Skip to content

Make environment providers own default selection#20665

Merged
starr-openai merged 8 commits into
mainfrom
starr/exec-env-stdio-stack-3-env-model
May 8, 2026
Merged

Make environment providers own default selection#20665
starr-openai merged 8 commits into
mainfrom
starr/exec-env-stdio-stack-3-env-model

Conversation

@starr-openai
Copy link
Copy Markdown
Contributor

@starr-openai starr-openai commented May 1, 2026

Why

The next PR in this stack introduces configured environments, where the provider knows both which environments exist and which one should be selected by default. The existing manager derived the default internally by checking for the legacy remote and local ids, and it treated "remote" as equivalent to "has a websocket URL." That does not work cleanly for stdio-command remotes because they are remote environments without an exec_server_url.

Stack position: this is PR 3 of 5. It is the environment-model bridge between PR 2's transport enum and PR 4's TOML provider.

What Changed

  • Add DefaultEnvironmentSelection to the EnvironmentProvider contract:
    • Derived preserves the old remote-then-local fallback behavior.
    • Environment(id) lets a provider explicitly select a configured default.
    • Disabled lets a provider intentionally expose no default environment.
  • Move the legacy CODEX_EXEC_SERVER_URL=none default-disabling behavior into DefaultEnvironmentProvider.
  • Make EnvironmentManager validate explicit provider defaults and return an error if the selected id is missing.
  • Track remote_transport separately from exec_server_url so stdio-command environments are still recognized as remote.
  • Add Environment::remote_stdio_shell_command(...) for the TOML provider added in the next PR.

Stack

Split from original draft: #20508

Validation

Not run locally; this was split out of the original draft stack.

@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-3-env-model branch from d2b7397 to 7eff29b Compare May 1, 2026 19:19
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-2-client branch 2 times, most recently from 225bb6b to ae52105 Compare May 1, 2026 19:37
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-3-env-model branch 2 times, most recently from 773f789 to 387ab7a Compare May 1, 2026 19:54
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-2-client branch from 3ae465a to d7095cf Compare May 1, 2026 20:00
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-3-env-model branch from 387ab7a to 3fe0b35 Compare May 1, 2026 20:00
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-2-client branch from d7095cf to a38f8e5 Compare May 1, 2026 20:34
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-3-env-model branch 2 times, most recently from f12eaed to 56ada0d Compare May 1, 2026 20:39
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-2-client branch from 4e89a77 to 0781da0 Compare May 1, 2026 20:42
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-3-env-model branch from 56ada0d to abde0bf Compare May 1, 2026 20:43
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-2-client branch from 0781da0 to 1a11c8b Compare May 1, 2026 20:59
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-3-env-model branch from abde0bf to e0ff30e Compare May 1, 2026 21:02
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-2-client branch from 1a11c8b to 751ed42 Compare May 1, 2026 22:02
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-3-env-model branch 2 times, most recently from 4682df9 to 313c1ad Compare May 4, 2026 18:11
starr-openai added a commit that referenced this pull request May 4, 2026
## Why

This stack adds configured exec-server environments, including
environments reached over stdio. Before client-side stdio transports or
config can use that path, the exec-server binary itself needs a
first-class stdio listen mode so it can speak the same JSON-RPC protocol
over stdin/stdout that it already speaks over websockets.

**Stack position:** this is PR 1 of 5. It is the server-side transport
foundation for the stack.

## What Changed

- Accept `stdio` and `stdio://` for `codex exec-server --listen`.
- Promote the existing stdio `JsonRpcConnection` helper from test-only
code into normal exec-server transport code.
- Add parse coverage for stdio listen URLs while preserving the existing
websocket default.

## Stack

- **1. This PR:** #20663 - Add stdio
exec-server listener
- 2. #20664 - Add stdio exec-server
client transport
- 3. #20665 - Make environment
providers own default selection
- 4. #20666 - Add CODEX_HOME
environments TOML provider
- 5. #20667 - Load configured
environments from CODEX_HOME

Split from original draft: #20508

## Validation

Not run locally; this was split out of the original draft stack.

---------

Co-authored-by: Codex <noreply@openai.com>
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-2-client branch from 3d9bb84 to 4c6d799 Compare May 4, 2026 18:41
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-3-env-model branch 2 times, most recently from 20d01c6 to c0e9b77 Compare May 4, 2026 19:04
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-2-client branch from 7bc1d8f to 309db97 Compare May 4, 2026 19:17
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-3-env-model branch 2 times, most recently from 6b1d4ee to 2a16b0e Compare May 4, 2026 19:52
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-2-client branch from abb8b00 to 26bf42b Compare May 5, 2026 17:15
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-2-client branch from 70fbecf to 2a1200e Compare May 5, 2026 23:03
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-3-env-model branch 7 times, most recently from 59776b1 to bc0677d Compare May 6, 2026 23:03
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-2-client branch from f023486 to 9f125d2 Compare May 7, 2026 04:15
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-3-env-model branch from bc0677d to 7cb55d2 Compare May 7, 2026 04:16
Oreoxp pushed a commit to Oreoxp/codex-cli that referenced this pull request May 7, 2026
## Why

This stack adds configured exec-server environments, including
environments reached over stdio. Before client-side stdio transports or
config can use that path, the exec-server binary itself needs a
first-class stdio listen mode so it can speak the same JSON-RPC protocol
over stdin/stdout that it already speaks over websockets.

**Stack position:** this is PR 1 of 5. It is the server-side transport
foundation for the stack.

## What Changed

- Accept `stdio` and `stdio://` for `codex exec-server --listen`.
- Promote the existing stdio `JsonRpcConnection` helper from test-only
code into normal exec-server transport code.
- Add parse coverage for stdio listen URLs while preserving the existing
websocket default.

## Stack

- **1. This PR:** openai#20663 - Add stdio
exec-server listener
- 2. openai#20664 - Add stdio exec-server
client transport
- 3. openai#20665 - Make environment
providers own default selection
- 4. openai#20666 - Add CODEX_HOME
environments TOML provider
- 5. openai#20667 - Load configured
environments from CODEX_HOME

Split from original draft: openai#20508

## Validation

Not run locally; this was split out of the original draft stack.

---------

Co-authored-by: Codex <noreply@openai.com>
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-3-env-model branch 2 times, most recently from ca24653 to dc926a5 Compare May 7, 2026 23:22
Base automatically changed from starr/exec-env-stdio-stack-2-client to main May 7, 2026 23:48
starr-openai added a commit that referenced this pull request May 7, 2026
## Why

Configured environments need to connect to exec-server instances that
are not necessarily already listening on a websocket URL. A
command-backed stdio transport lets Codex start an exec-server process,
speak JSON-RPC over its stdio streams, and clean up that child process
with the client lifetime.

**Stack position:** this is PR 2 of 5. It builds on the server-side
stdio listener from PR 1 and provides the client transport used by later
environment/config PRs.

## What Changed

- Add `ExecServerTransport` variants for websocket URLs and stdio shell
commands.
- Add stdio command connection support for `ExecServerClient`.
- Move websocket/stdio transport setup into `client_transport.rs` so
`client.rs` stays focused on shared JSON-RPC client, session, HTTP, and
notification behavior.
- Tie stdio child process cleanup to the JSON-RPC connection lifetime
with a RAII lifetime guard.
- Keep existing websocket environment behavior by adapting URL-backed
remotes to `ExecServerTransport::WebSocketUrl`.

## Stack

- 1. #20663 - Add stdio exec-server
listener
- **2. This PR:** #20664 - Add stdio
exec-server client transport
- 3. #20665 - Make environment
providers own default selection
- 4. #20666 - Add CODEX_HOME
environments TOML provider
- 5. #20667 - Load configured
environments from CODEX_HOME

Split from original draft: #20508

## Validation

Not run locally; this was split out of the original draft stack and then
refactored to separate transport setup from the base client.

---------

Co-authored-by: Codex <noreply@openai.com>
@starr-openai starr-openai enabled auto-merge (squash) May 7, 2026 23:53
starr-openai and others added 8 commits May 7, 2026 17:19
Let environment providers return an explicit default selection and let remote environments track the underlying transport instead of treating only websocket URLs as remote. This prepares the environment layer for stdio-backed remotes without introducing config-file loading.

Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Have providers return a concrete default environment id after constructing their environment map, using None to disable the default. This removes the DefaultEnvironmentSelection tri-state while preserving legacy derived defaults through the trait's default implementation.

Co-authored-by: Codex <noreply@openai.com>
Make environment providers return the environment map and default id together. This keeps provider-owned startup state in one boundary and removes the separate default callback over a map.

Co-authored-by: Codex <noreply@openai.com>
Remove the EnvironmentProviderSnapshot wrapper. Providers now expose environments and the selected default id directly, while EnvironmentManager validates that the default id exists in the returned environment map.

Co-authored-by: Codex <noreply@openai.com>
Remove the private from_provider_parts helper. EnvironmentManager::from_provider now performs the provider read, validation, and manager construction directly, and tests use a small provider implementation instead of bypassing that path.

Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Keep EnvironmentManager construction async to preserve caller behavior while moving provider-owned default selection into a single snapshot object.

Co-authored-by: Codex <noreply@openai.com>
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-3-env-model branch from dc926a5 to 01f47ba Compare May 8, 2026 00:19
@starr-openai starr-openai merged commit 9669756 into main May 8, 2026
38 of 39 checks passed
@starr-openai starr-openai deleted the starr/exec-env-stdio-stack-3-env-model branch May 8, 2026 01:00
@github-actions github-actions Bot locked and limited conversation to collaborators May 8, 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