Skip to content

Load configured environments from CODEX_HOME#20667

Merged
starr-openai merged 13 commits into
mainfrom
starr/exec-env-stdio-stack-5-wire-entrypoints
May 8, 2026
Merged

Load configured environments from CODEX_HOME#20667
starr-openai merged 13 commits into
mainfrom
starr/exec-env-stdio-stack-5-wire-entrypoints

Conversation

@starr-openai
Copy link
Copy Markdown
Contributor

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

Why

The earlier PRs add stdio transport support and the config-backed environment provider, but the feature remains inert until normal Codex entrypoints construct EnvironmentManager with enough context to discover CODEX_HOME/environments.toml. This final stack PR activates the provider while preserving the legacy CODEX_EXEC_SERVER_URL fallback when no environments file exists.

Stack position: this is PR 5 of 5. It is the product wiring PR that activates the configured environment provider added in PR 4.

What Changed

  • Thread codex_home into EnvironmentManagerArgs.
  • Change EnvironmentManager::new(...) to load the provider from CODEX_HOME.
  • Preserve legacy behavior by falling back to DefaultEnvironmentProvider::from_env() when environments.toml is absent.
  • Make environments.toml-backed managers start new threads with all configured environments, default first, while keeping the legacy env-var path single-default.
  • Update the app-server, TUI, exec, MCP server, connector, prompt-debug, and thread-manager-sample callsites to pass codex_home and handle provider-loading errors.

Self-Review Notes

  • The multi-environment startup path is intentionally tied to the environments.toml provider. Using >1 configured environment as the only signal would also expand the legacy CODEX_EXEC_SERVER_URL provider because it keeps local addressable alongside remote.
  • The startup environment list is still derived inside EnvironmentManager; the provider only says whether its snapshot should start new threads with all configured environments.
  • The thread-manager sample was updated to pass the current ThreadManager::new(...) installation id argument so the stack compiles under Bazel.

Stack

Split from original draft: #20508

Validation

  • just fmt
  • git diff --check
  • bazel build --config=remote --strategy=remote --remote_download_toplevel //codex-rs/thread-manager-sample:codex-thread-manager-sample
  • bazel test --config=remote --strategy=remote --remote_download_toplevel //codex-rs/exec-server:exec-server-unit-tests
  • bazel test --config=remote --strategy=remote --remote_download_toplevel --test_sharding_strategy=disabled --test_arg=default_thread_environment_selections_use_manager_default_id //codex-rs/core:core-unit-tests
  • bazel test --config=remote --strategy=remote --remote_download_toplevel --test_sharding_strategy=disabled --test_arg=start_thread_uses_all_default_environments_from_codex_home //codex-rs/core:core-unit-tests

Documentation

This activates CODEX_HOME/environments.toml; user-facing documentation should be added before this stack is treated as a documented public workflow.

