mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
7880414a27
## 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
103 lines
5.4 KiB
Rust
103 lines
5.4 KiB
Rust
use super::*;
|
|
use pretty_assertions::assert_eq;
|
|
use std::collections::BTreeMap;
|
|
|
|
#[test]
|
|
fn request_user_input_tool_includes_questions_schema() {
|
|
assert_eq!(
|
|
create_request_user_input_tool("Ask the user to choose.".to_string()),
|
|
ToolSpec::Function(ResponsesApiTool {
|
|
name: "request_user_input".to_string(),
|
|
description: "Ask the user to choose.".to_string(),
|
|
strict: false,
|
|
defer_loading: None,
|
|
parameters: JsonSchema::Object {
|
|
properties: BTreeMap::from([(
|
|
"questions".to_string(),
|
|
JsonSchema::Array {
|
|
description: Some(
|
|
"Questions to show the user. Prefer 1 and do not exceed 3".to_string(),
|
|
),
|
|
items: Box::new(JsonSchema::Object {
|
|
properties: BTreeMap::from([
|
|
(
|
|
"header".to_string(),
|
|
JsonSchema::String {
|
|
description: Some(
|
|
"Short header label shown in the UI (12 or fewer chars)."
|
|
.to_string(),
|
|
),
|
|
},
|
|
),
|
|
(
|
|
"id".to_string(),
|
|
JsonSchema::String {
|
|
description: Some(
|
|
"Stable identifier for mapping answers (snake_case)."
|
|
.to_string(),
|
|
),
|
|
},
|
|
),
|
|
(
|
|
"options".to_string(),
|
|
JsonSchema::Array {
|
|
description: Some(
|
|
"Provide 2-3 mutually exclusive choices. Put the recommended option first and suffix its label with \"(Recommended)\". Do not include an \"Other\" option in this list; the client will add a free-form \"Other\" option automatically."
|
|
.to_string(),
|
|
),
|
|
items: Box::new(JsonSchema::Object {
|
|
properties: BTreeMap::from([
|
|
(
|
|
"description".to_string(),
|
|
JsonSchema::String {
|
|
description: Some(
|
|
"One short sentence explaining impact/tradeoff if selected."
|
|
.to_string(),
|
|
),
|
|
},
|
|
),
|
|
(
|
|
"label".to_string(),
|
|
JsonSchema::String {
|
|
description: Some(
|
|
"User-facing label (1-5 words)."
|
|
.to_string(),
|
|
),
|
|
},
|
|
),
|
|
]),
|
|
required: Some(vec![
|
|
"label".to_string(),
|
|
"description".to_string(),
|
|
]),
|
|
additional_properties: Some(false.into()),
|
|
}),
|
|
},
|
|
),
|
|
(
|
|
"question".to_string(),
|
|
JsonSchema::String {
|
|
description: Some(
|
|
"Single-sentence prompt shown to the user.".to_string(),
|
|
),
|
|
},
|
|
),
|
|
]),
|
|
required: Some(vec![
|
|
"id".to_string(),
|
|
"header".to_string(),
|
|
"question".to_string(),
|
|
"options".to_string(),
|
|
]),
|
|
additional_properties: Some(false.into()),
|
|
}),
|
|
},
|
|
)]),
|
|
required: Some(vec!["questions".to_string()]),
|
|
additional_properties: Some(false.into()),
|
|
},
|
|
output_schema: None,
|
|
})
|
|
);
|
|
}
|