mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Simplify multi-agent mode controls (#29324)
## Why Multi-agent delegation policy was split across `multiAgentMode`, `features.multi_agent_mode`, and `usage_hint_enabled`. These controls could disagree: a requested mode could be downgraded by the feature flag, and disabling usage hints also disabled mode instructions. Some clients also need multi-agent tools without adding delegation-policy text to model context. The previous two-mode API could not express that directly. ## What changed `multiAgentMode` is now the only live delegation-policy control: | Mode | Behavior | | --- | --- | | `none` | Keep multi-agent tools available without adding mode instructions. | | `explicitRequestOnly` | Only delegate after an explicit user request. | | `proactive` | Delegate when parallel work materially improves speed or quality. | - new threads default to `explicitRequestOnly`; omitting the mode on later turns keeps the current value - thread start, resume, fork, and settings responses always report the concrete current mode instead of `null` - mode selection remains sticky across turns and resume - usage-hint text no longer controls whether mode instructions apply - `features.multi_agent_mode` and `usage_hint_enabled` remain accepted as ignored compatibility settings so existing configs continue to load - app-server documentation and generated schemas describe the three-mode API ## Tests - `just test -p codex-core multi_agent_mode` - `just test -p codex-core multi_agent_v2_config_from_feature_table` - `just test -p codex-core spawn_agent_description` - `just test -p codex-features` - `just test -p codex-app-server-protocol` - `just test -p codex-app-server multi_agent_mode`
This commit is contained in:
44 files changed
+253
-350
No files matched your search
@@ -24,7 +24,6 @@ pub struct SpawnAgentToolOptions {
|
||||
pub available_models: Vec<ModelPreset>,
|
||||
pub agent_type_description: String,
|
||||
pub hide_agent_type_model_reasoning: bool,
|
||||
pub include_usage_hint: bool,
|
||||
pub usage_hint_text: Option<String>,
|
||||
}
|
||||
|
||||
@@ -66,7 +65,6 @@ pub fn create_spawn_agent_tool_v1(options: SpawnAgentToolOptions) -> ToolSpec {
|
||||
available_models_description.as_deref(),
|
||||
inherited_model_guidance,
|
||||
return_value_description,
|
||||
options.include_usage_hint,
|
||||
options.usage_hint_text,
|
||||
),
|
||||
strict: false,
|
||||
@@ -99,7 +97,6 @@ pub fn create_spawn_agent_tool_v2(options: SpawnAgentToolOptions) -> ToolSpec {
|
||||
description: spawn_agent_tool_description_v2(
|
||||
available_models_description.as_deref(),
|
||||
inherited_model_guidance,
|
||||
options.include_usage_hint,
|
||||
options.usage_hint_text,
|
||||
),
|
||||
strict: false,
|
||||
@@ -648,7 +645,6 @@ fn spawn_agent_tool_description(
|
||||
available_models_description: Option<&str>,
|
||||
inherited_model_guidance: Option<&str>,
|
||||
return_value_description: &str,
|
||||
include_usage_hint: bool,
|
||||
usage_hint_text: Option<String>,
|
||||
) -> String {
|
||||
let agent_role_guidance = available_models_description.unwrap_or_default();
|
||||
@@ -660,9 +656,6 @@ fn spawn_agent_tool_description(
|
||||
Spawn a sub-agent for a well-scoped task. {return_value_description} {inherited_model_guidance}"#
|
||||
);
|
||||
|
||||
if !include_usage_hint {
|
||||
return tool_description;
|
||||
}
|
||||
if let Some(usage_hint_text) = usage_hint_text {
|
||||
return format!(
|
||||
r#"
|
||||
@@ -711,7 +704,6 @@ Do not spawn sub-agents unless the user explicitly asks for sub-agents, delegati
|
||||
fn spawn_agent_tool_description_v2(
|
||||
available_models_description: Option<&str>,
|
||||
inherited_model_guidance: Option<&str>,
|
||||
include_usage_hint: bool,
|
||||
usage_hint_text: Option<String>,
|
||||
) -> String {
|
||||
let agent_role_guidance = available_models_description.unwrap_or_default();
|
||||
@@ -731,9 +723,6 @@ The new agent's canonical task name will be provided to it along with the messag
|
||||
Note that passing `fork_turns="none"` will not pass any surrounding context to the spawned subagent, which may cause the agent to lack the context it needs to complete its task, whereas `fork_turns="all"` will provide the subagent with all surrounding context."#
|
||||
);
|
||||
|
||||
if !include_usage_hint {
|
||||
return tool_description;
|
||||
}
|
||||
if let Some(usage_hint_text) = usage_hint_text {
|
||||
return format!(
|
||||
r#"
|
||||
|
||||
@@ -45,7 +45,6 @@ fn spawn_agent_tool_v2_requires_task_name_and_lists_visible_models() {
|
||||
],
|
||||
agent_type_description: "role help".to_string(),
|
||||
hide_agent_type_model_reasoning: false,
|
||||
include_usage_hint: true,
|
||||
usage_hint_text: None,
|
||||
});
|
||||
|
||||
@@ -121,7 +120,6 @@ fn spawn_agent_tool_v1_keeps_legacy_fork_context_field() {
|
||||
available_models: Vec::new(),
|
||||
agent_type_description: "role help".to_string(),
|
||||
hide_agent_type_model_reasoning: false,
|
||||
include_usage_hint: true,
|
||||
usage_hint_text: None,
|
||||
});
|
||||
|
||||
@@ -178,7 +176,6 @@ fn spawn_agent_tool_caps_visible_model_summaries() {
|
||||
],
|
||||
agent_type_description: "role help".to_string(),
|
||||
hide_agent_type_model_reasoning: false,
|
||||
include_usage_hint: true,
|
||||
usage_hint_text: None,
|
||||
});
|
||||
|
||||
@@ -222,7 +219,6 @@ fn spawn_agent_tool_hides_service_tier_with_spawn_metadata() {
|
||||
available_models: vec![model_preset("visible", /*show_in_picker*/ true)],
|
||||
agent_type_description: "role help".to_string(),
|
||||
hide_agent_type_model_reasoning: true,
|
||||
include_usage_hint: true,
|
||||
usage_hint_text: None,
|
||||
});
|
||||
|
||||
|
||||
@@ -1148,11 +1148,7 @@ async fn multi_agent_v2_spawn_returns_path_and_send_message_accepts_relative_pat
|
||||
.features
|
||||
.enable(Feature::MultiAgentV2)
|
||||
.expect("test config should allow feature update");
|
||||
config
|
||||
.features
|
||||
.enable(Feature::MultiAgentMode)
|
||||
.expect("test config should allow feature update");
|
||||
turn.multi_agent_mode = Some(MultiAgentMode::Proactive);
|
||||
turn.multi_agent_mode = MultiAgentMode::Proactive;
|
||||
set_turn_config(&mut turn, config);
|
||||
|
||||
let session = Arc::new(session);
|
||||
@@ -1191,10 +1187,7 @@ async fn multi_agent_v2_spawn_returns_path_and_send_message_accepts_relative_pat
|
||||
child_snapshot.session_source.get_agent_path().as_deref(),
|
||||
Some("/root/test_process")
|
||||
);
|
||||
assert_eq!(
|
||||
child_snapshot.multi_agent_mode,
|
||||
Some(MultiAgentMode::Proactive)
|
||||
);
|
||||
assert_eq!(child_snapshot.multi_agent_mode, MultiAgentMode::Proactive);
|
||||
assert!(manager.captured_ops().iter().any(|(id, op)| {
|
||||
*id == child_thread_id
|
||||
&& matches!(
|
||||
|
||||
@@ -52,12 +52,8 @@ async fn handle_spawn_agent(
|
||||
let fork_mode = args.fork_mode()?;
|
||||
let multi_agent_mode = crate::session::multi_agents::effective_multi_agent_mode(
|
||||
turn.multi_agent_version,
|
||||
&turn.config.multi_agent_v2,
|
||||
&turn.session_source,
|
||||
turn.multi_agent_mode,
|
||||
turn.config
|
||||
.features
|
||||
.enabled(codex_features::Feature::MultiAgentMode),
|
||||
);
|
||||
let role_name = args
|
||||
.agent_type
|
||||
|
||||
Reference in new issue
Block a user