Move tool search metadata onto ToolExecutor (#25684)

Deferred tools need to be searchable even when they are not implemented
inside `codex-core`. Extension-provided tools can be registered for
later discovery, but the search metadata path was still owned by
core-specific runtime hooks, which meant the shared `ToolExecutor`
abstraction could not describe how a deferred extension tool should
appear in `tool_search`.

## Changes

- Move `ToolSearchEntry` and `ToolSearchInfo` into `codex-tools` and
re-export them from the shared tools crate.
- Add a default `ToolExecutor::search_info` implementation that derives
loadable tool-search metadata from function and namespace specs.
- Forward search metadata through extension adapters and exposure
overrides while keeping custom search text/source metadata for dynamic,
MCP, and multi-agent tools.
- Remove the old core-local `tool_search_entry` module now that search
metadata lives with the shared executor APIs.

## Testing

- Added `deferred_extension_tools_are_discoverable_with_tool_search`
coverage in `core/src/tools/spec_plan_tests.rs`.
This commit is contained in:
jif-oai
2026-06-02 00:24:41 +02:00
committed by GitHub
Unverified
parent 8ee49a2f74
commit 8d720feb69
18 changed files with 302 additions and 149 deletions
+9 -1
View File
@@ -1,6 +1,7 @@
use crate::FunctionCallError;
use crate::ToolName;
use crate::ToolOutput;
use crate::ToolSearchInfo;
use crate::ToolSpec;
/// Controls where a tool is exposed to the model.
@@ -13,7 +14,9 @@ pub enum ToolExposure {
Direct,
/// Register this tool for later discovery, but omit it from the initial
/// model-visible tool list.
/// model-visible tool list. Deferred tools must provide search metadata via
/// [`ToolExecutor::search_info`]. The default implementation derives
/// metadata from function and namespace specs.
Deferred,
/// Include this tool in the initial model-visible tool list only.
@@ -48,6 +51,11 @@ pub trait ToolExecutor<Invocation>: Send + Sync {
ToolExposure::Direct
}
fn search_info(&self) -> Option<ToolSearchInfo> {
let spec = self.spec();
ToolSearchInfo::from_tool_spec(&self.tool_name(), spec, /*source_info*/ None)
}
fn supports_parallel_tool_calls(&self) -> bool {
false
}