feat(core): expose agent tools in namespace

This commit is contained in:
Friel
2026-03-30 00:54:18 +00:00
parent bb95ec3ec6
commit 1222f23d0c
6 changed files with 107 additions and 71 deletions
+2 -1
View File
@@ -132,7 +132,8 @@ fn code_mode_tool_definition_for_spec(spec: &ToolSpec) -> Option<CodeModeToolDef
input_schema: None,
output_schema: None,
}),
ToolSpec::LocalShell {}
ToolSpec::Namespace(_)
| ToolSpec::LocalShell {}
| ToolSpec::ImageGeneration { .. }
| ToolSpec::ToolSearch { .. }
| ToolSpec::WebSearch { .. } => None,
+4
View File
@@ -1,5 +1,6 @@
use crate::FreeformTool;
use crate::JsonSchema;
use crate::ResponsesApiNamespace;
use crate::ResponsesApiTool;
use codex_protocol::config_types::WebSearchContextSize;
use codex_protocol::config_types::WebSearchFilters as ConfigWebSearchFilters;
@@ -15,6 +16,8 @@ use serde_json::Value;
pub enum ToolSpec {
#[serde(rename = "function")]
Function(ResponsesApiTool),
#[serde(rename = "namespace")]
Namespace(ResponsesApiNamespace),
#[serde(rename = "tool_search")]
ToolSearch {
execution: String,
@@ -52,6 +55,7 @@ impl ToolSpec {
pub fn name(&self) -> &str {
match self {
ToolSpec::Function(tool) => tool.name.as_str(),
ToolSpec::Namespace(namespace) => namespace.name.as_str(),
ToolSpec::ToolSearch { .. } => "tool_search",
ToolSpec::LocalShell {} => "local_shell",
ToolSpec::ImageGeneration { .. } => "image_generation",
+28
View File
@@ -6,6 +6,7 @@ use crate::AdditionalProperties;
use crate::FreeformTool;
use crate::FreeformToolFormat;
use crate::JsonSchema;
use crate::ResponsesApiNamespace;
use crate::ResponsesApiTool;
use crate::create_tools_json_for_responses_api;
use codex_protocol::config_types::WebSearchContextSize;
@@ -47,6 +48,15 @@ fn tool_spec_name_covers_all_variants() {
.name(),
"tool_search"
);
assert_eq!(
ToolSpec::Namespace(ResponsesApiNamespace {
name: "agents".to_string(),
description: "Agent tools".to_string(),
tools: Vec::new(),
})
.name(),
"agents"
);
assert_eq!(ToolSpec::LocalShell {}.name(), "local_shell");
assert_eq!(
ToolSpec::ImageGeneration {
@@ -166,6 +176,24 @@ fn create_tools_json_for_responses_api_includes_top_level_name() {
);
}
#[test]
fn namespace_tool_spec_serializes_expected_wire_shape() {
assert_eq!(
serde_json::to_value(ToolSpec::Namespace(ResponsesApiNamespace {
name: "agents".to_string(),
description: "Agent collaboration tools.".to_string(),
tools: Vec::new(),
}))
.expect("serialize namespace"),
json!({
"type": "namespace",
"name": "agents",
"description": "Agent collaboration tools.",
"tools": []
})
);
}
#[test]
fn web_search_tool_spec_serializes_expected_wire_shape() {
assert_eq!(