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

+32 -1
View File
@@ -172,7 +172,38 @@ impl ConfigManager {
let mut config = Config::rebuild_with_session_layers(
session_layers,
cwd.to_path_buf(),
&refreshed_config,
&refreshed_config.config_layer_stack,
refreshed_config.codex_home.clone(),
refreshed_config
.zsh_path
.clone()
.map(AbsolutePathBuf::try_from)
.transpose()?,
)
.await?;
self.apply_runtime_feature_enablement(&mut config);
self.apply_arg0_paths(&mut config);
Ok(config)
}
/// Refreshes global settings and managed requirements using already fetched session layers.
pub(crate) async fn load_retained_session_config(
&self,
session_layers: &ConfigLayerStack,
cwd: &Path,
) -> std::io::Result<Config> {
let mut manager = self.clone();
manager.thread_config_loader = Arc::new(codex_config::NoopThreadConfigLoader);
let refreshed_layers = manager
.load_config_layers_for_cwd(AbsolutePathBuf::from_absolute_path(cwd)?)
.await?;
// Merge the retained provider definitions before resolving managed provider selection.
let mut config = Config::rebuild_with_session_layers(
session_layers,
cwd.to_path_buf(),
&refreshed_layers,
AbsolutePathBuf::from_absolute_path(&self.codex_home)?,
/*default_zsh_path*/ None,
)
.await?;
self.apply_runtime_feature_enablement(&mut config);