From 7880414a2728514ea4aaa619cb5db0ffa807556d Mon Sep 17 00:00:00 2001 From: Michael Bolin Date: Sat, 28 Mar 2026 20:39:47 -0700 Subject: [PATCH] codex-tools: extract collaboration tool specs (#16141) ## Why The recent `codex-tools` migration steps have moved shared tool models and low-coupling spec helpers out of `codex-core`, but `core/src/tools/spec.rs` still owned a large block of pure collaboration-tool spec construction. Those builders do not need session state or runtime behavior; they only need a small amount of core-owned configuration injected at the seam. Moving that cohesive slice into `codex-tools` makes the crate boundary more honest and removes a substantial amount of passive tool-spec logic from `codex-core` without trying to move the runtime-coupled multi-agent handlers at the same time. ## What changed - added `agent_tool.rs`, `request_user_input_tool.rs`, and `agent_job_tool.rs` to `codex-tools`, with sibling `*_tests.rs` coverage and an exports-only `lib.rs` - moved the pure `ToolSpec` builders for: - collaboration tools such as `spawn_agent`, `send_input`, `send_message`, `assign_task`, `resume_agent`, `wait_agent`, `list_agents`, and `close_agent` - `request_user_input` - agent-job specs `spawn_agents_on_csv` and `report_agent_job_result` - rewired `core/src/tools/spec.rs` to call the extracted builders while still supplying the core-owned inputs, such as spawn-agent role descriptions and wait timeout bounds - updated the `core/src/tools/spec.rs` seam tests to build expected collaboration specs through `codex-tools` - updated `codex-rs/tools/README.md` so the crate documentation reflects the broader collaboration-tool boundary ## Test plan - `CARGO_TARGET_DIR=/tmp/codex-tools-collab-specs cargo test -p codex-tools` - `CARGO_TARGET_DIR=/tmp/codex-core-collab-specs cargo test -p codex-core --lib tools::spec::` - `just fix -p codex-tools -p codex-core` - `just argument-comment-lint` ## References - #15923 - #15928 - #15944 - #15953 - #16031 - #16047 - #16129 - #16132 - #16138 --- codex-rs/core/src/tools/spec.rs | 972 +----------------- codex-rs/core/src/tools/spec_tests.rs | 50 +- codex-rs/tools/README.md | 2 + codex-rs/tools/src/agent_job_tool.rs | 141 +++ codex-rs/tools/src/agent_job_tool_tests.rs | 140 +++ codex-rs/tools/src/agent_tool.rs | 729 +++++++++++++ codex-rs/tools/src/agent_tool_tests.rs | 152 +++ codex-rs/tools/src/lib.rs | 19 + codex-rs/tools/src/request_user_input_tool.rs | 94 ++ .../src/request_user_input_tool_tests.rs | 102 ++ 10 files changed, 1461 insertions(+), 940 deletions(-) create mode 100644 codex-rs/tools/src/agent_job_tool.rs create mode 100644 codex-rs/tools/src/agent_job_tool_tests.rs create mode 100644 codex-rs/tools/src/agent_tool.rs create mode 100644 codex-rs/tools/src/agent_tool_tests.rs create mode 100644 codex-rs/tools/src/request_user_input_tool.rs create mode 100644 codex-rs/tools/src/request_user_input_tool_tests.rs diff --git a/codex-rs/core/src/tools/spec.rs b/codex-rs/core/src/tools/spec.rs index 2e0dcf084..2cdd8ade2 100644 --- a/codex-rs/core/src/tools/spec.rs +++ b/codex-rs/core/src/tools/spec.rs @@ -2,7 +2,6 @@ use crate::client_common::tools::ToolSpec; use crate::config::AgentRoleConfig; use crate::mcp::CODEX_APPS_MCP_SERVER_NAME; use crate::mcp_connection_manager::ToolInfo; -use crate::models_manager::collaboration_mode_presets::CollaborationModesConfig; use crate::original_image_detail::can_request_original_image_detail; use crate::shell::Shell; use crate::shell::ShellType; @@ -46,13 +45,29 @@ use codex_tools::FreeformTool; use codex_tools::FreeformToolFormat; use codex_tools::ResponsesApiTool; use codex_tools::ShellToolOptions; +use codex_tools::SpawnAgentToolOptions; use codex_tools::ViewImageToolOptions; +use codex_tools::WaitAgentTimeoutOptions; use codex_tools::augment_tool_spec_for_code_mode; +use codex_tools::create_assign_task_tool; +use codex_tools::create_close_agent_tool_v1; +use codex_tools::create_close_agent_tool_v2; use codex_tools::create_exec_command_tool; +use codex_tools::create_list_agents_tool; +use codex_tools::create_report_agent_job_result_tool; use codex_tools::create_request_permissions_tool; +use codex_tools::create_request_user_input_tool; +use codex_tools::create_resume_agent_tool; +use codex_tools::create_send_input_tool_v1; +use codex_tools::create_send_message_tool; use codex_tools::create_shell_command_tool; use codex_tools::create_shell_tool; +use codex_tools::create_spawn_agent_tool_v1; +use codex_tools::create_spawn_agent_tool_v2; +use codex_tools::create_spawn_agents_on_csv_tool; use codex_tools::create_view_image_tool; +use codex_tools::create_wait_agent_tool_v1; +use codex_tools::create_wait_agent_tool_v2; use codex_tools::create_write_stdin_tool; use codex_tools::dynamic_tool_to_responses_api_tool; use codex_tools::mcp_tool_to_responses_api_tool; @@ -61,8 +76,6 @@ use codex_utils_absolute_path::AbsolutePathBuf; use codex_utils_template::Template; use serde::Deserialize; use serde::Serialize; -use serde_json::Value as JsonValue; -use serde_json::json; use std::collections::BTreeMap; use std::collections::HashMap; use std::path::PathBuf; @@ -89,186 +102,6 @@ static TOOL_SUGGEST_DESCRIPTION_TEMPLATE: LazyLock