Skip to content

feat: extract shared tool executor interface#22359

Merged
jif-oai merged 2 commits into
mainfrom
jif/tool-runtime-trait
May 13, 2026
Merged

feat: extract shared tool executor interface#22359
jif-oai merged 2 commits into
mainfrom
jif/tool-runtime-trait

Conversation

@jif-oai
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai commented May 12, 2026

Why

Codex still models model-visible tools and executable behavior largely inside codex-core, which makes it harder to evolve the tool system toward a single reusable abstraction for built-ins, MCP-backed tools, dynamic tools, and later tools injected from outside core.

This PR takes the next incremental step in that direction by moving the common execution-facing pieces out of core and separating them from core-only orchestration. The intent is to let shared tool abstractions improve in one place, while codex-core keeps the parts that are still inherently host-specific today, such as ToolInvocation, dispatch wiring, and hook integration.

This PR is mostly moving things around. The only interesting piece is this abstraction: https://github.com/openai/codex/pull/22359/changes#diff-81af519002548ba51ed102bdaaf77e081d40a1e73a6e5f9b104bbbc96a6f1b3dR13

What changed

  • Added codex_tools::ToolExecutor<Invocation> as the shared execution trait for model-visible tools.
  • Moved the reusable execution support types from codex-core into codex-tools:
    • FunctionCallError
    • ToolPayload
    • ToolOutput
  • Refactored core tool implementations so that execution behavior lives on ToolExecutor<ToolInvocation>, while ToolHandler remains the core-local extension point for hook payloads, telemetry tags, diff consumers, and other orchestration concerns.
  • Kept the registry and dispatch flow behaviorally unchanged while making the shared/extracted boundary explicit across built-in, MCP, dynamic, extension-backed, shell, and multi-agent tool handlers.

Verification

  • cargo test -p codex-tools
  • just fix -p codex-tools
  • just fix -p codex-core
  • cargo test -p codex-core progressed through the updated tool surfaces and then hit the existing unrelated multi-agent stack overflow in tools::handlers::multi_agents::tests::tool_handlers_cascade_close_and_resume_and_keep_explicitly_closed_subtrees_closed.

@jif-oai jif-oai requested a review from a team as a code owner May 12, 2026 18:24
@jif-oai jif-oai changed the title feat: tool executor feat: extract shared tool executor interface May 12, 2026
@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented May 12, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. More of your lovely PRs please.

ℹ️ 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".

@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented May 13, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Delightful!

ℹ️ 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".

…trait

# Conflicts:
#	codex-rs/core/src/tools/handlers/apply_patch.rs
#	codex-rs/core/src/tools/handlers/extension_tools.rs
#	codex-rs/core/src/tools/handlers/multi_agents/close_agent.rs
#	codex-rs/core/src/tools/handlers/multi_agents/resume_agent.rs
#	codex-rs/core/src/tools/handlers/multi_agents/spawn.rs
#	codex-rs/core/src/tools/handlers/multi_agents_v2/close_agent.rs
#	codex-rs/core/src/tools/handlers/multi_agents_v2/spawn.rs
#	codex-rs/core/src/tools/handlers/shell/container_exec.rs
#	codex-rs/core/src/tools/handlers/shell/local_shell.rs
#	codex-rs/core/src/tools/handlers/shell/shell_command.rs
#	codex-rs/core/src/tools/handlers/shell/shell_handler.rs
#	codex-rs/core/src/tools/handlers/unavailable_tool.rs
#	codex-rs/core/src/tools/handlers/unified_exec/exec_command.rs
#	codex-rs/core/src/tools/handlers/unified_exec/write_stdin.rs
#	codex-rs/core/src/tools/registry.rs
#	codex-rs/tools/src/lib.rs
@jif-oai jif-oai force-pushed the jif/tool-runtime-trait branch from 6199dbc to 436b20e Compare May 13, 2026 09:24
@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented May 13, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ 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".

@jif-oai jif-oai merged commit 1824685 into main May 13, 2026
27 checks passed
@jif-oai jif-oai deleted the jif/tool-runtime-trait branch May 13, 2026 09:31
@github-actions github-actions Bot locked and limited conversation to collaborators May 13, 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