mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Use generic search metadata for dynamic tools (#27356)
## Why Dynamic tools maintained a separate search-text builder even though the shared tool search path already derives the same metadata from `ToolSpec`. Using the shared path removes duplicate behavior before adding explicit namespaces. ## What changed - Build dynamic-tool search entries with `ToolSearchInfo::from_tool_spec`. - Remove the custom search-text state and its implementation-only unit test. The old search text included the tool name, its space-separated form, description, namespace, and top-level parameter names. The shared builder preserves all of those terms and also indexes namespace descriptions and nested schema metadata. ## Test plan - `just test -p codex-core tool_search_returns_deferred_dynamic_tool_and_routes_follow_up_call`
This commit is contained in:
1 parent
383708e74e
commit
b5a718ef67
2 files changed
+1
-64
No files matched your search
@@ -33,7 +33,6 @@ pub struct DynamicToolHandler {
|
||||
tool_name: ToolName,
|
||||
spec: ToolSpec,
|
||||
exposure: ToolExposure,
|
||||
search_text: String,
|
||||
}
|
||||
|
||||
impl DynamicToolHandler {
|
||||
@@ -56,7 +55,6 @@ impl DynamicToolHandler {
|
||||
} else {
|
||||
ToolExposure::Direct
|
||||
},
|
||||
search_text: build_dynamic_search_text(tool),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -75,8 +73,7 @@ impl ToolExecutor<ToolInvocation> for DynamicToolHandler {
|
||||
}
|
||||
|
||||
fn search_info(&self) -> Option<ToolSearchInfo> {
|
||||
ToolSearchInfo::from_spec(
|
||||
self.search_text.clone(),
|
||||
ToolSearchInfo::from_tool_spec(
|
||||
self.spec(),
|
||||
Some(ToolSearchSourceInfo {
|
||||
name: "Dynamic tools".to_string(),
|
||||
@@ -217,27 +214,3 @@ async fn request_dynamic_tool(
|
||||
|
||||
response
|
||||
}
|
||||
|
||||
fn build_dynamic_search_text(tool: &DynamicToolSpec) -> String {
|
||||
let mut schema_properties = tool
|
||||
.input_schema
|
||||
.get("properties")
|
||||
.and_then(serde_json::Value::as_object)
|
||||
.map(|map| map.keys().cloned().collect::<Vec<_>>())
|
||||
.unwrap_or_default();
|
||||
schema_properties.sort();
|
||||
let mut parts = vec![
|
||||
tool.name.clone(),
|
||||
tool.name.replace('_', " "),
|
||||
tool.description.clone(),
|
||||
];
|
||||
if let Some(namespace) = &tool.namespace {
|
||||
parts.push(namespace.clone());
|
||||
}
|
||||
parts.extend(schema_properties);
|
||||
parts.join(" ")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "dynamic_tests.rs"]
|
||||
mod tests;
|
||||
Reference in new issue
Block a user