mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Allow model catalogs to override the V2 spawn_agent description (#46123)
## What changed Read the static V2 `spawn_agent` description from `model_messages.tools.multi_agent.spawn_agent.description`, independently of the runtime tool namespace. Missing or null values retain the bundled description; an empty string suppresses it. Preserve generated model guidance, local usage hints, and tool parameters when applying an override. Resolve the description from the active model so it follows mid-turn model changes. ## Testing Add coverage for sparse and empty catalog values, preservation of generated context and outbound tool schemas, and description updates after mid-turn model changes. GitOrigin-RevId: 96cfa180f8f374dc868e4fabc337e49380e405da
This commit is contained in:
1 parent
a4ee536f01
commit
c5d079470e
11 files changed
+349
-74
No files matched your search
@@ -182,6 +182,7 @@ 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;
|
||||
|
||||
@@ -76,6 +76,7 @@ async fn persistent_async_message_guidance_follows_tool_availability(
|
||||
send_user_message_async: Some(ToolMessage {
|
||||
description: Some("Catalog async message description.".to_string()),
|
||||
}),
|
||||
..Default::default()
|
||||
});
|
||||
})
|
||||
.with_config(|config| {
|
||||
@@ -248,6 +249,7 @@ async fn freeform_async_message_emits_an_item_without_ending_the_turn(
|
||||
send_user_message_async: Some(ToolMessage {
|
||||
description: Some("Questions only.".to_string()),
|
||||
}),
|
||||
..Default::default()
|
||||
});
|
||||
})
|
||||
.with_config(move |config| {
|
||||
@@ -340,10 +342,10 @@ async fn freeform_async_message_emits_an_item_without_ending_the_turn(
|
||||
|
||||
#[test_case(None, "send_user_message_async"; "fallback_description")]
|
||||
#[test_case(None, "request_user_input_async"; "current_catalog_name")]
|
||||
#[test_case(Some(ToolMessages { send_user_message_async: None }), "send_user_message_async"; "missing_tool")]
|
||||
#[test_case(Some(ToolMessages { send_user_message_async: Some(ToolMessage::default()) }), "send_user_message_async"; "missing_description")]
|
||||
#[test_case(Some(ToolMessages { send_user_message_async: Some(ToolMessage { description: Some("Catalog async message description.".to_string()) }) }), "send_user_message_async"; "catalog_description")]
|
||||
#[test_case(Some(ToolMessages { send_user_message_async: Some(ToolMessage { description: Some(String::new()) }) }), "send_user_message_async"; "empty_description")]
|
||||
#[test_case(Some(ToolMessages::default()), "send_user_message_async"; "missing_tool")]
|
||||
#[test_case(Some(ToolMessages { send_user_message_async: Some(ToolMessage::default()), ..Default::default() }), "send_user_message_async"; "missing_description")]
|
||||
#[test_case(Some(ToolMessages { send_user_message_async: Some(ToolMessage { description: Some("Catalog async message description.".to_string()) }), ..Default::default() }), "send_user_message_async"; "catalog_description")]
|
||||
#[test_case(Some(ToolMessages { send_user_message_async: Some(ToolMessage { description: Some(String::new()) }), ..Default::default() }), "send_user_message_async"; "empty_description")]
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn request_user_input_async_emits_item_and_does_not_end_the_turn(
|
||||
tool_messages: Option<ToolMessages>,
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
//! 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(())
|
||||
}
|
||||
@@ -44,6 +44,7 @@ use codex_protocol::openai_models::ModelsResponse;
|
||||
use codex_protocol::openai_models::MultiAgentMessages;
|
||||
use codex_protocol::openai_models::MultiAgentModeMessages;
|
||||
use codex_protocol::openai_models::MultiAgentRoleMessages;
|
||||
use codex_protocol::openai_models::MultiAgentToolMessages;
|
||||
use codex_protocol::openai_models::ReasoningEffort;
|
||||
use codex_protocol::openai_models::ReasoningEffortPreset;
|
||||
use codex_protocol::openai_models::ToolMessage;
|
||||
@@ -86,6 +87,7 @@ use core_test_support::responses::mount_models_once;
|
||||
use core_test_support::responses::mount_response_sequence;
|
||||
use core_test_support::responses::mount_sse_once;
|
||||
use core_test_support::responses::mount_sse_sequence;
|
||||
use core_test_support::responses::namespace_child_tool;
|
||||
use core_test_support::responses::sse;
|
||||
use core_test_support::responses::sse_completed;
|
||||
use core_test_support::responses::sse_response;
|
||||
@@ -2224,7 +2226,7 @@ async fn model_activation_uses_destination_metadata_defaults(
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn request_user_input_async_description_follows_mid_turn_model_changes() -> Result<()> {
|
||||
async fn tool_descriptions_follow_mid_turn_model_changes() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = start_mock_server().await;
|
||||
@@ -2238,6 +2240,11 @@ async fn request_user_input_async_description_follows_mid_turn_model_changes() -
|
||||
.await;
|
||||
let test = step_settings_test()
|
||||
.with_config(|config| {
|
||||
config
|
||||
.features
|
||||
.enable(Feature::MultiAgentV2)
|
||||
.expect("test config should allow feature update");
|
||||
config.multi_agent_v2.expose_spawn_agent_model_overrides = false;
|
||||
for model in &mut config
|
||||
.model_catalog
|
||||
.as_mut()
|
||||
@@ -2255,6 +2262,11 @@ async fn request_user_input_async_description_follows_mid_turn_model_changes() -
|
||||
send_user_message_async: Some(ToolMessage {
|
||||
description: Some(format!("Async message description for {}.", model.slug)),
|
||||
}),
|
||||
multi_agent: Some(MultiAgentToolMessages {
|
||||
spawn_agent: Some(ToolMessage {
|
||||
description: Some(format!("Spawn description for {}.", model.slug)),
|
||||
}),
|
||||
}),
|
||||
});
|
||||
}
|
||||
})
|
||||
@@ -2290,13 +2302,20 @@ async fn request_user_input_async_description_follows_mid_turn_model_changes() -
|
||||
.iter()
|
||||
.find(|tool| tool["name"] == "request_user_input_async")
|
||||
.expect("async message tool");
|
||||
json!({"model": body["model"], "description": tool["description"]})
|
||||
let spawn = namespace_child_tool(&body, "collaboration", "spawn_agent")
|
||||
.expect("spawn agent tool");
|
||||
json!({
|
||||
"model": body["model"],
|
||||
"async_description": tool["description"],
|
||||
"spawn_description": spawn["description"].as_str().expect("spawn description").trim(),
|
||||
})
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
[MODEL_A, MODEL_B]
|
||||
.map(|model| json!({
|
||||
"model": model,
|
||||
"description": format!("Async message description for {model}."),
|
||||
"async_description": format!("Async message description for {model}."),
|
||||
"spawn_description": format!("Spawn description for {model}."),
|
||||
}))
|
||||
.to_vec(),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user