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
This commit is contained in:
jif authored and copyberry committed 2026-07-16 09:00:51 +00:00
1 parent cbc83d961e
commit 03bb3b1236
17 files changed
+431 -111

No files matched your search

+81
View File
@@ -29,6 +29,7 @@ pub(crate) fn new_debug_config_output(
let mut lines = render_debug_config_lines(&config.config_layer_stack, |mode| {
sandbox_mode_is_allowed_by_permissions(&config.permissions, mode)
});
lines.extend(render_agents_config_lines(config));
if let Some(proxy) = session_network_proxy {
lines.push("".into());
@@ -54,6 +55,55 @@ pub(crate) fn new_debug_config_output(
PlainHistoryCell::new(lines)
}
fn render_agents_config_lines(config: &Config) -> Vec<Line<'static>> {
vec![
"".into(),
"[agents]:".bold().into(),
format!(" - enabled = {}", config.agents_enabled).into(),
format!(
" - max_concurrent_threads_per_session = {}",
format_optional(config.agent_max_threads)
)
.into(),
format!(
" - max_depth = {} (V1 only; ignored by V2)",
config.agent_max_depth
)
.into(),
format!(
" - support_agent_type = {} (not yet wired)",
format_optional(config.agent_support_agent_type)
)
.into(),
format!(
" - default_subagent_model = {} (not yet wired)",
format_optional(config.agent_default_subagent_model.as_deref())
)
.into(),
format!(
" - default_subagent_reasoning_effort = {} (not yet wired)",
format_optional(config.agent_default_subagent_reasoning_effort.as_ref())
)
.into(),
format!(
" - job_max_runtime_seconds = {}",
format_optional(config.agent_job_max_runtime_seconds)
)
.into(),
format!(
" - interrupt_message = {}",
config.agent_interrupt_message_enabled
)
.into(),
]
}
fn format_optional(value: Option<impl std::fmt::Display>) -> String {
value
.map(|value| value.to_string())
.unwrap_or_else(|| "<unset>".to_string())
}
fn sandbox_mode_is_allowed_by_permissions(
permissions: &Permissions,
mode: SandboxModeRequirement,
@@ -552,9 +602,11 @@ fn format_network_unix_socket_permission(
#[cfg(test)]
mod tests {
use super::render_agents_config_lines;
use super::render_debug_config_lines;
use super::sandbox_mode_is_allowed_by_permissions;
use super::session_all_proxy_url;
use crate::legacy_core::config::ConfigBuilder;
use crate::legacy_core::config::Permissions;
use codex_app_server_protocol::AskForApproval;
use codex_config::ConfigLayerEntry;
@@ -569,6 +621,7 @@ mod tests {
use codex_config::FilesystemConstraints;
use codex_config::HookEventsToml;
use codex_config::HookHandlerConfig;
use codex_config::LoaderOverrides;
use codex_config::ManagedHooksRequirementsToml;
use codex_config::MatcherGroup;
use codex_config::McpServerIdentity;
@@ -592,6 +645,34 @@ mod tests {
use std::collections::BTreeMap;
use toml::Value as TomlValue;
#[tokio::test]
async fn debug_config_output_lists_agents_fields() {
let codex_home = tempfile::tempdir().expect("create temp dir");
std::fs::write(
codex_home.path().join(codex_config::CONFIG_TOML_FILE),
r#"[agents]
enabled = false
max_concurrent_threads_per_session = 7
max_depth = -2
support_agent_type = true
default_subagent_model = "gpt-5.6-terra"
default_subagent_reasoning_effort = "high"
job_max_runtime_seconds = 900
interrupt_message = false
"#,
)
.expect("write config");
let config = ConfigBuilder::default()
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(codex_home.path().to_path_buf()))
.loader_overrides(LoaderOverrides::without_managed_config_for_tests())
.build()
.await
.expect("load config");
insta::assert_snapshot!(render_to_text(&render_agents_config_lines(&config)));
}
fn empty_toml_table() -> TomlValue {
TomlValue::Table(toml::map::Map::new())
}