mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
codex: resolve model multi-agent overlay once per session
This commit is contained in:
@@ -258,7 +258,6 @@ impl AgentControl {
|
||||
&config,
|
||||
session_source,
|
||||
options.multi_agent_version,
|
||||
/*model_info*/ None,
|
||||
)
|
||||
});
|
||||
let notification_source = session_source.clone();
|
||||
@@ -385,12 +384,8 @@ impl AgentControl {
|
||||
inherited_shell_snapshot: Option<Arc<ShellSnapshot>>,
|
||||
inherited_exec_policy: Option<Arc<crate::exec_policy::ExecPolicyManager>>,
|
||||
) -> CodexResult<crate::thread_manager::NewThread> {
|
||||
let multi_agent_version = resolve_multi_agent_version(
|
||||
&config,
|
||||
&session_source,
|
||||
options.multi_agent_version,
|
||||
/*model_info*/ None,
|
||||
);
|
||||
let multi_agent_version =
|
||||
resolve_multi_agent_version(&config, &session_source, options.multi_agent_version);
|
||||
if options.fork_parent_spawn_call_id.is_none() {
|
||||
return Err(CodexErr::Fatal(
|
||||
"spawn_agent fork requires a parent spawn call id".to_string(),
|
||||
@@ -623,7 +618,6 @@ impl AgentControl {
|
||||
&config,
|
||||
&session_source,
|
||||
stored_thread.multi_agent_version,
|
||||
/*model_info*/ None,
|
||||
);
|
||||
if let SessionSource::SubAgent(SubAgentSource::ThreadSpawn { depth, .. }) = &session_source
|
||||
&& *depth >= config.agent_max_depth
|
||||
|
||||
@@ -543,8 +543,8 @@ impl Codex {
|
||||
&session_source,
|
||||
conversation_history
|
||||
.get_multi_agent_version()
|
||||
.or(parent_multi_agent_version),
|
||||
Some(&model_info),
|
||||
.or(parent_multi_agent_version)
|
||||
.or(model_info.multi_agent_version),
|
||||
);
|
||||
if let SessionSource::SubAgent(SubAgentSource::ThreadSpawn { depth, .. }) = session_source
|
||||
&& depth >= config.agent_max_depth
|
||||
|
||||
@@ -7237,7 +7237,6 @@ async fn build_initial_context_adds_multi_agent_v2_usage_hint_when_selector_is_v
|
||||
#[tokio::test]
|
||||
async fn spawned_child_multi_agent_version_follows_parent_system() {
|
||||
let (_session, turn_context) = make_session_and_context().await;
|
||||
let mut model_info = turn_context.model_info.clone();
|
||||
let child_source = SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
|
||||
parent_thread_id: ThreadId::new(),
|
||||
depth: 1,
|
||||
@@ -7245,20 +7244,16 @@ async fn spawned_child_multi_agent_version_follows_parent_system() {
|
||||
agent_nickname: None,
|
||||
agent_role: None,
|
||||
});
|
||||
model_info.multi_agent_version = Some(MultiAgentVersion::V1);
|
||||
let resolved_from_v2_parent = resolve_multi_agent_version(
|
||||
turn_context.config.as_ref(),
|
||||
&child_source,
|
||||
Some(MultiAgentVersion::V2),
|
||||
Some(&model_info),
|
||||
);
|
||||
|
||||
model_info.multi_agent_version = Some(MultiAgentVersion::V2);
|
||||
let resolved_from_v1_parent = resolve_multi_agent_version(
|
||||
turn_context.config.as_ref(),
|
||||
&child_source,
|
||||
Some(MultiAgentVersion::V1),
|
||||
Some(&model_info),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
|
||||
@@ -110,7 +110,6 @@ pub(crate) fn resolve_multi_agent_version(
|
||||
config: &Config,
|
||||
session_source: &SessionSource,
|
||||
inherited_multi_agent_version: Option<MultiAgentVersion>,
|
||||
model_info: Option<&ModelInfo>,
|
||||
) -> Option<MultiAgentVersion> {
|
||||
if is_guardian_reviewer_source(session_source)
|
||||
|| matches!(
|
||||
@@ -120,17 +119,15 @@ pub(crate) fn resolve_multi_agent_version(
|
||||
{
|
||||
return None;
|
||||
}
|
||||
inherited_multi_agent_version
|
||||
.or_else(|| model_info.and_then(|model_info| model_info.multi_agent_version))
|
||||
.or_else(|| {
|
||||
if config.features.enabled(Feature::MultiAgentV2) {
|
||||
Some(MultiAgentVersion::V2)
|
||||
} else if config.features.enabled(Feature::Collab) {
|
||||
Some(MultiAgentVersion::V1)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
inherited_multi_agent_version.or_else(|| {
|
||||
if config.features.enabled(Feature::MultiAgentV2) {
|
||||
Some(MultiAgentVersion::V2)
|
||||
} else if config.features.enabled(Feature::Collab) {
|
||||
Some(MultiAgentVersion::V1)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
impl TurnContext {
|
||||
|
||||
@@ -922,7 +922,6 @@ impl ThreadManager {
|
||||
&config,
|
||||
&session_source,
|
||||
history.get_multi_agent_version(),
|
||||
/*model_info*/ None,
|
||||
);
|
||||
let interrupted_marker =
|
||||
InterruptedTurnHistoryMarker::from_config(&config, multi_agent_version);
|
||||
|
||||
@@ -886,7 +886,6 @@ async fn resolved_multi_agent_version_controls_runtime_behavior() {
|
||||
turn.config.as_ref(),
|
||||
&turn.session_source,
|
||||
/*inherited_multi_agent_version*/ None,
|
||||
Some(&turn.model_info),
|
||||
);
|
||||
})
|
||||
.await;
|
||||
@@ -907,7 +906,6 @@ async fn resolved_multi_agent_version_controls_runtime_behavior() {
|
||||
turn.config.as_ref(),
|
||||
&turn.session_source,
|
||||
/*inherited_multi_agent_version*/ None,
|
||||
Some(&turn.model_info),
|
||||
);
|
||||
})
|
||||
.await;
|
||||
@@ -933,7 +931,6 @@ async fn resolved_multi_agent_version_controls_runtime_behavior() {
|
||||
turn.config.as_ref(),
|
||||
&turn.session_source,
|
||||
Some(MultiAgentVersion::V1),
|
||||
Some(&turn.model_info),
|
||||
);
|
||||
})
|
||||
.await;
|
||||
|
||||
Reference in New Issue
Block a user