Connect app-server workspace discovery to model request routing (#46281)

## Why

Model requests need the selected workspace's routing constraints before sending content. A missing cached route cannot establish that a custom ChatGPT-auth destination is independent of the workspace.

## What changed

- Register the account processor as the workspace routing resolver for Responses HTTP, compaction, and WebSockets, enabling origin selection and routing headers while preserving API paths and rejecting routed HTTP redirects.
- Share concurrent discovery by auth generation, workspace, and backend configuration. Recover from discovery-time `401` responses while allowing token refreshes for the same auth owner.
- Require successful discovery before classifying custom destinations as independent, and require a new thread when a workspace-bound session's bootstrap origin changes.
- Refresh managed requirements using retained session configuration without fetching thread configuration again. Return typed routing errors without account or backend details.

## Testing

Extend coverage for discovery-time token refresh, retained provider definitions under managed requirements, and specific invalid-routing error categories.

GitOrigin-RevId: 090cda70daa91ee8acfbc973699d028111e54125
This commit is contained in:
acrognale-oai authored and copyberry committed 2026-09-17 19:12:42 +00:00
1 parent d7f8e48d7d
commit 0a5b999169
21 files changed
+505 -200

No files matched your search

+8 -2
View File
@@ -5478,10 +5478,13 @@ async fn rebuild_with_session_layers_refreshes_requirements() -> std::io::Result
thread_layer_stack,
)
.await?;
let zsh_path = refreshed_config.zsh_path.clone();
let config = Config::rebuild_with_session_layers(
&thread_config.config_layer_stack,
thread_config.cwd.to_path_buf(),
&refreshed_config,
&refreshed_config.config_layer_stack,
refreshed_config.codex_home.clone(),
zsh_path.map(AbsolutePathBuf::try_from).transpose()?,
)
.await?;
@@ -5603,10 +5606,13 @@ async fn rebuild_with_session_layers_refreshes_plugin_derived_mcp_config() -> an
thread_layer_stack,
)
.await?;
let zsh_path = refreshed_config.zsh_path.clone();
let config = Config::rebuild_with_session_layers(
&thread_config.config_layer_stack,
thread_config.cwd.to_path_buf(),
&refreshed_config,
&refreshed_config.config_layer_stack,
refreshed_config.codex_home.clone(),
zsh_path.map(AbsolutePathBuf::try_from).transpose()?,
)
.await?;
let plugins_manager =
+6 -12
View File
@@ -1844,22 +1844,16 @@ impl Config {
pub async fn rebuild_with_session_layers(
session_layers: &ConfigLayerStack,
cwd: PathBuf,
refreshed_config: &Config,
refreshed_layers: &ConfigLayerStack,
codex_home: AbsolutePathBuf,
default_zsh_path: Option<AbsolutePathBuf>,
) -> std::io::Result<Self> {
let config_layer_stack = Self::layer_stack_preserving_session(
session_layers,
&refreshed_config.config_layer_stack,
)?;
let config_layer_stack =
Self::layer_stack_preserving_session(session_layers, refreshed_layers)?;
let cfg: ConfigToml = config_layer_stack
.effective_config()
.try_into()
.map_err(|err| std::io::Error::new(std::io::ErrorKind::InvalidData, err))?;
let default_zsh_path = refreshed_config
.zsh_path
.clone()
.map(AbsolutePathBuf::try_from)
.transpose()?;
Self::load_config_with_layer_stack(
LOCAL_FS.as_ref(),
cfg,
@@ -1868,7 +1862,7 @@ impl Config {
default_zsh_path,
..Default::default()
},
refreshed_config.codex_home.clone(),
codex_home,
config_layer_stack,
)
.await