Skip to content

Extract tool registry planning into codex-tools#16513

Merged
bolinfest merged 1 commit intomainfrom
pr16513
Apr 2, 2026
Merged

Extract tool registry planning into codex-tools#16513
bolinfest merged 1 commit intomainfrom
pr16513

Conversation

@bolinfest
Copy link
Copy Markdown
Collaborator

@bolinfest bolinfest commented Apr 2, 2026

Why

This is a larger step in the codex-core -> codex-tools migration called out in AGENTS.md.

codex-rs/core/src/tools/spec.rs had become mostly pure tool-spec assembly plus handler registration. That made it hard to move more of the tool-definition layer into codex-tools, because the runtime binding and the crate-independent planning logic were still interleaved in one function.

Splitting those concerns gives codex-tools ownership of the declarative registry plan while keeping codex-core responsible for instantiating concrete handlers.

What Changed

  • Add a codex-tools registry-plan layer in codex-rs/tools/src/tool_registry_plan.rs and codex-rs/tools/src/tool_registry_plan_types.rs.
  • Move feature-gated tool-spec assembly, MCP/dynamic tool conversion, tool-search aliases, and code-mode nested-plan expansion into codex-tools.
  • Keep codex-rs/core/src/tools/spec.rs as the core-side adapter that maps each planned handler kind to concrete runtime handler instances.
  • Update spec_tests.rs to import the moved codex_tools symbols directly instead of relying on top-level spec.rs re-exports.

This is intended to be a straight refactor with no behavior change and no new test surface.

Verification

  • cargo test -p codex-tools
  • cargo test -p codex-core tools::spec::tests

Stack created with Sapling. Best reviewed with ReviewStack.

@bolinfest
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8e7b90b94b

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/core/src/tools/spec.rs Outdated
Comment on lines +134 to +136
let tool_search_handler = app_tools
.as_ref()
.map(|app_tools| Arc::new(ToolSearchHandler::new(app_tools.clone())));
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.

P3 Badge Avoid cloning app tools when tool search is disabled

This eagerly clones the full app_tools map even when config.search_tool is false, but in that configuration no ToolSearch handler is registered from the plan. That introduces avoidable O(n) allocations on every registry build for app-enabled sessions (a regression from the previous branch-local clone), which can add unnecessary latency as the number of app tools grows. Build this handler lazily only when a ToolSearch registration is actually needed.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@codex I believe this is fixed in the latest version of the PR: can you confirm?

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.

Codex Review: Didn't find any major issues. 🚀

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@bolinfest bolinfest merged commit 828b837 into main Apr 2, 2026
22 checks passed
@bolinfest bolinfest deleted the pr16513 branch April 2, 2026 07:18
@github-actions github-actions bot locked and limited conversation to collaborators Apr 2, 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.

1 participant