Repository navigation
Flatten MCP namespace tools for unsupported providers - #28271
kotakem-openai wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6219b01856
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 785a5a6fae
ℹ️ 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".
| let exposure = if search_tool_enabled(turn_context) { | ||
| ToolExposure::Deferred |
There was a problem hiding this comment.
Preserve spawn-agent hook names after flattening
When search_tool_enabled is true for a provider with namespace_tools = false, v1 multi-agent tools now load through tool_search as flat functions like multi_agent_v1__spawn_agent. The registry fallback executes the namespaced SpawnAgentHandler, but the invocation name remains the flat plain name, so function_hook_tool_name no longer maps the call to HookToolName::spawn_agent() with the Agent alias. Existing pre/post hook policies that match spawn_agent or Agent therefore stop applying in exactly this flattened v1 path; either dispatch with the matched runtime's canonical ToolName or recognize the flattened v1 names in the hook-name special case.
Useful? React with 👍 / 👎.
|
|
||
| fn capabilities(&self) -> ProviderCapabilities { | ||
| ProviderCapabilities { | ||
| namespace_tools: resolve_namespace_tools(&self.info), |
There was a problem hiding this comment.
Keep standalone tools available for Responses Lite
For a configured non-OpenAI provider whose model uses Responses Lite, this new default makes namespace_tools false, but hosted_model_tool_specs returns no hosted web/image tools for Responses Lite and standalone_web_search_enabled / standalone_image_generation_model_visible still require namespace support before extension tools are even registered. That means providers that need flattened tools lose web.run and image_gen.imagegen entirely instead of exposing them as flat functions, so Responses Lite sessions cannot use those features unless they opt back into the wrapper they may reject.
AGENTS.md reference: AGENTS.md:L103-L110
Useful? React with 👍 / 👎.
|
Tested this locally against a real OpenRouter + MCP setup and this PR fixes the failure mode for me. Environment:
Baseline result with Codex 0.141.0, same profile/config/prompt: PR result with the same profile/config/prompt: {"type":"item.started","item":{"type":"mcp_tool_call","server":"jira","tool":"jira_search","arguments":{"jql":"issuetype = Story AND creator = currentUser() ORDER BY created DESC","fields":"key,summary,status,created","limit":1}}}The call completed successfully and returned the expected Jira issue: One local note: running the probe with So from my side this validates the flattened-tool path for OpenRouter/Grok and restores MCP tool use that is absent in 0.141.0. |
5c6d729 to
42961ed
Compare
42961ed to
18fecc6
Compare
|
Closing this PR in favor of #29602. After working through the review feedback, I realized this approach was conflating two separate concerns: whether a provider accepts Codex's #29602 takes a narrower approach: it treats This supersedes the implementation in this PR, so I am closing this one to keep review focused on the revised approach. |
Checked before filing: the namespace_tools defect is already reported upstream as openai#26234 (open since 2026-06-03, `bug`, 29 comments, reference branch attached) and openai#33263. Two fix PRs, openai#28271 and openai#29602, were authored by an OpenAI engineer and both closed unmerged without explanation. So this is not a transitional patch awaiting an upstream fix — plan to carry it. Records the evidence, and notes that openai#26234's per-provider `namespace_tools` config (defaulting to `requires_openai_auth`) is a better shape than our global feature flag if we revisit it.
Summary
Fixes #26234.
Some Responses API-compatible providers do not understand Codex's proprietary
type: "namespace"tool wrapper. When MCP tools are only exposed through that wrapper, those providers never see callable MCP functions.This change adds a provider capability for namespace tool support and flattens namespace tools into plain functions when the active provider does not support the wrapper.
Manual repro is attached on #26234.
What Changed
namespace_toolstoModelProviderInfo.namespace_tools = false.<namespace>__<tool>function names when namespace tools are disabled.tool_searchwhen namespaces are flattened, and flattened deferred search results before returning them to the model.<namespace>__<tool>calls resolve back to the namespaced runtime.namespace_toolsthrough remote thread config serialization.Test Plan
just test -p codex-app-server validate_dynamic_tools_rejects_duplicate_canonical_flat_namejust test -p codex-core handler_resolves_flat_name_to_namespaced_runtime namespace_tools_disabled_flattens_mcp_namespace_into_function mcp_and_tool_search_follow_direct_and_deferred_tool_exposure search_results_flatten_mcp_namespaces_without_namespace_toolsjust test -p codex-protocoljust test -p codex-toolsjust test -p codex-model-provider-info test_merge_configured_model_providers_applies_amazon_bedrock_namespace_tools_override test_merge_configured_model_providers_applies_amazon_bedrock_allowed_overrides_together test_merge_configured_model_providers_rejects_amazon_bedrock_non_default_fieldsjust test -p codex-core accepts_amazon_bedrock_namespace_tools_override load_config_applies_amazon_bedrock_namespace_tools_override load_config_applies_amazon_bedrock_allowed_overrides_together load_config_rejects_unsupported_amazon_bedrock_overrides