Skip to content

Commit 03bb3b1

Browse files
jif-oaicopyberry
authored andcommitted
Unify multi-agent settings under agents (#33550)
## What changed - Add `agents.enabled` as a user override for multi-agent tools while keeping an enabled `features.multi_agent_v2` authoritative. - Rename the shared spawned-thread limit to `agents.max_concurrent_threads_per_session`, retain `agents.max_threads` as an alias, and apply the setting to both multi-agent backends. - Add reserved subagent model, reasoning effort, and agent-type settings to the config surface and persist all resolved agent settings in config locks. - Show the resolved `[agents]` values in TUI debug-config output. ## Testing - Cover config loading, legacy alias normalization across merged layers, backend-selection precedence, V2 concurrency, and debug output. GitOrigin-RevId: 2957c954a2e1aef51592768dbbccd56c4bf8f118
1 parent cbc83d9 commit 03bb3b1

17 files changed

Lines changed: 429 additions & 109 deletions

File tree

‎codex-rs/config/src/config_toml.rs‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -678,14 +678,23 @@ where
678678
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq, JsonSchema)]
679679
#[schemars(deny_unknown_fields)]
680680
pub struct AgentsToml {
681-
/// Maximum number of agent threads that can be open concurrently.
682-
/// When unset, no limit is enforced.
683-
#[schemars(range(min = 1))]
684-
pub max_threads: Option<usize>,
685-
/// Maximum nesting depth allowed for spawned agent threads.
686-
/// Root sessions start at depth 0.
681+
/// Whether multi-agent tools are enabled. Defaults to true.
682+
/// An enabled `features.multi_agent_v2` setting takes precedence.
683+
pub enabled: Option<bool>,
684+
/// Maximum number of spawned agent threads that can be open concurrently per session.
685+
/// When unset, the selected multi-agent backend uses its default.
686+
#[serde(alias = "max_threads")]
687687
#[schemars(range(min = 1))]
688+
pub max_concurrent_threads_per_session: Option<usize>,
689+
/// Maximum nesting depth for V1 agent threads. Ignored by V2.
688690
pub max_depth: Option<i32>,
691+
/// Reserved for controlling whether the spawn tool supports agent types.
692+
/// Currently ignored.
693+
pub support_agent_type: Option<bool>,
694+
/// Reserved default model for spawned subagents. Currently ignored.
695+
pub default_subagent_model: Option<String>,
696+
/// Reserved default reasoning effort for spawned subagents. Currently ignored.
697+
pub default_subagent_reasoning_effort: Option<ReasoningEffort>,
689698
/// Default maximum runtime in seconds for agent job workers.
690699
#[schemars(range(min = 1))]
691700
pub job_max_runtime_seconds: Option<u64>,

‎codex-rs/config/src/key_aliases.rs‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@ struct ConfigKeyAlias {
88
canonical_key: &'static str,
99
}
1010

11-
const CONFIG_KEY_ALIASES: &[ConfigKeyAlias] = &[ConfigKeyAlias {
12-
table_path: &["memories"],
13-
legacy_key: "no_memories_if_mcp_or_web_search",
14-
canonical_key: "disable_on_external_context",
15-
}];
11+
const CONFIG_KEY_ALIASES: &[ConfigKeyAlias] = &[
12+
ConfigKeyAlias {
13+
table_path: &["memories"],
14+
legacy_key: "no_memories_if_mcp_or_web_search",
15+
canonical_key: "disable_on_external_context",
16+
},
17+
ConfigKeyAlias {
18+
table_path: &["agents"],
19+
legacy_key: "max_threads",
20+
canonical_key: "max_concurrent_threads_per_session",
21+
},
22+
];
1623

1724
pub(crate) fn normalize_key_aliases(path: &[String], table: &mut TomlMap<String, TomlValue>) {
1825
for alias in CONFIG_KEY_ALIASES {

‎codex-rs/config/src/merge_tests.rs‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use super::*;
2+
use crate::config_toml::AgentsToml;
23
use crate::config_toml::ConfigToml;
34
use crate::types::MemoriesToml;
45
use pretty_assertions::assert_eq;
@@ -99,6 +100,67 @@ disable_on_external_context = true
99100
assert_eq!(base, expected);
100101
}
101102

103+
#[test]
104+
fn merge_toml_values_normalizes_legacy_agents_key_across_layers() {
105+
let mut base = parse_toml(
106+
r#"
107+
[agents]
108+
max_threads = 4
109+
"#,
110+
);
111+
let overlay = parse_toml(
112+
r#"
113+
[agents]
114+
max_concurrent_threads_per_session = 7
115+
"#,
116+
);
117+
118+
merge_toml_values(&mut base, &overlay);
119+
120+
let expected = parse_toml(
121+
r#"
122+
[agents]
123+
max_concurrent_threads_per_session = 7
124+
"#,
125+
);
126+
assert_eq!(base, expected);
127+
128+
let config: ConfigToml = base.try_into().expect("merged config should deserialize");
129+
assert_eq!(
130+
config.agents,
131+
Some(AgentsToml {
132+
max_concurrent_threads_per_session: Some(7),
133+
..Default::default()
134+
})
135+
);
136+
}
137+
138+
#[test]
139+
fn merge_toml_values_normalizes_legacy_agents_key_from_overlay() {
140+
let mut base = parse_toml(
141+
r#"
142+
[agents]
143+
max_concurrent_threads_per_session = 4
144+
"#,
145+
);
146+
let overlay = parse_toml(
147+
r#"
148+
[agents]
149+
max_threads = 7
150+
"#,
151+
);
152+
153+
merge_toml_values(&mut base, &overlay);
154+
155+
let expected = parse_toml(
156+
r#"
157+
[agents]
158+
max_concurrent_threads_per_session = 7
159+
"#,
160+
);
161+
assert_eq!(base, expected);
162+
}
163+
102164
#[test]
103165
fn merge_toml_values_normalizes_permission_network_domains_before_overlaying() {
104166
let mut base = parse_toml(

‎codex-rs/core/config.schema.json‎

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@
3636
"$ref": "#/definitions/AgentRoleToml"
3737
},
3838
"properties": {
39+
"default_subagent_model": {
40+
"description": "Reserved default model for spawned subagents. Currently ignored.",
41+
"type": "string"
42+
},
43+
"default_subagent_reasoning_effort": {
44+
"allOf": [
45+
{
46+
"$ref": "#/definitions/ReasoningEffort"
47+
}
48+
],
49+
"description": "Reserved default reasoning effort for spawned subagents. Currently ignored."
50+
},
51+
"enabled": {
52+
"description": "Whether multi-agent tools are enabled. Defaults to true. An enabled `features.multi_agent_v2` setting takes precedence.",
53+
"type": "boolean"
54+
},
3955
"interrupt_message": {
4056
"description": "Whether to record a model-visible message when an agent turn is interrupted. Defaults to true.",
4157
"type": "boolean"
@@ -46,17 +62,20 @@
4662
"minimum": 1.0,
4763
"type": "integer"
4864
},
49-
"max_depth": {
50-
"description": "Maximum nesting depth allowed for spawned agent threads. Root sessions start at depth 0.",
51-
"format": "int32",
65+
"max_concurrent_threads_per_session": {
66+
"description": "Maximum number of spawned agent threads that can be open concurrently per session. When unset, the selected multi-agent backend uses its default.",
67+
"format": "uint",
5268
"minimum": 1.0,
5369
"type": "integer"
5470
},
55-
"max_threads": {
56-
"description": "Maximum number of agent threads that can be open concurrently. When unset, no limit is enforced.",
57-
"format": "uint",
58-
"minimum": 1.0,
71+
"max_depth": {
72+
"description": "Maximum nesting depth for V1 agent threads. Ignored by V2.",
73+
"format": "int32",
5974
"type": "integer"
75+
},
76+
"support_agent_type": {
77+
"description": "Reserved for controlling whether the spawn tool supports agent types. Currently ignored.",
78+
"type": "boolean"
6079
}
6180
},
6281
"type": "object"

‎codex-rs/core/src/agent/control_tests.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,7 +1953,7 @@ async fn spawn_agent_fork_last_n_turns_strips_parent_usage_hints() {
19531953
}
19541954

19551955
#[tokio::test]
1956-
async fn spawn_agent_respects_max_threads_limit() {
1956+
async fn spawn_agent_respects_legacy_max_threads_alias() {
19571957
let max_threads = 1usize;
19581958
let (_home, config) = test_config_with_cli_overrides(vec![(
19591959
"agents.max_threads".to_string(),
@@ -2008,7 +2008,7 @@ async fn spawn_agent_respects_max_threads_limit() {
20082008
async fn spawn_agent_releases_slot_after_shutdown() {
20092009
let max_threads = 1usize;
20102010
let (_home, config) = test_config_with_cli_overrides(vec![(
2011-
"agents.max_threads".to_string(),
2011+
"agents.max_concurrent_threads_per_session".to_string(),
20122012
TomlValue::Integer(max_threads as i64),
20132013
)])
20142014
.await;
@@ -2051,7 +2051,7 @@ async fn spawn_agent_releases_slot_after_shutdown() {
20512051
async fn spawn_agent_limit_shared_across_clones() {
20522052
let max_threads = 1usize;
20532053
let (_home, config) = test_config_with_cli_overrides(vec![(
2054-
"agents.max_threads".to_string(),
2054+
"agents.max_concurrent_threads_per_session".to_string(),
20552055
TomlValue::Integer(max_threads as i64),
20562056
)])
20572057
.await;
@@ -2096,7 +2096,7 @@ async fn spawn_agent_limit_shared_across_clones() {
20962096
async fn resume_agent_respects_max_threads_limit() {
20972097
let max_threads = 1usize;
20982098
let (_home, config) = test_config_with_cli_overrides(vec![(
2099-
"agents.max_threads".to_string(),
2099+
"agents.max_concurrent_threads_per_session".to_string(),
21002100
TomlValue::Integer(max_threads as i64),
21012101
)])
21022102
.await;
@@ -2152,7 +2152,7 @@ async fn resume_agent_respects_max_threads_limit() {
21522152
async fn resume_agent_releases_slot_after_resume_failure() {
21532153
let max_threads = 1usize;
21542154
let (_home, config) = test_config_with_cli_overrides(vec![(
2155-
"agents.max_threads".to_string(),
2155+
"agents.max_concurrent_threads_per_session".to_string(),
21562156
TomlValue::Integer(max_threads as i64),
21572157
)])
21582158
.await;

0 commit comments

Comments
 (0)