Route backend requests through the HTTP client factory (#34490)

## Why

Backend-backed features need to use the same outbound routing configuration as the rest of Codex.

## What changed

- Build the backend client on a route-aware client pool supplied by `HttpClientFactory`.
- Pass the configured factory through app-server account requests, cloud config loading, cloud tasks, and memory rate-limit checks.
- Preserve task query encoding, authentication headers, JSON request bodies, and ChatGPT cookie handling during the migration.

## Testing

- Add backend-client tests for proxy-policy propagation, task query encoding, bearer authentication, and JSON request bodies.

GitOrigin-RevId: c17d162e0dce9cec758df7cdeecf982207c6512b
This commit is contained in:
Michael Bolin authored and copyberry committed 2026-07-21 08:28:51 +00:00
1 parent d5998e7452
commit dc21b46aea
20 files changed
+365 -124

No files matched your search

+3 -2
View File
@@ -60,7 +60,9 @@ async fn init_backend(user_agent_suffix: &str) -> anyhow::Result<BackendContext>
}
let ua = get_codex_user_agent();
let mut http = codex_cloud_tasks_client::HttpClient::new(base_url.clone())?.with_user_agent(ua);
let (auth_manager, http_client_factory) = util::load_auth_manager(Some(base_url.clone())).await;
let mut http = codex_cloud_tasks_client::HttpClient::new(base_url.clone(), http_client_factory)
.with_user_agent(ua);
let style = if base_url.contains("/backend-api") {
"wham"
} else {
@@ -68,7 +70,6 @@ async fn init_backend(user_agent_suffix: &str) -> anyhow::Result<BackendContext>
};
append_error_log(format!("startup: base_url={base_url} path_style={style}"));
let auth_manager = util::load_auth_manager(Some(base_url.clone())).await;
let auth = match auth_manager.as_ref() {
Some(manager) => manager.auth().await,
None => None,