fix(runtime): canonicalize Codex-mangled MCP tool names before gate checks - #99
Merged
Merged
Conversation
…hecks Codex CLI globally rewrites `-` to `_` on the qualified MCP tool identifier before it reaches any hook (sanitize_responses_api_tool_name(), openai/codex#14605 — Code Mode exposes tools as TypeScript identifiers, where `-` is illegal). This harness compared against the hyphenated form everywhere, so on Codex: SHOT_TOOLS.has() always missed (design pipeline stuck at phase 1), classifyExplore never credited research-expert (APEX freshness gate), and the doc-cache gate never fired. canonicalizeMcpToolName(id, tool) is a pure function, id !== "codex" short-circuits first, two closed null-prototype tables (Object.create(null)) with server-scoped TOOL_ALIASES to avoid corrupting segments that already contain a legitimate underscore. Wired into the 5 ingestion paths: normalize.ts, adapters/codex/index.ts, doc-cache-gate.ts, cache-doc.ts (+ dispatch-aipilot.ts to propagate id). Verified: tsc --noEmit clean, 1106/1107 tests pass (1 skip), 660-line before/after characterization (15 harness ids x 44 tools) shows 12 lines changed, all id:"codex", zero regression outside Codex. Confirmed live on Codex 0.147: a real design-expert subagent session now reaches screenshotsCount:5 and completes the identity phase. Claude-Session: https://claude.ai/code/session_01VV766SFwq62DoXAkFs4Xbc
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
-to_on the qualified MCP tool identifier before it reaches any hook (sanitize_responses_api_tool_name(), Normalize MCP tool names to code-mode safe form openai/codex#14605). This harness compared against the hyphenated form everywhere, so on Codex only: the design gate'sSHOT_TOOLS.has()always missed (stuck at phase 1),classifyExplorenever creditedresearch-expert(APEX freshness gate), and the doc-cache gate never fired.canonicalizeMcpToolName(id, tool)(src/runtime/mcp-tool-name.ts) — pure function,id !== "codex"short-circuits first, two closed null-prototype tables (Object.create(null)), server-scopedTOOL_ALIASESto avoid corrupting segments that already contain a legitimate underscore. Wired into 5 ingestion paths:normalize.ts,adapters/codex/index.ts,doc-cache-gate.ts,cache-doc.ts(+dispatch-aipilot.tsto propagateid).0.1.89->0.1.90, CHANGELOG updated.Test plan
bunx tsc --noEmit— exit 0bun test— 1106 pass / 1 skip / 0 fail, 196 filesbun run build— exit 0, 97 files (validated pre-commit by the implementing session)id: "codex", zero regression outside Codexdesign-expertsubagent session reachesscreenshotsCount: 5, phase 1, identity phase completedhttps://claude.ai/code/session_01VV766SFwq62DoXAkFs4Xbc