mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Validate reasoning effort after applying spawn roles (#33656)
## Why Agent roles can override the model or reasoning effort after the initial `spawn_agent` configuration is validated, leaving an unsupported combination unchecked. ## What changed - Validate the final reasoning effort against model metadata whenever a role changes the spawned agent's model settings. - Preserve independently configured subagent defaults when a role does not override them. - Apply the same role validation in both multi-agent spawn implementations. ## Testing Added coverage for independent model and reasoning defaults, instruction-only roles, and rejection of a reasoning effort unsupported by a role-selected model. GitOrigin-RevId: 1885314e9380f778603f067fc04a6225ee963428
This commit is contained in:
1 parent
726b6378d2
commit
8a7c854bff
4 files changed
+198
-9
No files matched your search
@@ -5,7 +5,6 @@ use crate::agent::control::render_input_preview;
|
||||
use crate::agent::exceeds_thread_spawn_depth_limit;
|
||||
use crate::agent::next_thread_spawn_depth;
|
||||
use crate::agent::role::DEFAULT_ROLE_NAME;
|
||||
use crate::agent::role::apply_role_to_config;
|
||||
use crate::tools::handlers::multi_agents_spec::SpawnAgentToolOptions;
|
||||
use crate::tools::handlers::multi_agents_spec::create_spawn_agent_tool_v1;
|
||||
use codex_tools::ToolSpec;
|
||||
@@ -103,9 +102,7 @@ async fn handle_spawn_agent(
|
||||
)
|
||||
.await?;
|
||||
if !args.fork_context {
|
||||
apply_role_to_config(&mut config, role_name)
|
||||
.await
|
||||
.map_err(FunctionCallError::RespondToModel)?;
|
||||
apply_spawn_agent_role(&session, &mut config, role_name).await?;
|
||||
}
|
||||
apply_spawn_agent_service_tier(
|
||||
&session,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::agent::role::apply_role_to_config;
|
||||
use crate::config::Config;
|
||||
use crate::config::DEFAULT_MULTI_AGENT_V2_MIN_WAIT_TIMEOUT_MS;
|
||||
use crate::config::HARD_MAX_MULTI_AGENT_V2_TIMEOUT_MS;
|
||||
@@ -353,6 +354,46 @@ pub(crate) async fn apply_spawn_agent_service_tier(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn apply_spawn_agent_role(
|
||||
session: &Session,
|
||||
config: &mut Config,
|
||||
role_name: Option<&str>,
|
||||
) -> Result<(), FunctionCallError> {
|
||||
let previous_model = config.model.clone();
|
||||
let previous_reasoning_effort = config.model_reasoning_effort.clone();
|
||||
apply_role_to_config(config, role_name)
|
||||
.await
|
||||
.map_err(FunctionCallError::RespondToModel)?;
|
||||
if config.model == previous_model && config.model_reasoning_effort == previous_reasoning_effort
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let Some(reasoning_effort) = config.model_reasoning_effort.clone() else {
|
||||
return Ok(());
|
||||
};
|
||||
let model = config.model.clone().ok_or_else(|| {
|
||||
FunctionCallError::RespondToModel(
|
||||
"spawn_agent could not resolve the child model for reasoning effort validation"
|
||||
.to_string(),
|
||||
)
|
||||
})?;
|
||||
let model_info = session
|
||||
.services
|
||||
.models_manager
|
||||
.get_model_info(&model, &config.to_models_manager_config())
|
||||
.await;
|
||||
if model_info.used_fallback_model_metadata {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
validate_spawn_agent_reasoning_effort(
|
||||
&model,
|
||||
&model_info.supported_reasoning_levels,
|
||||
&reasoning_effort,
|
||||
)
|
||||
}
|
||||
|
||||
fn find_spawn_agent_model_name(
|
||||
available_models: &[ModelPreset],
|
||||
requested_model: &str,
|
||||
|
||||
@@ -3,7 +3,6 @@ use crate::agent::control::SpawnAgentForkMode;
|
||||
use crate::agent::control::SpawnAgentOptions;
|
||||
use crate::agent::next_thread_spawn_depth;
|
||||
use crate::agent::role::DEFAULT_ROLE_NAME;
|
||||
use crate::agent::role::apply_role_to_config;
|
||||
use crate::agent_communication::AgentCommunicationContext;
|
||||
use crate::agent_communication::AgentCommunicationKind;
|
||||
use crate::tools::handlers::multi_agents_spec::SpawnAgentToolOptions;
|
||||
@@ -77,9 +76,7 @@ async fn handle_spawn_agent(
|
||||
)
|
||||
.await?;
|
||||
if !is_full_history_fork {
|
||||
apply_role_to_config(&mut config, role_name)
|
||||
.await
|
||||
.map_err(FunctionCallError::RespondToModel)?;
|
||||
apply_spawn_agent_role(&session, &mut config, role_name).await?;
|
||||
}
|
||||
apply_spawn_agent_service_tier(
|
||||
&session,
|
||||
|
||||
Reference in new issue
Block a user