Improve orchestration agent model selection
This commit is contained in:
@@ -1247,7 +1247,7 @@ pub fn compose_run_agents_child_prompt(base_prompt: &str, per_agent_prompt: &str
|
||||
}
|
||||
}
|
||||
|
||||
/// Translates run-wide config into a per-child
|
||||
/// Translates shared config and the child's model selection into a per-child
|
||||
/// [`StartAgentExecutionMode`]. Returns `Err` for rejected
|
||||
/// combinations (e.g. OpenCode+Remote).
|
||||
///
|
||||
@@ -1262,12 +1262,15 @@ pub fn run_agents_to_start_agent_mode(
|
||||
run_auth_secret_name: Option<&str>,
|
||||
cfg: &RunAgentsAgentRunConfig,
|
||||
) -> Result<StartAgentExecutionMode, String> {
|
||||
let child_model_id = if cfg.model_id.trim().is_empty() {
|
||||
run_model_id.trim()
|
||||
} else {
|
||||
cfg.model_id.trim()
|
||||
};
|
||||
match run_execution_mode {
|
||||
RunAgentsExecutionMode::Local => {
|
||||
let trimmed = run_harness_type.trim();
|
||||
// Propagate run-wide model selection for local launches.
|
||||
let trimmed_model_id = run_model_id.trim();
|
||||
let model_id = (!trimmed_model_id.is_empty()).then(|| trimmed_model_id.to_string());
|
||||
let model_id = (!child_model_id.is_empty()).then(|| child_model_id.to_string());
|
||||
if trimmed.is_empty() || trimmed.eq_ignore_ascii_case("oz") {
|
||||
Ok(StartAgentExecutionMode::Local {
|
||||
harness_type: None,
|
||||
@@ -1299,7 +1302,7 @@ pub fn run_agents_to_start_agent_mode(
|
||||
Ok(StartAgentExecutionMode::Remote {
|
||||
environment_id: environment_id.clone(),
|
||||
skill_references: run_skills.to_vec(),
|
||||
model_id: run_model_id.to_string(),
|
||||
model_id: child_model_id.to_string(),
|
||||
computer_use_enabled: *computer_use_enabled,
|
||||
worker_host: worker_host.clone(),
|
||||
harness_type: run_harness_type.to_string(),
|
||||
|
||||
@@ -266,6 +266,7 @@ fn execute_denies_mixed_batch_containing_launched_agent() {
|
||||
name: "new-child".to_string(),
|
||||
prompt: "Do separate work".to_string(),
|
||||
title: String::new(),
|
||||
model_id: String::new(),
|
||||
});
|
||||
|
||||
let execution = state.executor.update(&mut app, |executor, ctx| {
|
||||
@@ -306,6 +307,7 @@ fn validate_request_rejects_blank_and_duplicate_agent_names() {
|
||||
name: " child ".to_string(),
|
||||
prompt: "Do separate work".to_string(),
|
||||
title: String::new(),
|
||||
model_id: String::new(),
|
||||
});
|
||||
assert_eq!(
|
||||
validate_request(&request),
|
||||
@@ -323,6 +325,7 @@ fn validate_request_allows_unique_sibling_names() {
|
||||
name: "second-child".to_string(),
|
||||
prompt: "Do separate work".to_string(),
|
||||
title: String::new(),
|
||||
model_id: String::new(),
|
||||
});
|
||||
|
||||
assert_eq!(validate_request(&request), Ok(()));
|
||||
@@ -384,6 +387,7 @@ fn recovered_run_agents_reattaches_existing_child_and_launches_only_missing_chil
|
||||
name: "missing-child".to_string(),
|
||||
prompt: "Do separate work".to_string(),
|
||||
title: String::new(),
|
||||
model_id: String::new(),
|
||||
});
|
||||
state.executor.update(&mut app, |executor, _| {
|
||||
executor
|
||||
@@ -454,12 +458,12 @@ fn recovered_run_agents_reattaches_existing_child_and_launches_only_missing_chil
|
||||
assert_eq!(agents.len(), 2);
|
||||
assert!(matches!(
|
||||
&agents[0].kind,
|
||||
RunAgentsAgentOutcomeKind::Launched { agent_id }
|
||||
RunAgentsAgentOutcomeKind::Completed { agent_id, .. }
|
||||
if agent_id == &existing_child_id.to_string()
|
||||
));
|
||||
assert!(matches!(
|
||||
&agents[1].kind,
|
||||
RunAgentsAgentOutcomeKind::Launched { agent_id }
|
||||
RunAgentsAgentOutcomeKind::Completed { agent_id, .. }
|
||||
if agent_id == &missing_child_id.to_string()
|
||||
));
|
||||
});
|
||||
@@ -766,6 +770,7 @@ fn remote_run_agents_action(harness_type: &str) -> AIAgentAction {
|
||||
name: "child".to_string(),
|
||||
prompt: "Help".to_string(),
|
||||
title: String::new(),
|
||||
model_id: String::new(),
|
||||
}],
|
||||
plan_id: String::new(),
|
||||
harness_auth_secret_name: None,
|
||||
@@ -789,6 +794,7 @@ fn local_codex_run_agents_maps_to_local_harness_mode_when_flag_enabled() {
|
||||
name: "child".to_string(),
|
||||
prompt: "Investigate the failure".to_string(),
|
||||
title: String::new(),
|
||||
model_id: String::new(),
|
||||
};
|
||||
|
||||
let mode = run_agents_to_start_agent_mode(
|
||||
@@ -810,6 +816,34 @@ fn local_codex_run_agents_maps_to_local_harness_mode_when_flag_enabled() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn child_model_overrides_the_run_wide_model() {
|
||||
let cfg = RunAgentsAgentRunConfig {
|
||||
name: "child".to_string(),
|
||||
prompt: "Investigate".to_string(),
|
||||
title: String::new(),
|
||||
model_id: "child-model".to_string(),
|
||||
};
|
||||
|
||||
let mode = run_agents_to_start_agent_mode(
|
||||
&RunAgentsExecutionMode::Local,
|
||||
"oz",
|
||||
"fallback-model",
|
||||
&[],
|
||||
None,
|
||||
&cfg,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
mode,
|
||||
StartAgentExecutionMode::Local {
|
||||
harness_type: None,
|
||||
model_id: Some("child-model".to_string()),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
fn persist_default_auth_secret(app: &mut App, harness_config_name: &str, secret_name: &str) {
|
||||
CloudAgentSettings::handle(app).update(app, |settings, ctx| {
|
||||
let mut secrets = settings.last_selected_auth_secret.value().clone();
|
||||
|
||||
Reference in New Issue
Block a user