Skip to content

Add sticky thread environment selections#18745

Draft
starr-openai wants to merge 38 commits intomainfrom
sticky-thread-environments-20260420
Draft

Add sticky thread environment selections#18745
starr-openai wants to merge 38 commits intomainfrom
sticky-thread-environments-20260420

Conversation

@starr-openai
Copy link
Copy Markdown
Contributor

@starr-openai starr-openai commented Apr 20, 2026

Summary

  • add experimental thread/start.environments to configure sticky environment selections for a thread
  • carry sticky selections through app-server thread creation into SessionConfiguration
  • resolve turn environments from per-turn override first, then sticky thread selection, then existing default behavior

Behavior

  • omitted thread/start.environments: preserve existing default environment behavior
  • empty thread/start.environments: use no environment for turns unless a turn override is supplied
  • non-empty thread/start.environments: use the first selected environment as the current environment for turns without an override
  • turn/start.environments continues to override the sticky thread selection when supplied

Validation

  • cd codex-rs && just fmt
  • Dream app-server smoke script against local app-server:
    • sticky unset / empty / local / remote / local+remote
    • per-turn unset / empty / local / remote / local+remote overrides

@starr-openai starr-openai force-pushed the sticky-thread-environments-20260420 branch from f7a5b4f to 3aa693e Compare April 21, 2026 00:49
starr-openai and others added 12 commits April 21, 2026 10:31
Refactor EnvironmentManager to own a keyed environment registry with explicit default and local lookups. Keep remote exec-server connections lazy at environment use sites and preserve disabled agent environment access separately from internal local environment access.

Co-authored-by: Codex <noreply@openai.com>
Use EnvironmentManager::new for args-struct construction and keep from_env methods as the env-var factory entrypoints.

Co-authored-by: Codex <noreply@openai.com>
Return concrete default and local environments from EnvironmentManager now that the manager always installs local and default entries. Keep arbitrary ID lookup optional.

Co-authored-by: Codex <noreply@openai.com>
Keep the lazy remote exec-server client wrapper alongside ExecServerClient and import it from the client module for environment-backed exec and filesystem use.

Co-authored-by: Codex <noreply@openai.com>
Use EnvironmentManager::new with EnvironmentManagerArgs for runtime-path-aware construction and keep from_env only for the no-args env-var factory.

Co-authored-by: Codex <noreply@openai.com>
Add high-level EnvironmentManager docs for local/remote initialization, default environment selection, disabled agent access, and lazy remote connection behavior.

Co-authored-by: Codex <noreply@openai.com>
Drop the unused local_environment helper and keep local lookups on the generic get_environment API.

Co-authored-by: Codex <noreply@openai.com>
Clarify that SessionServices carries an Arc handle to the process-level EnvironmentManager rather than owning a session-specific manager.

Co-authored-by: Codex <noreply@openai.com>
Restore CODEX_EXEC_SERVER_URL=none semantics by making EnvironmentManager::default_environment return None when environment access is disabled. Remove the separate disabled-for-agent flag and derive tool availability from the optional default environment.

Add an end-to-end tool exposure test for CODEX_EXEC_SERVER_URL=none.

Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
@starr-openai starr-openai force-pushed the turn-environments-20260417 branch from a6baffb to 4fe4541 Compare April 21, 2026 17:41
@starr-openai starr-openai force-pushed the sticky-thread-environments-20260420 branch 3 times, most recently from 646a58b to a001a93 Compare April 21, 2026 18:03
Create one lazy exec-server client per remote environment and pass clones into the remote process and filesystem backends. This keeps ExecServerClient as the connected-client type while avoiding duplicate websocket clients for one environment.

Co-authored-by: Codex <noreply@openai.com>
@starr-openai starr-openai force-pushed the turn-environments-20260417 branch from 63a554c to 3ce57fe Compare April 21, 2026 18:14
@starr-openai starr-openai force-pushed the sticky-thread-environments-20260420 branch from a001a93 to 889a287 Compare April 21, 2026 18:15
Make EnvironmentManagerArgs::default() own CODEX_EXEC_SERVER_URL parsing so production entrypoints can keep using EnvironmentManager::new with struct update syntax for runtime paths. Add explicit test defaults so test managers do not depend on the process environment.

