Files
codex/codex-rs/core/src/responses_headers.rs
T
Charlie Marsh ae6c0c8ac1 Exclude per-item usage attribution by default (#63219)
## What changed

Add `usage.attribution` to the `x-codex-exclude` header for Responses HTTP
requests and WebSocket handshakes by default. Threads started with
`experimentalRawEvents` keep receiving per-item attribution in raw responses.
Subagents inherit the policy, and the app server restores it when a thread
resumes with an existing raw-event subscription.

## Testing

Cover the default exclusion, raw completion events with upstream usage,
subagent inheritance, and resuming a closed subagent after both its runtime
and its parent's runtime have unloaded.

GitOrigin-RevId: 0dad92f97606300907f1294f09dd7845d1e6476f
2026-11-23 01:06:41 +00:00

35 lines
1.2 KiB
Rust

//! Host-supplied header settings for threads on the Codex Responses endpoint.
use http::HeaderMap;
/// Controls delivery of per-item attribution requested by the Codex backend for
/// accounting. Seed in `StartThreadOptions::thread_extension_init` to set the
/// policy for a thread and its subagents.
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub enum UsageAttributionPolicy {
#[default]
Exclude,
Retain,
}
/// 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()
}
}