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

@@ -87,8 +87,12 @@ impl Handler {
.send_input(
receiver_thread_id,
input_items,
Some(turn.sub_id.clone()),
turn.turn_metadata_state.root_turn_id(),
crate::TurnStartOptions {
parent_turn_id: Some(turn.sub_id.clone()),
root_turn_id: turn.turn_metadata_state.root_turn_id(),
cyber_access_program: turn.cyber_access_program,
..Default::default()
},
)
.await
.map_err(|err| collab_agent_error(receiver_thread_id, err));
@@ -132,6 +132,7 @@ async fn handle_spawn_agent(
root_turn_id: turn.turn_metadata_state.root_turn_id(),
environments: Some(step_context.environments.to_selections()),
multi_agent_v2_usage_hints: None,
cyber_access_program: turn.cyber_access_program,
},
))
.await
@@ -1132,7 +1132,7 @@ async fn multi_agent_v2_spawn_returns_path_and_send_message_accepts_relative_pat
*id == child_thread_id
&& matches!(
op,
Op::InterAgentCommunication { communication }
Op::InterAgentCommunication { communication, .. }
if communication.author == AgentPath::root()
&& communication.recipient.as_str() == "/root/test_process"
&& communication.other_recipients.is_empty()
@@ -1159,7 +1159,7 @@ async fn multi_agent_v2_spawn_returns_path_and_send_message_accepts_relative_pat
*id == child_thread_id
&& matches!(
op,
Op::InterAgentCommunication { communication }
Op::InterAgentCommunication { communication, .. }
if communication.author == AgentPath::root()
&& communication.recipient.as_str() == "/root/test_process"
&& communication.other_recipients.is_empty()
@@ -1355,7 +1355,7 @@ async fn multi_agent_v2_send_message_accepts_root_target_from_child() {
*id == root.thread_id
&& matches!(
op,
Op::InterAgentCommunication { communication }
Op::InterAgentCommunication { communication, .. }
if communication.author == child_path
&& communication.recipient == AgentPath::root()
&& communication.other_recipients.is_empty()
@@ -1869,7 +1869,7 @@ async fn multi_agent_v2_send_message_rejects_interrupt_parameter() {
assert!(!ops_for_agent.iter().any(|op| matches!(op, Op::Interrupt)));
assert!(!ops_for_agent.iter().any(|op| matches!(
op,
Op::InterAgentCommunication { communication }
Op::InterAgentCommunication { communication, .. }
if communication.author == AgentPath::root()
&& communication.recipient.as_str() == "/root/worker"
&& communication.other_recipients.is_empty()
@@ -1956,7 +1956,7 @@ async fn multi_agent_v2_followup_task_completion_notifies_parent_on_every_turn()
*id == agent_id
&& matches!(
op,
Op::InterAgentCommunication { communication }
Op::InterAgentCommunication { communication, .. }
if communication.author == AgentPath::root()
&& communication.recipient == worker_path
&& communication.encrypted_content.as_deref() == Some("continue")
@@ -2003,7 +2003,7 @@ async fn multi_agent_v2_followup_task_completion_notifies_parent_on_every_turn()
(id == root.thread_id)
.then_some(op)
.and_then(|op| match op {
Op::InterAgentCommunication { communication }
Op::InterAgentCommunication { communication, .. }
if communication.author == worker_path
&& communication.recipient == AgentPath::root()
&& communication.other_recipients.is_empty()
@@ -2149,7 +2149,7 @@ async fn multi_agent_v2_interrupted_turn_does_not_notify_parent() {
(id == root.thread_id)
.then_some(op)
.and_then(|op| match op {
Op::InterAgentCommunication { communication }
Op::InterAgentCommunication { communication, .. }
if communication.author.as_str() == "/root/worker"
&& communication.recipient == AgentPath::root()
&& communication.other_recipients.is_empty()
@@ -3019,8 +3019,7 @@ async fn multi_agent_v2_wait_agent_accepts_timeout_only_argument() {
"hello from worker".to_string(),
/*trigger_turn*/ false,
),
/*parent_turn_id*/ None,
/*root_turn_id*/ None,
Default::default(),
)
.await;
@@ -3524,8 +3523,7 @@ async fn multi_agent_v2_wait_agent_returns_summary_for_mailbox_activity() {
"completed".to_string(),
/*trigger_turn*/ false,
),
/*parent_turn_id*/ None,
/*root_turn_id*/ None,
Default::default(),
)
.await;
@@ -3601,8 +3599,7 @@ async fn multi_agent_v2_wait_agent_returns_for_already_queued_mail() {
"already queued".to_string(),
/*trigger_turn*/ false,
),
/*parent_turn_id*/ None,
/*root_turn_id*/ None,
Default::default(),
)
.await;
@@ -3704,8 +3701,7 @@ async fn multi_agent_v2_wait_agent_wakes_on_any_mailbox_notification() {
"from worker b".to_string(),
/*trigger_turn*/ false,
),
/*parent_turn_id*/ None,
/*root_turn_id*/ None,
Default::default(),
)
.await;
@@ -3796,8 +3792,7 @@ async fn multi_agent_v2_wait_agent_does_not_return_completed_content() {
"sensitive child output".to_string(),
/*trigger_turn*/ false,
),
/*parent_turn_id*/ None,
/*root_turn_id*/ None,
Default::default(),
)
.await;
@@ -117,8 +117,12 @@ pub(super) async fn handle_message_string_tool(
receiver_thread_id,
communication,
context,
parent_turn_id,
turn.turn_metadata_state.root_turn_id(),
crate::TurnStartOptions {
parent_turn_id,
root_turn_id: turn.turn_metadata_state.root_turn_id(),
cyber_access_program: turn.cyber_access_program,
..Default::default()
},
)
.await
.map_err(|err| collab_agent_error(receiver_thread_id, err));
@@ -223,6 +223,7 @@ async fn handle_spawn_agent(
root_turn_id: turn.turn_metadata_state.root_turn_id(),
environments: Some(step_context.environments.to_selections()),
multi_agent_v2_usage_hints,
cyber_access_program: turn.cyber_access_program,
},
),
)