Files
codex/codex-rs/core/src/responses_headers.rs
T
jif e1dd7ed1ba Preserve Guardian request metadata with custom OpenAI base URLs (#57439)
## Why

Custom OpenAI base URLs caused Codex backend authentication to lose Responses headers and Guardian metadata when the URL did not match a recognized backend route.

## What changed

Apply model-scoped Responses headers, Guardian reviewer and classifier markers, and eligible ChatGPT parent credit requests based on the OpenAI provider and authentication configuration, regardless of the base URL. Keep API-key requests and other providers excluded from this behavior.

## Testing

Extend coverage for custom `/v1` URLs and direct `/api/codex` endpoints with ChatGPT, header-based, and API-key authentication, including HTTP fallback and WebSocket requests.

GitOrigin-RevId: cc4bb5b4a1a6596904ecf8965237c7a4f09e112b
2026-10-27 12:17:14 +00:00

26 lines
970 B
Rust

//! Header overrides for host-created threads on the Codex Responses endpoint.
//! Headers are scoped to a model and rechecked against current auth on each attempt.
use http::HeaderMap;
/// Seed in `StartThreadOptions::thread_extension_init` to supply Responses headers.
///
/// Applied only to the selected model on the OpenAI provider with Codex backend
/// auth, regardless of the base URL. The headers are sent on HTTP requests and
/// WebSocket handshakes; changes require a new socket. Other providers and
/// unrelated threads do not inherit these headers.
#[derive(Clone)]
pub struct CodexResponsesHeaders {
pub model: String,
pub headers: HeaderMap,
}
impl std::fmt::Debug for CodexResponsesHeaders {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("CodexResponsesHeaders")
.field("model", &self.model)
.field("header_names", &self.headers.keys())
.finish()
}
}