Co-authored-by: Codex <noreply@openai.com>
@starr-openai starr-openai force-pushed the turn-environments-20260417 branch from 3ce57fe to 7e40485 Compare April 21, 2026 18:24
@starr-openai starr-openai force-pushed the sticky-thread-environments-20260420 branch from 889a287 to fdd3a94 Compare April 21, 2026 18:27
Drop the networked integration test for CODEX_EXEC_SERVER_URL=none omitting environment-backed tools. Lower-level coverage already verifies disabled environments omit those tools.

Co-authored-by: Codex <noreply@openai.com>
@starr-openai starr-openai force-pushed the turn-environments-20260417 branch from 7e40485 to c2fbdee Compare April 21, 2026 18:48
@starr-openai starr-openai force-pushed the sticky-thread-environments-20260420 branch from fdd3a94 to 841572e Compare April 21, 2026 18:49
starr-openai and others added 4 commits April 21, 2026 12:44
Make EnvironmentManagerArgs carry ExecServerRuntimePaths for production construction and route test-only unsandboxed setup through explicit _for_tests helpers. Use the manager local environment for MCP and app-server filesystem fallbacks instead of constructing a fresh default environment.

Co-authored-by: Codex <noreply@openai.com>
Remove the app-server-client re-export now that environment-manager construction owns CODEX_EXEC_SERVER_URL reading directly in exec-server.

Co-authored-by: Codex <noreply@openai.com>
Add a connector loading helper that accepts the existing EnvironmentManager and switch app-server paths to use it. Keep the config-only helper as a temporary fallback for callers such as TUI that do not yet pass the manager through.

Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
starr-openai and others added 6 commits April 21, 2026 13:13
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
@starr-openai starr-openai force-pushed the turn-environments-20260417 branch from c2fbdee to 675777c Compare April 21, 2026 20:13
@starr-openai starr-openai force-pushed the sticky-thread-environments-20260420 branch from 590262b to 9e59851 Compare April 21, 2026 20:18
starr-openai and others added 13 commits April 21, 2026 13:19
Co-authored-by: Codex <noreply@openai.com>
Allow thread/start to configure sticky environment selections that are used by turns when no per-turn override is supplied. Per-turn environments continue to take precedence, while omitted thread selections preserve the existing default behavior.

Co-authored-by: Codex <noreply@openai.com>
Cover sticky thread environment selections and turn-level overrides through the app-server v2 thread/start and turn/start JSON-RPC flow. The matrix mirrors the manual smoke cases for omitted, empty, local, remote, and local plus remote selections.

Co-authored-by: Codex <noreply@openai.com>
Carry thread-level environment selections through app-server, core turn context, unified exec, and environment manager plumbing. Update generated schema and existing tests for the new environment fields.

Co-authored-by: Codex <noreply@openai.com>
Shrink app.rs below the blob policy threshold, clean up dead-code fallout, and update stale exec-server listen URL test expectations.

Co-authored-by: Codex <noreply@openai.com>
Group thread-start options for clippy and make the new environment tests comply with stricter CI lint settings.

Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
The submit helper already waits for the turn to complete. Remove the second wait so the test can inspect the captured request after the successful selected-environment tool call.

Co-authored-by: Codex <noreply@openai.com>
The test serializes captured request JSON before checking the model-visible environment context, so XML attribute quotes are JSON-escaped in the assertion string.

Co-authored-by: Codex <noreply@openai.com>
Use a command-backed remote environment so the test covers remote selection without depending on an unreachable websocket during session startup.

Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
@starr-openai starr-openai force-pushed the sticky-thread-environments-20260420 branch from 9e59851 to 9f8f766 Compare April 21, 2026 20:20
@starr-openai starr-openai force-pushed the turn-environments-20260417 branch 2 times, most recently from 3fdd893 to 8dac6ca Compare April 21, 2026 23:41
Base automatically changed from turn-environments-20260417 to main April 22, 2026 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant