Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions codex-rs/core/src/tools/handlers/tool_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,12 @@ mod tests {
description: "Create events desktop tool".to_string(),
strict: false,
defer_loading: Some(true),
parameters: codex_tools::JsonSchema::object(
Default::default(),
/*required*/ None,
Some(false.into()),
parameters: codex_tools::JsonSchema::from_raw_tool_input_schema(
serde_json::json!({
"type": "object",
"properties": {},
"additionalProperties": false,
}),
),
output_schema: None,
}),
Expand All @@ -262,10 +264,12 @@ mod tests {
description: "List events desktop tool".to_string(),
strict: false,
defer_loading: Some(true),
parameters: codex_tools::JsonSchema::object(
Default::default(),
/*required*/ None,
Some(false.into()),
parameters: codex_tools::JsonSchema::from_raw_tool_input_schema(
serde_json::json!({
"type": "object",
"properties": {},
"additionalProperties": false,
}),
),
output_schema: None,
}),
Expand All @@ -280,13 +284,15 @@ mod tests {
.to_string(),
strict: false,
defer_loading: Some(true),
parameters: codex_tools::JsonSchema::object(
std::collections::BTreeMap::from([(
"mode".to_string(),
codex_tools::JsonSchema::string(/*description*/ None),
)]),
Some(vec!["mode".to_string()]),
Some(false.into()),
parameters: codex_tools::JsonSchema::from_raw_tool_input_schema(
serde_json::json!({
"type": "object",
"properties": {
"mode": { "type": "string" },
},
"required": ["mode"],
"additionalProperties": false,
}),
),
output_schema: None,
})],
Expand Down
71 changes: 20 additions & 51 deletions codex-rs/core/src/tools/spec_plan_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ fn test_test_model_info_includes_sync_tool() {
}

#[test]
fn test_build_specs_mcp_tools_converted() {
fn test_build_specs_mcp_tools_preserve_raw_schema() {
let model_info = model_info();
let mut features = Features::with_defaults();
features.enable(Feature::UnifiedExec);
Expand All @@ -1290,29 +1290,31 @@ fn test_build_specs_mcp_tools_converted() {
permission_profile: &PermissionProfile::Disabled,
windows_sandbox_level: WindowsSandboxLevel::Disabled,
});
let input_schema = serde_json::json!({
"type": "object",
"properties": {
"string_argument": { "type": "string" },
"number_argument": { "type": "number" },
"object_argument": {
"type": "object",
"properties": {
"string_property": { "type": "string" },
"number_property": { "type": "number" },
},
"required": ["string_property", "number_property"],
"additionalProperties": false,
},
},
});

let (tools, _) = build_specs(
&tools_config,
Some(HashMap::from([(
ToolName::namespaced("test_server/", "do_something_cool"),
mcp_tool(
"do_something_cool",
"Do something cool",
serde_json::json!({
"type": "object",
"properties": {
"string_argument": { "type": "string" },
"number_argument": { "type": "number" },
"object_argument": {
"type": "object",
"properties": {
"string_property": { "type": "string" },
"number_property": { "type": "number" },
},
"required": ["string_property", "number_property"],
"additionalProperties": false,
},
},
}),
input_schema.clone(),
),
)])),
/*deferred_mcp_tools*/ None,
Expand All @@ -1324,40 +1326,7 @@ fn test_build_specs_mcp_tools_converted() {
tool,
&ResponsesApiTool {
name: "do_something_cool".to_string(),
parameters: JsonSchema::object(
BTreeMap::from([
(
"string_argument".to_string(),
JsonSchema::string(/*description*/ None),
),
(
"number_argument".to_string(),
JsonSchema::number(/*description*/ None),
),
(
"object_argument".to_string(),
JsonSchema::object(
BTreeMap::from([
(
"string_property".to_string(),
JsonSchema::string(/*description*/ None),
),
(
"number_property".to_string(),
JsonSchema::number(/*description*/ None),
),
]),
Some(vec![
"string_property".to_string(),
"number_property".to_string(),
]),
Some(false.into()),
),
),
]),
/*required*/ None,
/*additional_properties*/ None
),
parameters: JsonSchema::from_raw_tool_input_schema(input_schema),
description: "Do something cool".to_string(),
strict: false,
output_schema: Some(mcp_call_tool_result_output_schema(serde_json::json!({}))),
Expand Down
Loading
Loading