Refactor namespaced tool spec registration#22256
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 381d4103ed
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
381d410 to
c4cd824
Compare
pakrym-oai
commented
May 12, 2026
…-tool-spec-refactor # Conflicts: # codex-rs/core/src/tools/registry.rs # codex-rs/core/src/tools/spec_plan.rs
jif-oai
reviewed
May 12, 2026
| } | ||
| } | ||
|
|
||
| if let Some(deferred_mcp_tools) = params.deferred_mcp_tools { |
Collaborator
There was a problem hiding this comment.
The dedup is gone but I don't see it anywhere...
Collaborator
Author
There was a problem hiding this comment.
registration API on builder dedups.
…c' into pakrym/code-mode-remove-find-spec
…-tool-spec-refactor # Conflicts: # codex-rs/core/src/tools/handlers/dynamic.rs # codex-rs/core/src/tools/router_tests.rs
…l-spec-refactor # Conflicts: # codex-rs/core/src/tools/code_mode/mod.rs # codex-rs/core/src/tools/router_tests.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This refactor makes tool handlers the owner of the specs they can publish, so registry construction can register handlers once and separately publish only the specs that should be model-visible.
The main motivation is deferred tools: MCP and dynamic tools still need handlers registered up front, but deferred tools should be discoverable through
tool_searchrather than emitted in the initial tool spec list.What changed
McpHandlerandDynamicToolHandlercan return their ownToolSpec.build_tool_registry_buildernow collects handlers, registers them through the no-spec path, and publishes only non-deferred handler specs.all_deferred_toolsset that drives spec filtering, code-mode deferred-tool signaling, andtool_searchregistration.tool_searchregistration now requires both deferred tools andnamespace_tools.spec_plan, preserving top-level spec order, sorting tools within each namespace, and backfilling empty namespace descriptions.Testing
cargo test -p codex-core tools::spec::tests:: -- --nocapturecargo test -p codex-core tools::spec_plan::tests:: -- --nocapturecargo test -p codex-core tools::router::tests::specs_filter_deferred_dynamic_tools -- --nocapturecargo test -p codex-core suite::prompt_caching::prompt_tools_are_consistent_across_requests -- --nocapturejust fmtjust fix -p codex-corecargo test -p codex-core -- --skip tools::handlers::multi_agents::tests::tool_handlers_cascade_close_and_resume_and_keep_explicitly_closed_subtrees_closedpassed the library suite after skipping the known stack-overflowing unit test.Full
cargo test -p codex-corecurrently hits a stack overflow intools::handlers::multi_agents::tests::tool_handlers_cascade_close_and_resume_and_keep_explicitly_closed_subtrees_closed; the same focused test reproduces onorigin/main.