feat: add supports_parallel_tool_calls for MCP servers#9944
Closed
teknium1 wants to merge 1 commit into
Closed
Conversation
Port from openai/codex#17667: MCP servers can now opt-in to parallel tool execution by setting supports_parallel_tool_calls: true in their config. This allows tools from the same server to run concurrently within a single tool-call batch, matching the behavior already available for built-in tools like web_search and read_file. Previously all MCP tools were forced sequential because they weren't in the _PARALLEL_SAFE_TOOLS set. Now _should_parallelize_tool_batch checks is_mcp_tool_parallel_safe() which looks up the server's config flag. Config example: mcp_servers: docs: command: "docs-server" supports_parallel_tool_calls: true Changes: - tools/mcp_tool.py: Track parallel-safe servers in _parallel_safe_servers set, populated during register_mcp_servers(). Add is_mcp_tool_parallel_safe() public API. - run_agent.py: Add _is_mcp_tool_parallel_safe() lazy-import wrapper. Update _should_parallelize_tool_batch() to check MCP tools against server config. - 11 new tests covering the feature end-to-end. - Updated MCP docs and config reference.
Contributor
Author
|
Closing in favor of #26825, which salvages this PR onto current main with the cherry-pick conflict (circuit breaker block landed on main after this PR's branch point) resolved and two stale test mocks of the removed |
Contributor
Author
|
Correction on the earlier close comment: #26825 was squash-merged (not rebase-merged). Authorship is preserved in either case since both PRs were authored by you. |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Port of openai/codex#17667: MCP servers can now opt-in to parallel tool execution via a per-server config flag.
Problem
All MCP tools were forced to run sequentially because they weren't in the static
_PARALLEL_SAFE_TOOLSset in run_agent.py. This was unnecessarily slow for MCP servers whose tools are safe to run concurrently (e.g. read-only query servers, independent API endpoints).Solution
Add
supports_parallel_tool_calls: trueconfig option for MCP servers:When set, tools from that server are eligible for concurrent execution in the same tool-call batch, matching the behavior already available for built-in read-only tools (web_search, read_file, etc.).
Implementation
_parallel_safe_serversset tracks sanitized server names with the flag enabled. Populated duringregister_mcp_servers()(idempotent, handles toggling on/off). New public APIis_mcp_tool_parallel_safe(tool_name)checks if a tool belongs to a parallel-safe server._is_mcp_tool_parallel_safe()lazy-import wrapper._should_parallelize_tool_batch()now checks MCP tools against server config when they're not in the static parallel-safe set.is_mcp_tool_parallel_safe()andregister_mcp_serverstracking, plus 4 integration tests for_should_parallelize_tool_batch()with MCP tools.Architectural differences from Codex
Codex is Rust and threads the config through
ToolRouterat the crate level. Hermes uses a module-level set (_parallel_safe_servers) populated during MCP server registration, queried via a function that does server name extraction from tool names. The server name matching handles underscores in sanitized server names by checking all registered parallel-safe prefixes.Test plan