Capture saved Daybreak preferences for native helpers (#60749)

## What changed

Add the disabled-by-default `daybreak_program_propagation` feature to capture a parent's saved Daybreak choice when spawning native helpers. Retain the choice and account identity for helper turns and nested spawns, while preserving explicit `cyber_access_program` overrides. A helper's own saved preference takes precedence on later turns.

Read pending metadata before persisted metadata so preferences survive thread materialization, with stored choices taking precedence. Share this resolution logic with `thread/read` and support refreshing the feature through user configuration.

## Testing

Add coverage for saved and pending preferences, unset choices, explicit overrides, failed metadata reads, nested spawns, parent unloading, feature withdrawal, and preference changes between helper turns.

GitOrigin-RevId: b3b349da8cb3d48154cddf058890587385efcda2
This commit is contained in:
jamy-OAI
2026-11-11 07:39:04 +00:00
committed by copyberry
parent c320b5c69e
commit d9a32c1789
23 changed files with 780 additions and 24 deletions
+5 -1
View File
@@ -1,4 +1,4 @@
//! Publishes resolved MCP configuration and host timing rollouts for future turns.
//! Publishes refreshable configuration while preserving unrelated session settings.
use crate::McpRefreshReason;
use std::sync::Arc;
@@ -98,6 +98,10 @@ impl Session {
if !matches!(scope, RuntimeConfigRefresh::UserFiles) {
for (feature, description) in [
(Feature::Mcp20260728, "MCP protocol"),
(
Feature::DaybreakProgramPropagation,
"Daybreak helper propagation",
),
(Feature::CodexAppsMcp20260728, "Codex Apps MCP protocol"),
] {
if let Err(err) = config
+10
View File
@@ -1183,6 +1183,16 @@ impl Session {
)),
);
}
// Native children receive their enrollment at spawn. A cold resume or durable fork
// has no live attachment, even when the rollout is enabled at startup.
if matches!(
&initial_history,
InitialHistory::New | InitialHistory::Cleared
) && !session_source.is_non_root_agent()
&& config.features.enabled(Feature::DaybreakProgramPropagation)
{
thread_extension_data.insert(crate::agent::helper_daybreak::Enrollment::Root);
}
thread_extension_data.insert(crate::context::GuardianReviewEvidence::default());
crate::model_search::SearchOwner::restore(&thread_extension_data, &initial_history);
// Kick off independent async setup tasks in parallel to reduce startup latency.
@@ -338,6 +338,7 @@ pub(crate) struct NewTurnContextOptions {
pub(crate) final_output_json_schema: Option<Value>,
pub(crate) prompt_cache_ttl: Option<crate::PromptCacheTtl>,
pub(crate) cyber_access_program: Option<CyberAccessProgram>,
pub(crate) helper_admission: Option<crate::agent::helper_daybreak::turn::HelperTurnAdmission>,
}
/// The context needed for a single turn of the thread.
@@ -1489,6 +1490,9 @@ impl Session {
turn_context.prompt_cache_ttl = options.prompt_cache_ttl;
turn_context.cyber_access_program =
cyber_access_program::for_provider(&turn_context.config, options.cyber_access_program);
if let Some(admission) = options.helper_admission {
admission.capture_intent(self, &turn_context).await;
}
// Tool observers retain this turn's selection even after a later turn starts.
if let Some(program) = turn_context.cyber_access_program {
turn_context.extension_data.insert(program);
+8
View File
@@ -22,6 +22,7 @@ use super::thread_settings;
use super::turn_context::NewTurnContextOptions;
use super::turn_context::TurnContext;
use crate::WithTurnExtensionData;
use crate::agent::helper_daybreak::turn::HelperTurnAdmission;
use crate::context::ContextualUserFragment;
use crate::context::GuardianSenderMessages;
use crate::state::ActiveTurn;
@@ -160,6 +161,12 @@ impl PreparedTurnInputSettings {
root_turn_id,
cyber_access_program,
} = self.start_options;
let helper_admission =
if kind == TurnStartKind::User && turn_trigger.as_deref() != Some("queue") {
HelperTurnAdmission::capture(session)
} else {
None
};
let emit_thread_settings_applied = self.thread_settings_update.is_some();
let _settings_guard = if emit_thread_settings_applied {
Some(thread_settings::acquire_persistence_lock(session).await)
@@ -174,6 +181,7 @@ impl PreparedTurnInputSettings {
final_output_json_schema,
prompt_cache_ttl,
cyber_access_program,
helper_admission,
};
let turn_context = match kind {
TurnStartKind::User | TurnStartKind::Recovery => Some(