Skip to content

feat: introduce registry for tool handlers and schemas #779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

joerucci
Copy link

@joerucci joerucci commented May 2, 2025

What

This PR refactors tool dispatch to use a centralized, registry-based system.

  • Introduces a shared tool registry (registerTool, getToolHandler)
  • Supports OpenAI-compatible tool schemas (FunctionTool)
  • Enables alias resolution for legacy tool names (e.g. container.exec)
  • Moves shell tool definition and handler into standalone modules
  • Adds registerDefaultTools() to cleanly register built-in tools
  • Replaces hardcoded tool dispatch logic in AgentLoop with dynamic lookup

Why

Previously, tool execution was hardcoded inside agent-loop.ts, limiting extensibility. This change lays the foundation for modular and plugin-based tooling, while preserving existing behavior.

How

  • Built a minimal tool-registry.ts to track tool schemas and handlers
  • Aliases are resolved internally, but not sent to the model
  • shell is now first-class tool registered by default
  • Updated AgentLoop to call getToolHandler() instead of matching on tool name

This prepares Codex CLI for easier tool extension while preserving existing functionality.

@joerucci
Copy link
Author

joerucci commented May 2, 2025

I have read the CLA Document and I hereby sign the CLA

Copy link

github-actions bot commented May 2, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

github-actions bot added a commit that referenced this pull request May 2, 2025
@ottojung
Copy link

ottojung commented May 2, 2025

Please make it possible to disable the built-in shell tool. Codex is often very inefficient with generic shell commands + it's difficult to make them unavailable otherwise (ex: by removing them from $PATH).

@joerucci
Copy link
Author

joerucci commented May 5, 2025

Please make it possible to disable the built-in shell tool. Codex is often very inefficient with generic shell commands + it's difficult to make them unavailable otherwise (ex: by removing them from $PATH).

Thanks, that’s a great point. I’ll follow up with a separate PR to make the default tool registration optional — possibly via an env var or config hook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants