Skip to content

codex-tools: introduce named tool definitions#15953

Merged
bolinfest merged 1 commit intomainfrom
pr15953
Mar 27, 2026
Merged

codex-tools: introduce named tool definitions#15953
bolinfest merged 1 commit intomainfrom
pr15953

Conversation

@bolinfest
Copy link
Copy Markdown
Collaborator

@bolinfest bolinfest commented Mar 27, 2026

Why

This continues the codex-tools migration by moving one more piece of generic tool-definition bookkeeping out of codex-core.

The earlier extraction steps moved shared schema parsing into codex-tools, but core/src/tools/spec.rs still had to supply tool names separately and perform ad hoc rewrites for deferred MCP aliases. That meant the crate boundary was still awkward: the parsed shape coming back from codex-tools was missing part of the definition that codex-core ultimately needs to assemble a ResponsesApiTool.

This change introduces a named ToolDefinition in codex-tools so both MCP tools and dynamic tools cross the crate boundary in the same reusable model. codex-core still owns the final ResponsesApiTool assembly, but less of the generic tool-definition shaping logic stays behind in core.

What changed

  • replaced ParsedToolDefinition with a named ToolDefinition in codex-rs/tools/src/tool_definition.rs
  • added codex-rs/tools/src/tool_definition_tests.rs for renamed() and into_deferred()
  • updated parse_dynamic_tool() and parse_mcp_tool() to return ToolDefinition
  • simplified codex-rs/core/src/tools/spec.rs so it adapts ToolDefinition into ResponsesApiTool instead of rewriting names and deferred fields inline
  • updated parser tests and codex-rs/tools/README.md to reflect the named tool-definition model

Test plan

  • cargo test -p codex-tools
  • cargo test -p codex-core --lib tools::spec::
@bolinfest bolinfest changed the base branch from main to pr15944 March 27, 2026 05:07
bolinfest added a commit that referenced this pull request Mar 27, 2026
## Why

`codex-tools` already owned the shared JSON schema parser and the MCP
tool schema adapter, but `core/src/tools/spec.rs` still parsed dynamic
tools directly.

That left the tool-schema boundary split in two different ways:

- MCP tools flowed through `codex-tools`, while dynamic tools were still
parsed in `codex-core`
- the extracted dynamic-tool path initially introduced a
dynamic-specific parsed shape even though `codex-tools` already had very
similar MCP adapter output

This change finishes that extraction boundary in one step. `codex-core`
still owns `ResponsesApiTool` assembly, but both MCP tools and dynamic
tools now enter that layer through `codex-tools` using the same parsed
tool-definition shape.

## What changed

- added `tools/src/dynamic_tool.rs` and sibling
`tools/src/dynamic_tool_tests.rs`
- introduced `parse_dynamic_tool()` in `codex-tools` and switched
`core/src/tools/spec.rs` to use it for dynamic tools
- added `tools/src/parsed_tool_definition.rs` so both MCP and dynamic
adapters return the same `ParsedToolDefinition`
- updated `core/src/tools/spec.rs` to build `ResponsesApiTool` through a
shared local adapter helper instead of separate MCP and dynamic assembly
paths
- expanded `core/src/tools/spec_tests.rs` so the dynamic-tool adapter
test asserts the full converted `ResponsesApiTool`, including
`defer_loading`
- updated `codex-rs/tools/README.md` to reflect the shared parsed
tool-definition boundary

## Test plan

- `cargo test -p codex-tools`
- `cargo test -p codex-core --lib tools::spec::`

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/15944).
* #15953
* __->__ #15944
Base automatically changed from pr15944 to main March 27, 2026 16:12
@bolinfest bolinfest enabled auto-merge (squash) March 27, 2026 17:11
@bolinfest bolinfest disabled auto-merge March 27, 2026 19:02
@bolinfest bolinfest merged commit caee620 into main Mar 27, 2026
108 of 124 checks passed
@bolinfest bolinfest deleted the pr15953 branch March 27, 2026 19:02
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

2 participants