Skip to content

enable tool search over dynamic tools - #18263

Merged
sayan-oai merged 7 commits into
mainfrom
codex/tool-search-entry-adapter-cleanup
Apr 17, 2026
Merged

sayan-oai merged 7 commits into
mainfrom
codex/tool-search-entry-adapter-cleanup

Conversation

@sayan-oai

Copy link
Copy Markdown
Contributor

Summary

  • Normalize deferred MCP and dynamic tools into ToolSearchEntry values before constructing ToolSearchHandler.
  • Move the tool-search entry adapter out of tools/handlers and into tools/tool_search_entry.rs so the handlers directory stays focused on handlers.
  • Keep ToolSearchHandler operating over one generic entry list for BM25 search, namespace grouping, and per-bucket default limits.

Why

Follow-up cleanup for #17849. The dynamic tool-search support made the handler juggle source-specific MCP and dynamic tool lists, index arithmetic, output conversion, and namespace emission. This keeps source adaptation outside the handler so the search loop itself is smaller and source-agnostic.

Validation

  • just fmt
  • cargo test -p codex-core tools::handlers::tool_search::tests
  • git diff --check
  • cargo test -p codex-core currently fails in unrelated plugins::manager::tests::list_marketplaces_ignores_installed_roots_missing_from_config; rerunning that single test fails the same way at core/src/plugins/manager_tests.rs:1692.

@sayan-oai
sayan-oai changed the base branch from codex/search-deferred-dynamic-tools to main April 17, 2026 10:05
@sayan-oai
sayan-oai force-pushed the codex/tool-search-entry-adapter-cleanup branch from dba0847 to c955ab8 Compare April 17, 2026 10:55
@sayan-oai
sayan-oai marked this pull request as ready for review April 17, 2026 10:55
ToolSearchOutputTool::Function(tool) => {
tools.push(ToolSearchOutputTool::Function(tool.clone()));
}
ToolSearchOutputTool::Namespace(namespace) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this complicated logic? are we creating duplicated namespaces somewhere?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we do the same namespace merging on normal path?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its to avoid duplicate namespace entries while preserving search result order. dynamic tools can interleave results from the same namespace, so we merge later hits into the first namespace entry. the ideas being:

  1. we want to preserve search ordering
  2. we dont want to show the model repeated entries for the same namespace

Comment thread codex-rs/tools/src/tool_discovery.rs Resolved
Comment thread codex-rs/tools/src/tool_discovery.rs Resolved
@sayan-oai sayan-oai changed the title [codex] Clean up tool search entries enable tool search over dynamic tools Apr 17, 2026
@sayan-oai

Copy link
Copy Markdown
Contributor Author

follow ups i noted but dont want to block this on:

  • lazy load bm25 index?
  • clean up ToolSearchResultSource
  • is it worth indexing tool search entries by ToolName rather than usize?

@sayan-oai
sayan-oai merged commit 6991be7 into main Apr 17, 2026
34 of 36 checks passed
@sayan-oai
sayan-oai deleted the codex/tool-search-entry-adapter-cleanup branch April 17, 2026 18:08
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants