Add per-turn cyber access program selection (#40687)

## What changed

- Add the experimental `turn/start.cyberAccessProgram` option with `standard`,
  `daybreakBlue`, and `daybreakRed` values.
- Forward the selection as `access_programs.cyber` on Responses, WebSocket,
  and remote-compaction requests made with ChatGPT authentication, while
  omitting it for API-key and custom-provider requests.
- Preserve the per-turn selection across recovery, compaction, and child-agent
  turns without making it a persistent thread setting.

## Testing

- Cover app-server forwarding, authentication boundaries, WebSocket reuse,
  turn recovery, compaction, and child-agent inheritance.

GitOrigin-RevId: d2eb468f365b2214c5099bc21741cf30f8bd2eb5
This commit is contained in:
faizan-oai authored and copyberry committed 2026-08-25 19:54:52 +00:00
1 parent a6e63f9f32
commit 94967e03e5
72 files changed
+1323 -273

No files matched your search

+17
View File
@@ -116,6 +116,7 @@ use crate::client_common::ResponseEvent;
use crate::client_common::ResponseStream;
use crate::context::BaseInstructionsFragment;
use crate::context::ContextualUserFragment;
use crate::cyber_access_program;
use crate::feedback_tags;
use crate::responses_metadata::CodexResponsesMetadata;
use crate::responses_metadata::subagent_header_value;
@@ -307,6 +308,7 @@ struct WebsocketSession {
// This is intentionally not a `PartialEq` implementation: request equality includes `input` and
// `client_metadata`, while websocket reuse compares the input separately and ignores metadata.
// Access programs are authorized per response, including continuations, without replaying input.
// Keep the destructuring exhaustive so new request fields require an explicit reuse decision.
fn responses_request_properties_match(
previous: &ResponsesApiRequest,
@@ -328,6 +330,7 @@ fn responses_request_properties_match(
prompt_cache_key: previous_prompt_cache_key,
text: previous_text,
client_metadata: _,
access_programs: _,
} = previous;
let ResponsesApiRequest {
model: current_model,
@@ -345,6 +348,7 @@ fn responses_request_properties_match(
prompt_cache_key: current_prompt_cache_key,
text: current_text,
client_metadata: _,
access_programs: _,
} = current;
previous_model == current_model
@@ -620,6 +624,10 @@ impl ModelClient {
service_tier: service_tier.as_deref(),
prompt_cache_key: prompt_cache_key.as_deref(),
text,
access_programs: cyber_access_program::for_auth(
client_setup.auth.as_ref(),
prompt.cyber_access_program,
),
};
let mut extra_headers = ApiHeaderMap::new();
@@ -957,6 +965,7 @@ impl ModelClient {
prompt_cache_key,
text,
client_metadata: Some(responses_metadata.client_metadata()),
access_programs: None,
};
Ok(request)
}
@@ -1520,6 +1529,10 @@ impl ModelClientSession {
.extra_headers
.insert(X_CODEX_ROUTING_HINT_HEADER, header_value);
}
request.access_programs = cyber_access_program::for_auth(
client_setup.auth.as_ref(),
prompt.cyber_access_program,
);
self.client
.prepare_response_items_for_request(&mut request.input);
let request_session_telemetry =
@@ -1638,6 +1651,10 @@ impl ModelClientSession {
service_tier.clone(),
responses_metadata,
)?;
request.access_programs = cyber_access_program::for_auth(
client_setup.auth.as_ref(),
prompt.cyber_access_program,
);
let mut websocket_metadata = responses_metadata.clone();
websocket_metadata.routing_hint = self.client.build_routing_hint_header(
client_setup.auth.as_ref(),