@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-4-toml-provider branch from 2106226 to 50c4f0d Compare May 1, 2026 19:19
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-5-wire-entrypoints branch from a001a32 to 44a2edb Compare May 1, 2026 19:19
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-4-toml-provider branch from 50c4f0d to 0314e55 Compare May 1, 2026 19:37
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-5-wire-entrypoints branch from 44a2edb to 5a13714 Compare May 1, 2026 19:37
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-4-toml-provider branch from 0314e55 to d3e9d10 Compare May 1, 2026 19:54
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-5-wire-entrypoints branch 2 times, most recently from 7bbc2e1 to f8af4b1 Compare May 1, 2026 20:00
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-4-toml-provider branch 2 times, most recently from 4fef0c4 to 40ebd87 Compare May 1, 2026 20:08
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-5-wire-entrypoints branch from f8af4b1 to 67be044 Compare May 1, 2026 20:09
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-4-toml-provider branch from 40ebd87 to 8be2149 Compare May 1, 2026 20:35
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-5-wire-entrypoints branch from 67be044 to 9671f2b Compare May 1, 2026 20:35
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-4-toml-provider branch 2 times, most recently from 18bb387 to 16a67b4 Compare May 1, 2026 20:39
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-5-wire-entrypoints branch from 9671f2b to 0fa5fe2 Compare May 1, 2026 20:39
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-4-toml-provider branch from 16a67b4 to 4ba0ef0 Compare May 1, 2026 20:44
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-5-wire-entrypoints branch from 0fa5fe2 to 9920728 Compare May 1, 2026 20:44
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-4-toml-provider branch from 4ba0ef0 to 8898b25 Compare May 1, 2026 21:02
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-5-wire-entrypoints branch from 9920728 to 64848b2 Compare May 1, 2026 21:02
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-4-toml-provider branch from 8898b25 to 2fb7e79 Compare May 1, 2026 22:02
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-5-wire-entrypoints branch from 64848b2 to 57e8885 Compare May 1, 2026 22:02
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-4-toml-provider branch from 2fb7e79 to 0eeddca Compare May 4, 2026 18:11
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-5-wire-entrypoints branch from 57e8885 to 8ea31ab 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-4-toml-provider branch from 0eeddca to a99c2c7 Compare May 4, 2026 18:41
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-4-toml-provider branch from f04a72c to 8565584 Compare May 5, 2026 21:39
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-5-wire-entrypoints branch from 1cfd592 to 14121ac Compare May 5, 2026 21:39
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-4-toml-provider branch from 8565584 to 7a171e1 Compare May 5, 2026 22:04
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-5-wire-entrypoints branch from 14121ac to b4b2e71 Compare May 5, 2026 22:04
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-4-toml-provider branch from 7a171e1 to ee9b735 Compare May 5, 2026 22:16
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-5-wire-entrypoints branch from b4b2e71 to a5df0b7 Compare May 5, 2026 22:16
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-4-toml-provider branch from ee9b735 to 3ac2f68 Compare May 5, 2026 22:40
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-5-wire-entrypoints branch 3 times, most recently from a0af7e4 to 7e08acf Compare May 5, 2026 22:44
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-4-toml-provider branch from a57ea34 to 2a2f9c7 Compare May 5, 2026 22:48
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-5-wire-entrypoints branch from 7e08acf to 7d8d27a Compare May 5, 2026 22:48
@starr-openai starr-openai force-pushed the starr/exec-env-stdio-stack-4-toml-provider branch from 2a2f9c7 to dcdd3dd Compare May 5, 2026 22:54
starr-openai and others added 13 commits May 8, 2026 10:05
Co-authored-by: Codex <noreply@openai.com>
Thread codex_home into EnvironmentManager construction so app entrypoints load environments.toml when present and continue falling back to the legacy CODEX_EXEC_SERVER_URL provider otherwise.

Co-authored-by: Codex <noreply@openai.com>
Pass the app-owned EnvironmentManager into ChatWidget so connector prefetch uses the same environment selection that the session was initialized with, instead of reconstructing it from config.

Co-authored-by: Codex <noreply@openai.com>
Keep the direct ChatWidget test constructor aligned with the production initializer after wiring the active environment manager through the TUI.

Co-authored-by: Codex <noreply@openai.com>
Apply the rustfmt indentation reported by the PR20667 Format / etc CI job after the stack rebase.

Co-authored-by: Codex <noreply@openai.com>
Preserve provider environment order and derive startup selections from the configured default plus remaining environments. This lets multi-environment CODEX_HOME setups attach every configured environment by default while keeping the default first as primary.

Co-authored-by: Codex <noreply@openai.com>
Exercise a non-local configured default so the test proves default-first ordering rather than relying on the implicit local environment already being first.

Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Keep the app-server ignore-user-config path compiling after rebasing onto the merged TOML-provider stack.

Co-authored-by: Codex <noreply@openai.com>
Drop the stale await from the configured-environments startup regression now that the test helper returns ThreadManager synchronously on current main.

Co-authored-by: Codex <noreply@openai.com>
Derive initial thread environments from the default environment and the available environment map instead of storing a separate startup selection list. This also removes the provider snapshot boolean that distinguished legacy and TOML startup policies.

Co-authored-by: Codex <noreply@openai.com>
Remove a test-only call to a non-existent CodexThread helper. The test still verifies startup environment ordering through the manager defaults and generated environment context.

Co-authored-by: Codex <noreply@openai.com>
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