mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:50:52 +00:00
Enable CLI Daybreak by default and enforce background-turn eligibility (#53701)
## What changed - Mark `cli_daybreak` as stable and enable it by default. - Apply Daybreak to background turns only for eligible OpenAI accounts, allowing API-key accounts when `api_key_cyber_access_programs` is enabled. Preserve saved settings for ineligible accounts and report account lookup failures when Daybreak is enabled for the OpenAI provider. - Skip inheriting Daybreak configuration when the app server does not support reading effective configuration. ## Testing Expand dynamic-tool request tests to cover the feature toggle, ChatGPT and API-key authentication, API-key program eligibility, and unsupported configuration reads. GitOrigin-RevId: 55a57315c9f527f977dd8305ea62d4096ed7dae9
This commit is contained in:
@@ -1411,8 +1411,8 @@ pub const FEATURES: &[FeatureSpec] = &[
|
||||
FeatureSpec {
|
||||
id: Feature::CliDaybreak,
|
||||
key: "cli_daybreak",
|
||||
stage: Stage::UnderDevelopment,
|
||||
default_enabled: false,
|
||||
stage: Stage::Stable,
|
||||
default_enabled: true,
|
||||
},
|
||||
FeatureSpec {
|
||||
id: Feature::ApiKeyCyberAccessPrograms,
|
||||
|
||||
@@ -65,9 +65,6 @@ async fn daybreak_command_persists_and_confirms_each_selection() -> Result<()> {
|
||||
use codex_protocol::turn_input::CyberAccessProgram;
|
||||
|
||||
let (mut app, mut events, mut ops) = make_test_app_with_channels().await;
|
||||
app.config.features.enable(Feature::CliDaybreak)?;
|
||||
app.chat_widget
|
||||
.set_feature_enabled(Feature::CliDaybreak, /*enabled*/ true);
|
||||
let (mut server, requests, proxy) = start_recording_app_server(
|
||||
&app.config,
|
||||
/*blocked_thread_list*/ None,
|
||||
@@ -1860,18 +1857,57 @@ async fn embedded_server_rejects_unowned_dynamic_tool_calls() -> Result<()> {
|
||||
|
||||
#[tokio::test]
|
||||
async fn dynamic_tool_requests_ignore_other_namespaces_and_dispatch_tui_namespace() -> Result<()> {
|
||||
boxed_future!(check_dynamic_tool_requests(/*rollout_enabled*/ true)).await?;
|
||||
boxed_future!(check_dynamic_tool_requests(/*rollout_enabled*/ false)).await
|
||||
use HistoryCapabilities::ConfigReadUnsupported;
|
||||
use HistoryCapabilities::Current;
|
||||
use codex_app_server_protocol::AuthMode::ApiKey;
|
||||
use codex_app_server_protocol::AuthMode::Chatgpt;
|
||||
|
||||
for (
|
||||
rollout_enabled,
|
||||
auth_mode,
|
||||
api_key_cyber_access_programs,
|
||||
history_capabilities,
|
||||
expected_program,
|
||||
) in [
|
||||
(true, Chatgpt, false, Current, Some("daybreakBlue")),
|
||||
(false, Chatgpt, false, Current, None),
|
||||
(true, ApiKey, false, Current, None),
|
||||
(true, ApiKey, true, Current, Some("daybreakBlue")),
|
||||
(true, Chatgpt, false, ConfigReadUnsupported(-32601), None),
|
||||
(true, Chatgpt, false, ConfigReadUnsupported(-32600), None),
|
||||
] {
|
||||
boxed_future!(check_dynamic_tool_requests(
|
||||
rollout_enabled,
|
||||
auth_mode,
|
||||
api_key_cyber_access_programs,
|
||||
history_capabilities,
|
||||
expected_program,
|
||||
))
|
||||
.await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn check_dynamic_tool_requests(rollout_enabled: bool) -> Result<()> {
|
||||
async fn check_dynamic_tool_requests(
|
||||
rollout_enabled: bool,
|
||||
auth_mode: codex_app_server_protocol::AuthMode,
|
||||
api_key_cyber_access_programs: bool,
|
||||
history_capabilities: HistoryCapabilities,
|
||||
expected_program: Option<&str>,
|
||||
) -> Result<()> {
|
||||
let (mut app, mut events, _ops) = make_test_app_with_channels().await;
|
||||
app.config
|
||||
.features
|
||||
.set_enabled(Feature::CliDaybreak, rollout_enabled)?;
|
||||
app.config.features.set_enabled(
|
||||
Feature::ApiKeyCyberAccessPrograms,
|
||||
api_key_cyber_access_programs,
|
||||
)?;
|
||||
let codex_home = tempdir()?;
|
||||
let backend = wiremock::MockServer::start().await;
|
||||
let backend_url = format!("{}/backend-api", backend.uri());
|
||||
let api_url = format!("{}/v1", backend.uri());
|
||||
app.config.model_provider.base_url = Some(api_url.clone());
|
||||
app.config.codex_home = codex_home.path().to_path_buf().abs();
|
||||
app.config.sqlite = SqliteConfig::new_for_testing(codex_home.path().abs());
|
||||
let mut catalog = codex_models_manager::bundled_models_response()?;
|
||||
@@ -1886,7 +1922,7 @@ async fn check_dynamic_tool_requests(rollout_enabled: bool) -> Result<()> {
|
||||
std::fs::write(
|
||||
codex_home.path().join("config.toml"),
|
||||
format!(
|
||||
"daybreak = true\nmodel_catalog_json = {:?}\nchatgpt_base_url = {backend_url:?}\ncli_auth_credentials_store = \"file\"\n",
|
||||
"daybreak = true\nmodel_catalog_json = {:?}\nchatgpt_base_url = {backend_url:?}\ncli_auth_credentials_store = \"file\"\nopenai_base_url = {api_url:?}\n",
|
||||
catalog_path.display().to_string()
|
||||
),
|
||||
)?;
|
||||
@@ -1901,6 +1937,14 @@ async fn check_dynamic_tool_requests(rollout_enabled: bool) -> Result<()> {
|
||||
codex_login::AuthCredentialsStoreMode::File,
|
||||
)
|
||||
.expect("write fixture auth");
|
||||
if auth_mode == codex_app_server_protocol::AuthMode::ApiKey {
|
||||
codex_login::login_with_api_key(
|
||||
codex_home.path(),
|
||||
"test-key",
|
||||
codex_login::AuthCredentialsStoreMode::File,
|
||||
codex_login::AuthKeyringBackendKind::default(),
|
||||
)?;
|
||||
}
|
||||
app.config
|
||||
.permissions
|
||||
.set_permission_profile(PermissionProfile::workspace_write_with(
|
||||
@@ -1909,10 +1953,13 @@ async fn check_dynamic_tool_requests(rollout_enabled: bool) -> Result<()> {
|
||||
/*exclude_tmpdir_env_var*/ true,
|
||||
/*exclude_slash_tmp*/ true,
|
||||
))?;
|
||||
let (mut app_server, requests, proxy) = start_recording_app_server(
|
||||
let (mut app_server, requests, proxy) = start_recording_app_server_with_history(
|
||||
&app.config,
|
||||
history_capabilities,
|
||||
/*blocked_thread_list*/ None,
|
||||
/*failed_thread_name*/ Some("Unavailable name"),
|
||||
crate::app_server_session::ThreadParamsMode::Embedded,
|
||||
LoaderOverrides::without_managed_config_for_tests(),
|
||||
)
|
||||
.await?;
|
||||
let thread_id = app_server
|
||||
@@ -2181,7 +2228,10 @@ async fn check_dynamic_tool_requests(rollout_enabled: bool) -> Result<()> {
|
||||
);
|
||||
assert_eq!(
|
||||
recorded_params(&requests, "thread/start").last().unwrap()["daybreakEnabled"],
|
||||
serde_json::json!(rollout_enabled.then_some(true))
|
||||
serde_json::json!(
|
||||
(rollout_enabled && history_capabilities == HistoryCapabilities::Current)
|
||||
.then_some(true)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
recorded_params(&requests, "thread/start")
|
||||
@@ -2198,7 +2248,7 @@ async fn check_dynamic_tool_requests(rollout_enabled: bool) -> Result<()> {
|
||||
.expect("background task turn request");
|
||||
assert_eq!(
|
||||
turn["cyberAccessProgram"],
|
||||
serde_json::json!(rollout_enabled.then_some("daybreakBlue"))
|
||||
serde_json::json!(expected_program)
|
||||
);
|
||||
assert_eq!(turn["input"], serde_json::json!([]));
|
||||
assert_eq!(
|
||||
@@ -2283,7 +2333,7 @@ async fn check_dynamic_tool_requests(rollout_enabled: bool) -> Result<()> {
|
||||
let turn = &recorded_params(&requests, "turn/start")[1];
|
||||
assert_eq!(
|
||||
turn["cyberAccessProgram"],
|
||||
serde_json::json!(rollout_enabled.then_some("daybreakBlue"))
|
||||
serde_json::json!(expected_program)
|
||||
);
|
||||
assert_eq!(turn["input"], serde_json::json!([]));
|
||||
assert_eq!(
|
||||
|
||||
@@ -16,6 +16,7 @@ use pretty_assertions::assert_eq;
|
||||
#[tokio::test]
|
||||
async fn resumed_initial_messages_render_history() {
|
||||
let (mut chat, mut rx, _ops) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.set_feature_enabled(Feature::CliDaybreak, /*enabled*/ false);
|
||||
|
||||
let thread_id = ThreadId::new();
|
||||
let rollout_file = NamedTempFile::new().unwrap();
|
||||
|
||||
@@ -2218,7 +2218,6 @@ async fn slash_copy_picker_remains_available_from_parent_owned_threads() {
|
||||
#[tokio::test]
|
||||
async fn slash_daybreak_offers_an_application_when_unavailable() {
|
||||
let (mut chat, mut rx, _ops) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.set_feature_enabled(Feature::CliDaybreak, /*enabled*/ true);
|
||||
chat.has_chatgpt_account = true;
|
||||
chat.config.model_provider_id = "openai".into();
|
||||
let mut model = crate::test_support::TEST_MODEL_PRESETS[0].clone();
|
||||
|
||||
@@ -446,6 +446,7 @@ async fn status_line_setup_popup_rate_limits_snapshot() {
|
||||
#[tokio::test]
|
||||
async fn status_line_setup_popup_mixed_snapshot() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.has_chatgpt_account = true;
|
||||
chat.set_feature_enabled(Feature::CliDaybreak, /*enabled*/ true);
|
||||
chat.status_line_branch = Some("feature/mixed-preview".to_string());
|
||||
chat.thread_name = Some("Mixed preview thread".to_string());
|
||||
@@ -501,6 +502,7 @@ async fn terminal_title_setup_popup_hardcoded_only_snapshot() {
|
||||
#[tokio::test]
|
||||
async fn terminal_title_setup_popup_mixed_snapshot() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.has_chatgpt_account = true;
|
||||
chat.set_feature_enabled(Feature::CliDaybreak, /*enabled*/ true);
|
||||
chat.thread_name = Some("Mixed preview thread".to_string());
|
||||
chat.set_daybreak_enabled(/*enabled*/ true);
|
||||
|
||||
@@ -494,17 +494,19 @@ async fn execute_inner(
|
||||
if features.enabled(Feature::CliDaybreak)
|
||||
&& thread_start_params.daybreak_enabled.is_none()
|
||||
{
|
||||
let defaults = crate::config_update::read_effective_config(
|
||||
let defaults = crate::config_update::read_effective_config_if_supported(
|
||||
handle.clone(),
|
||||
source_thread.cwd.to_string_lossy().into_owned(),
|
||||
source_thread.cwd.as_path(),
|
||||
)
|
||||
.await
|
||||
.map_err(|error| error.to_string())?;
|
||||
thread_start_params.daybreak_enabled = defaults
|
||||
.config
|
||||
.additional
|
||||
.get("daybreak")
|
||||
.and_then(Value::as_bool);
|
||||
thread_start_params.daybreak_enabled = defaults.and_then(|defaults| {
|
||||
defaults
|
||||
.config
|
||||
.additional
|
||||
.get("daybreak")
|
||||
.and_then(Value::as_bool)
|
||||
});
|
||||
}
|
||||
thread_start_params.history_mode = (source_thread.history_mode
|
||||
== ThreadHistoryMode::Paginated)
|
||||
@@ -1283,11 +1285,23 @@ async fn background_turn_program(
|
||||
},
|
||||
}),
|
||||
);
|
||||
let account = match account {
|
||||
Ok(response) => response.account,
|
||||
Err(error) if enabled && provider == "openai" => {
|
||||
return Err(format!(
|
||||
"Could not determine Daybreak account eligibility: {error}"
|
||||
));
|
||||
}
|
||||
Err(_) => None,
|
||||
};
|
||||
let has_chatgpt_account = matches!(account, Some(Account::Chatgpt { .. }));
|
||||
let eligible = provider == "openai"
|
||||
&& matches!(
|
||||
account.ok().and_then(|response| response.account),
|
||||
Some(Account::Chatgpt { .. })
|
||||
);
|
||||
&& (has_chatgpt_account
|
||||
|| enabled
|
||||
&& matches!(account, Some(Account::ApiKey { .. }))
|
||||
&& features.enabled(Feature::ApiKeyCyberAccessPrograms));
|
||||
// Retain saved metadata while suppressing it for accounts that cannot use Daybreak.
|
||||
let enabled = enabled && eligible;
|
||||
let models = models
|
||||
.map(|response| {
|
||||
response
|
||||
|
||||
Reference in New Issue
Block a user