mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Support catalog descriptions for all multi-agent V2 tools (#46297)
## Why Model catalog description overrides only covered `spawn_agent`, leaving the other multi-agent V2 tools with fixed descriptions. ## What changed Extend `model_messages.tools.multi_agent` description overrides to `send_message`, `followup_task`, `wait_agent`, `interrupt_agent`, and `list_agents`. Resolve each override by tool name across namespaced, plain, and Code Mode exposure. Missing or null descriptions retain bundled text; empty strings suppress static text without disabling tools. Preserve `spawn_agent` runtime guidance, tool schemas, and execution behavior. Descriptions follow mid-turn model changes. ## Testing Expand integration coverage to all six tools, including missing, null, empty, and sparse overrides; plain, namespaced, and Code Mode exposure; unchanged V1 behavior; and mid-turn model changes. GitOrigin-RevId: a2c47eb8efb28c3eeebcc6482e36c188c38a6dd1
This commit is contained in:
1 parent
17baabd01b
commit
3e581ebca8
10 files changed
+401
-191
No files matched your search
@@ -131,6 +131,7 @@ mod models_cache_ttl;
|
||||
mod models_etag_responses;
|
||||
mod multi_agent_mode;
|
||||
mod multi_agent_resume;
|
||||
mod multi_agent_tool_descriptions;
|
||||
#[cfg(unix)]
|
||||
mod multi_exec_server_sandbox;
|
||||
mod network_approval;
|
||||
@@ -184,7 +185,6 @@ mod skill_approval;
|
||||
mod skills;
|
||||
mod skills_extension;
|
||||
mod spawn_agent_description;
|
||||
mod spawn_agent_tool_descriptions;
|
||||
mod sqlite_state;
|
||||
mod startup_cancellation;
|
||||
mod step_settings;
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
//! Verifies catalog descriptions reach V2 tools without changing their schemas or availability.
|
||||
|
||||
use anyhow::Result;
|
||||
use codex_core::config::AgentRoleConfig;
|
||||
use codex_features::Feature;
|
||||
use codex_protocol::openai_models::ToolMessages;
|
||||
use codex_protocol::protocol::MultiAgentVersion;
|
||||
use core_test_support::responses::mount_sse_sequence;
|
||||
use core_test_support::responses::sse_completed;
|
||||
use core_test_support::responses::start_mock_server;
|
||||
use core_test_support::skip_if_no_network;
|
||||
use core_test_support::test_codex::test_codex;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::Value;
|
||||
use serde_json::json;
|
||||
use test_case::test_case;
|
||||
|
||||
const TOOL_NAMES: [&str; 6] = [
|
||||
"spawn_agent",
|
||||
"send_message",
|
||||
"followup_task",
|
||||
"wait_agent",
|
||||
"interrupt_agent",
|
||||
"list_agents",
|
||||
];
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
enum Exposure {
|
||||
Namespaced,
|
||||
Plain,
|
||||
CodeMode,
|
||||
V1,
|
||||
}
|
||||
|
||||
fn all_tool_messages(message: Value) -> Value {
|
||||
json!({
|
||||
"multi_agent": TOOL_NAMES
|
||||
.map(|name| {
|
||||
let mut message = message.clone();
|
||||
if let Some(description) = message["description"].as_str() {
|
||||
message["description"] = json!(description.replace("TOOL_NAME", name));
|
||||
}
|
||||
(name.to_string(), message)
|
||||
})
|
||||
.into_iter()
|
||||
.collect::<serde_json::Map<String, Value>>()
|
||||
})
|
||||
}
|
||||
|
||||
#[test_case(json!(null), Exposure::Namespaced; "missing_tools")]
|
||||
#[test_case(json!({}), Exposure::Namespaced; "missing_multi_agent")]
|
||||
#[test_case(json!({"multi_agent": null}), Exposure::Namespaced; "null_multi_agent")]
|
||||
#[test_case(json!({"multi_agent": {}}), Exposure::Namespaced; "missing_tools_in_family")]
|
||||
#[test_case(all_tool_messages(json!(null)), Exposure::Namespaced; "null_tool")]
|
||||
#[test_case(all_tool_messages(json!({})), Exposure::Namespaced; "missing_description")]
|
||||
#[test_case(all_tool_messages(json!({"description": null})), Exposure::Namespaced; "null_description")]
|
||||
#[test_case(all_tool_messages(json!({"description": " Catalog TOOL_NAME description.\n{{literal_placeholder}} "})), Exposure::Namespaced; "catalog_description")]
|
||||
#[test_case(all_tool_messages(json!({"description": ""})), Exposure::Namespaced; "empty_description")]
|
||||
#[test_case(json!({"multi_agent": {"send_message": {"description": "Catalog send."}}}), Exposure::Namespaced; "sparse_sibling_fallback")]
|
||||
#[test_case(all_tool_messages(json!({"description": "Catalog TOOL_NAME description."})), Exposure::Plain; "plain_tools")]
|
||||
#[test_case(all_tool_messages(json!({"description": "Catalog TOOL_NAME description."})), Exposure::CodeMode; "code_mode_declarations")]
|
||||
#[test_case(all_tool_messages(json!({"description": ""})), Exposure::CodeMode; "empty_code_mode_descriptions")]
|
||||
#[test_case(all_tool_messages(json!({"description": "Catalog TOOL_NAME description."})), Exposure::V1; "v1_unchanged")]
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn multi_agent_catalog_descriptions_preserve_outbound_schema(
|
||||
tool_messages: Value,
|
||||
exposure: Exposure,
|
||||
) -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = start_mock_server().await;
|
||||
let response = mount_sse_sequence(
|
||||
&server,
|
||||
vec![sse_completed("resp-default"), sse_completed("resp-catalog")],
|
||||
)
|
||||
.await;
|
||||
for messages in [
|
||||
None,
|
||||
serde_json::from_value::<Option<ToolMessages>>(tool_messages.clone())?,
|
||||
] {
|
||||
let test = test_codex()
|
||||
.with_model_info_override("gpt-5.2", move |model| {
|
||||
model.multi_agent_version = Some(if matches!(exposure, Exposure::V1) {
|
||||
MultiAgentVersion::V1
|
||||
} else {
|
||||
MultiAgentVersion::V2
|
||||
});
|
||||
model.model_messages.as_mut().expect("model messages").tools = messages;
|
||||
})
|
||||
.with_config(move |config| {
|
||||
if matches!(exposure, Exposure::V1) {
|
||||
config.features.enable(Feature::Collab).expect("enable V1");
|
||||
config
|
||||
.features
|
||||
.disable(Feature::MultiAgentV2)
|
||||
.expect("disable V2");
|
||||
} else {
|
||||
config
|
||||
.features
|
||||
.enable(Feature::MultiAgentV2)
|
||||
.expect("enable V2");
|
||||
}
|
||||
if matches!(exposure, Exposure::CodeMode) {
|
||||
config
|
||||
.features
|
||||
.enable(Feature::CodeMode)
|
||||
.expect("enable Code Mode");
|
||||
// Inspect declarations even when the test has no Code Mode host to execute them.
|
||||
config.code_mode.disable_in_process_fallback = true;
|
||||
config.multi_agent_v2.non_code_mode_only = false;
|
||||
}
|
||||
config.multi_agent_v2.tool_namespace =
|
||||
(!matches!(exposure, Exposure::Plain)).then(|| "delegation".to_string());
|
||||
config.multi_agent_v2.hide_spawn_agent_metadata = false;
|
||||
config.multi_agent_v2.expose_spawn_agent_model_overrides = true;
|
||||
config.multi_agent_v2.usage_hint_text = Some("Local delegation hint.".to_string());
|
||||
config.agent_roles.insert(
|
||||
"researcher".to_string(),
|
||||
AgentRoleConfig {
|
||||
description: Some("Research the assigned question.".to_string()),
|
||||
config_file: None,
|
||||
nickname_candidates: None,
|
||||
},
|
||||
);
|
||||
})
|
||||
.build_with_auto_env(&server)
|
||||
.await?;
|
||||
test.submit_turn("Inspect the available tools.").await?;
|
||||
}
|
||||
|
||||
let requests = response.requests();
|
||||
assert_eq!(requests.len(), 2);
|
||||
let mut expected = requests[0].body_json()["tools"].clone();
|
||||
let actual = requests[1].body_json()["tools"].clone();
|
||||
if !matches!(exposure, Exposure::V1) {
|
||||
let tools = if matches!(exposure, Exposure::Plain) {
|
||||
expected.as_array_mut().expect("plain tools")
|
||||
} else {
|
||||
expected
|
||||
.as_array_mut()
|
||||
.expect("tools")
|
||||
.iter_mut()
|
||||
.find(|tool| tool["name"] == "delegation")
|
||||
.expect("delegation namespace")["tools"]
|
||||
.as_array_mut()
|
||||
.expect("namespace tools")
|
||||
};
|
||||
let actual_tools = if matches!(exposure, Exposure::Plain) {
|
||||
actual.as_array().expect("plain tools")
|
||||
} else {
|
||||
actual
|
||||
.as_array()
|
||||
.expect("tools")
|
||||
.iter()
|
||||
.find(|tool| tool["name"] == "delegation")
|
||||
.expect("delegation namespace")["tools"]
|
||||
.as_array()
|
||||
.expect("namespace tools")
|
||||
};
|
||||
for name in TOOL_NAMES {
|
||||
let expected_tool = tools
|
||||
.iter_mut()
|
||||
.find(|tool| tool["name"] == name)
|
||||
.expect(name);
|
||||
let actual_tool = actual_tools
|
||||
.iter()
|
||||
.find(|tool| tool["name"] == name)
|
||||
.expect(name);
|
||||
if let Some(description) = tool_messages["multi_agent"][name]["description"].as_str() {
|
||||
let bundled = expected_tool["description"]
|
||||
.as_str()
|
||||
.expect("bundled description");
|
||||
let declaration = bundled
|
||||
.find("\n\nexec tool declaration:")
|
||||
.map(|index| &bundled[index..])
|
||||
.unwrap_or_default();
|
||||
if matches!(exposure, Exposure::CodeMode) {
|
||||
assert!(
|
||||
declaration.contains(&format!("delegation__{name}")),
|
||||
"Code Mode description for {name}: {bundled}"
|
||||
);
|
||||
}
|
||||
let replacement = if name == "spawn_agent" {
|
||||
let actual_description = actual_tool["description"]
|
||||
.as_str()
|
||||
.expect("spawn description");
|
||||
assert!(actual_description.contains(description));
|
||||
assert!(
|
||||
!actual_description
|
||||
.contains("Spawns an agent to work on the specified task.")
|
||||
);
|
||||
assert!(
|
||||
actual_description
|
||||
.strip_suffix(declaration)
|
||||
.expect("unchanged declaration")
|
||||
.ends_with("Local delegation hint.")
|
||||
);
|
||||
actual_description.to_string()
|
||||
} else {
|
||||
format!("{description}{declaration}")
|
||||
};
|
||||
expected_tool["description"] = json!(replacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
assert_eq!(actual, expected);
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
//! Verifies catalog tool descriptions reach the V2 outbound tool without changing its parameters.
|
||||
|
||||
use anyhow::Result;
|
||||
use codex_core::config::AgentRoleConfig;
|
||||
use codex_features::Feature;
|
||||
use codex_protocol::openai_models::ToolMessages;
|
||||
use codex_protocol::protocol::MultiAgentVersion;
|
||||
use core_test_support::responses::mount_sse_sequence;
|
||||
use core_test_support::responses::namespace_child_tool;
|
||||
use core_test_support::responses::sse_completed;
|
||||
use core_test_support::responses::start_mock_server;
|
||||
use core_test_support::skip_if_no_network;
|
||||
use core_test_support::test_codex::test_codex;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::Value;
|
||||
use serde_json::json;
|
||||
use test_case::test_case;
|
||||
|
||||
#[test_case(json!(null); "missing_tools")]
|
||||
#[test_case(json!({}); "missing_multi_agent")]
|
||||
#[test_case(json!({"multi_agent": null}); "null_multi_agent")]
|
||||
#[test_case(json!({"multi_agent": {}}); "missing_spawn_agent")]
|
||||
#[test_case(json!({"multi_agent": {"spawn_agent": null}}); "null_spawn_agent")]
|
||||
#[test_case(json!({"multi_agent": {"spawn_agent": {}}}); "missing_description")]
|
||||
#[test_case(json!({"multi_agent": {"spawn_agent": {"description": null}}}); "null_description")]
|
||||
#[test_case(json!({"multi_agent": {"spawn_agent": {"description": "Catalog spawn."}}}); "catalog_description")]
|
||||
#[test_case(json!({"multi_agent": {"spawn_agent": {"description": ""}}}); "empty_description")]
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn spawn_agent_catalog_descriptions_preserve_outbound_schema(
|
||||
tool_messages: Value,
|
||||
) -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = start_mock_server().await;
|
||||
let response = mount_sse_sequence(
|
||||
&server,
|
||||
vec![sse_completed("resp-default"), sse_completed("resp-catalog")],
|
||||
)
|
||||
.await;
|
||||
for messages in [
|
||||
None,
|
||||
serde_json::from_value::<Option<ToolMessages>>(tool_messages.clone())?,
|
||||
] {
|
||||
let test = test_codex()
|
||||
.with_model_info_override("gpt-5.2", move |model| {
|
||||
model.multi_agent_version = Some(MultiAgentVersion::V2);
|
||||
model.model_messages.as_mut().expect("model messages").tools = messages;
|
||||
})
|
||||
.with_config(|config| {
|
||||
config
|
||||
.features
|
||||
.enable(Feature::MultiAgentV2)
|
||||
.expect("enable V2");
|
||||
config.multi_agent_v2.tool_namespace = Some("delegation".to_string());
|
||||
config.multi_agent_v2.hide_spawn_agent_metadata = false;
|
||||
config.multi_agent_v2.expose_spawn_agent_model_overrides = true;
|
||||
config.multi_agent_v2.usage_hint_text = Some("Local delegation hint.".to_string());
|
||||
config.agent_roles.insert(
|
||||
"researcher".to_string(),
|
||||
AgentRoleConfig {
|
||||
description: Some("Research the assigned question.".to_string()),
|
||||
config_file: None,
|
||||
nickname_candidates: None,
|
||||
},
|
||||
);
|
||||
})
|
||||
.build_with_auto_env(&server)
|
||||
.await?;
|
||||
test.submit_turn("Inspect the available tools.").await?;
|
||||
}
|
||||
|
||||
let requests = response.requests();
|
||||
assert_eq!(requests.len(), 2);
|
||||
let mut expected = namespace_child_tool(&requests[0].body_json(), "delegation", "spawn_agent")
|
||||
.expect("default spawn agent tool")
|
||||
.clone();
|
||||
let actual = namespace_child_tool(&requests[1].body_json(), "delegation", "spawn_agent")
|
||||
.expect("catalog spawn agent tool")
|
||||
.clone();
|
||||
let messages = &tool_messages["multi_agent"]["spawn_agent"];
|
||||
if let Some(description) = messages["description"].as_str() {
|
||||
let actual_description = actual["description"].as_str().expect("tool description");
|
||||
assert!(actual_description.contains(description));
|
||||
assert!(!actual_description.contains("Spawns an agent to work on the specified task."));
|
||||
assert!(actual_description.ends_with("Local delegation hint."));
|
||||
expected["description"] = actual["description"].clone();
|
||||
}
|
||||
assert_eq!(actual, expected);
|
||||
Ok(())
|
||||
}
|
||||
@@ -2229,6 +2229,15 @@ async fn model_activation_uses_destination_metadata_defaults(
|
||||
async fn tool_descriptions_follow_mid_turn_model_changes() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
const MULTI_AGENT_TOOLS: [&str; 6] = [
|
||||
"spawn_agent",
|
||||
"send_message",
|
||||
"followup_task",
|
||||
"wait_agent",
|
||||
"interrupt_agent",
|
||||
"list_agents",
|
||||
];
|
||||
|
||||
let server = start_mock_server().await;
|
||||
let response_mock = mount_sse_sequence(
|
||||
&server,
|
||||
@@ -2254,18 +2263,24 @@ async fn tool_descriptions_follow_mid_turn_model_changes() -> Result<()> {
|
||||
model
|
||||
.experimental_supported_tools
|
||||
.push("send_user_message_async".to_string());
|
||||
let description = |name| {
|
||||
Some(ToolMessage {
|
||||
description: Some(format!("{name} description for {}.", model.slug)),
|
||||
})
|
||||
};
|
||||
model
|
||||
.model_messages
|
||||
.as_mut()
|
||||
.expect("model instruction metadata")
|
||||
.tools = Some(ToolMessages {
|
||||
send_user_message_async: Some(ToolMessage {
|
||||
description: Some(format!("Async message description for {}.", model.slug)),
|
||||
}),
|
||||
send_user_message_async: description("Async message"),
|
||||
multi_agent: Some(MultiAgentToolMessages {
|
||||
spawn_agent: Some(ToolMessage {
|
||||
description: Some(format!("Spawn description for {}.", model.slug)),
|
||||
}),
|
||||
spawn_agent: description("spawn_agent"),
|
||||
send_message: description("send_message"),
|
||||
followup_task: description("followup_task"),
|
||||
wait_agent: description("wait_agent"),
|
||||
interrupt_agent: description("interrupt_agent"),
|
||||
list_agents: description("list_agents"),
|
||||
}),
|
||||
});
|
||||
}
|
||||
@@ -2302,12 +2317,14 @@ async fn tool_descriptions_follow_mid_turn_model_changes() -> Result<()> {
|
||||
.iter()
|
||||
.find(|tool| tool["name"] == "request_user_input_async")
|
||||
.expect("async message tool");
|
||||
let spawn = namespace_child_tool(&body, "collaboration", "spawn_agent")
|
||||
.expect("spawn agent tool");
|
||||
let descriptions = MULTI_AGENT_TOOLS.map(|name| {
|
||||
let tool = namespace_child_tool(&body, "collaboration", name).expect(name);
|
||||
(name.to_string(), json!(tool["description"].as_str().expect("tool description").trim()))
|
||||
}).into_iter().collect::<serde_json::Map<String, Value>>();
|
||||
json!({
|
||||
"model": body["model"],
|
||||
"async_description": tool["description"],
|
||||
"spawn_description": spawn["description"].as_str().expect("spawn description").trim(),
|
||||
"multi_agent_descriptions": descriptions,
|
||||
})
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
@@ -2315,7 +2332,10 @@ async fn tool_descriptions_follow_mid_turn_model_changes() -> Result<()> {
|
||||
.map(|model| json!({
|
||||
"model": model,
|
||||
"async_description": format!("Async message description for {model}."),
|
||||
"spawn_description": format!("Spawn description for {model}."),
|
||||
"multi_agent_descriptions": MULTI_AGENT_TOOLS
|
||||
.map(|name| (name.to_string(), json!(format!("{name} description for {model}."))))
|
||||
.into_iter()
|
||||
.collect::<serde_json::Map<String, Value>>(),
|
||||
}))
|
||||
.to_vec(),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user