mirror of
https://github.com/openai/codex.git
synced 2026-11-19 22:30:42 +00:00
Treat managed new-thread settings as defaults
This commit is contained in:
@@ -41,7 +41,6 @@ use codex_models_manager::manager::SharedModelsManager;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::config_types::CollaborationModeMask;
|
||||
use codex_protocol::config_types::MultiAgentMode;
|
||||
use codex_protocol::config_types::ServiceTier;
|
||||
use codex_protocol::error::CodexErr;
|
||||
use codex_protocol::error::Result as CodexResult;
|
||||
use codex_protocol::openai_models::ModelPreset;
|
||||
@@ -218,45 +217,6 @@ fn effective_originator_value(
|
||||
.unwrap_or(default_originator)
|
||||
}
|
||||
|
||||
fn apply_managed_new_thread_defaults(
|
||||
config: &mut Config,
|
||||
initial_history: &InitialHistory,
|
||||
session_source: &SessionSource,
|
||||
) {
|
||||
if session_source.is_non_root_agent()
|
||||
|| !matches!(
|
||||
initial_history,
|
||||
InitialHistory::New | InitialHistory::Cleared
|
||||
)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
let Some(defaults) = config
|
||||
.config_layer_stack
|
||||
.requirements_toml()
|
||||
.models
|
||||
.as_ref()
|
||||
.and_then(|models| models.new_thread.as_ref())
|
||||
else {
|
||||
return;
|
||||
};
|
||||
|
||||
if let Some(model) = defaults.model.as_ref() {
|
||||
config.model = Some(model.clone());
|
||||
}
|
||||
if let Some(model_reasoning_effort) = defaults.model_reasoning_effort.as_ref() {
|
||||
config.model_reasoning_effort = Some(model_reasoning_effort.clone());
|
||||
}
|
||||
if let Some(service_tier) = defaults.service_tier.as_ref() {
|
||||
config.service_tier = Some(
|
||||
ServiceTier::from_request_value(service_tier)
|
||||
.map(|tier| tier.request_value().to_string())
|
||||
.unwrap_or_else(|| service_tier.clone()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct ResumeThreadWithHistoryOptions {
|
||||
pub(crate) config: Config,
|
||||
pub(crate) initial_history: InitialHistory,
|
||||
@@ -1538,7 +1498,7 @@ impl ThreadManagerState {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(crate) async fn spawn_thread_with_source(
|
||||
&self,
|
||||
mut config: Config,
|
||||
config: Config,
|
||||
initial_history: InitialHistory,
|
||||
auth_manager: Arc<AuthManager>,
|
||||
agent_control: AgentControl,
|
||||
@@ -1579,7 +1539,6 @@ impl ThreadManagerState {
|
||||
threads.remove(&resumed.conversation_id);
|
||||
}
|
||||
}
|
||||
apply_managed_new_thread_defaults(&mut config, &initial_history, &session_source);
|
||||
let user_instructions = self
|
||||
.user_instructions_for_spawn(&session_source, parent_thread_id, forked_from_thread_id)
|
||||
.await;
|
||||
|
||||
@@ -16,7 +16,6 @@ use codex_protocol::models::ContentItem;
|
||||
use codex_protocol::models::ReasoningItemReasoningSummary;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
use codex_protocol::openai_models::ModelsResponse;
|
||||
use codex_protocol::openai_models::ReasoningEffort;
|
||||
use codex_protocol::protocol::AgentMessageEvent;
|
||||
use codex_protocol::protocol::InitialHistory;
|
||||
use codex_protocol::protocol::InternalSessionSource;
|
||||
@@ -79,60 +78,6 @@ impl codex_agent_graph_store::AgentGraphStore for FakeAgentGraphStore {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn managed_new_thread_defaults_only_apply_to_root_new_threads() {
|
||||
let mut base_config = test_config().await;
|
||||
base_config.model = Some("local-model".to_string());
|
||||
base_config.model_reasoning_effort = Some(ReasoningEffort::Low);
|
||||
base_config.service_tier = Some("flex".to_string());
|
||||
base_config.config_layer_stack = codex_config::ConfigLayerStack::new(
|
||||
Vec::new(),
|
||||
codex_config::ConfigRequirements::default(),
|
||||
codex_config::ConfigRequirementsToml {
|
||||
models: Some(codex_config::ModelsRequirementsToml {
|
||||
new_thread: Some(codex_config::NewThreadModelDefaultsToml {
|
||||
model: Some("managed-model".to_string()),
|
||||
model_reasoning_effort: Some(ReasoningEffort::Medium),
|
||||
service_tier: Some("fast".to_string()),
|
||||
}),
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.expect("build managed requirements stack");
|
||||
|
||||
let cases = [
|
||||
(
|
||||
InitialHistory::New,
|
||||
SessionSource::VSCode,
|
||||
("managed-model", ReasoningEffort::Medium, "priority"),
|
||||
),
|
||||
(
|
||||
InitialHistory::Cleared,
|
||||
SessionSource::VSCode,
|
||||
("managed-model", ReasoningEffort::Medium, "priority"),
|
||||
),
|
||||
(
|
||||
InitialHistory::Forked(Vec::new()),
|
||||
SessionSource::VSCode,
|
||||
("local-model", ReasoningEffort::Low, "flex"),
|
||||
),
|
||||
(
|
||||
InitialHistory::New,
|
||||
SessionSource::SubAgent(SubAgentSource::Review),
|
||||
("local-model", ReasoningEffort::Low, "flex"),
|
||||
),
|
||||
];
|
||||
|
||||
for (history, source, (expected_model, expected_effort, expected_service_tier)) in cases {
|
||||
let mut config = base_config.clone();
|
||||
apply_managed_new_thread_defaults(&mut config, &history, &source);
|
||||
assert_eq!(config.model.as_deref(), Some(expected_model));
|
||||
assert_eq!(config.model_reasoning_effort, Some(expected_effort));
|
||||
assert_eq!(config.service_tier.as_deref(), Some(expected_service_tier));
|
||||
}
|
||||
}
|
||||
|
||||
fn user_msg(text: &str) -> ResponseItem {
|
||||
ResponseItem::Message {
|
||||
id: None,
|
||||
|
||||
Reference in New Issue
Block a user