Skip to content

fix(core): preserve admitted tool names - #41201

Open
kitlangton wants to merge 1 commit into
v2from
canonical-tool-names
Open

fix(core): preserve admitted tool names#41201
kitlangton wants to merge 1 commit into
v2from
canonical-tool-names

Conversation

@kitlangton

@kitlangton kitlangton commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

What

Keep provider-advertised direct tool names identical to the canonical names admitted by the tool registry.

Before / After

Before: src/tool.ts normalized and validated a registration such as namespace slack.admin plus tool name send.message, then stored it under slack_admin_send_message. tool/runtime.ts independently recomputed the provider definition name from the producer object. If that object changed after registration, the provider could receive a name the registry lookup never admitted, so executing the advertised call returned Unknown tool.

After: provider definitions receive the already-admitted registry key. Advertisement, permission fallback, registration storage, and execution lookup now use the same canonical identity even if the producer object's name changes after registration.

flowchart LR
  subgraph before["Before: duplicated recomputation"]
    B0["Producer tool object"] --> B1["Registry normalizes and admits"]
    B0 --> B2["Runtime recomputes name"]
    B1 --> B3["Execution lookup key"]
    B2 --> B4["Provider definition name"]
    B4 -. "may not match" .-> B3
  end

  subgraph after["After: one admitted identity"]
    A0["Producer tool object"] --> A1["Registry normalizes and admits"]
    A1 --> A2["Admitted registry key"]
    A2 --> A3["Provider definition name"]
    A2 --> A4["Execution lookup key"]
  end
Loading

How

  • packages/core/src/tool/runtime.ts makes definition accept its canonical name explicitly and removes its duplicate normalization implementation.
  • packages/core/src/tool.ts passes direct registration map keys into definition derivation and uses the canonical synthetic name execute for CodeMode.
  • packages/core/src/codemode/tool.ts passes each existing admitted registration key while deriving child schemas; CodeMode still owns its separate catalog path representation.
  • packages/core/test/tool-schema.test.ts updates direct definition call sites for the explicit identity.
  • packages/core/test/session-runner-tool-registry.test.ts proves a namespaced, normalized tool advertises and executes through its admitted lookup key after the producer object's name is mutated.

Passing the admitted identity is preferable to sharing a normalization helper because a shared helper would still rederive identity from a producer object after validation. The registration key is already the authoritative result of normalization, collision validation, permission fallback, and map admission, so passing it removes both drift and a second derivation point without reversing the registry/runtime dependency direction.

Scope

  • Does not change normalization or namespace rules.
  • Does not change CodeMode catalog paths or tool execution behavior.
  • Does not add registration cloning or immutability enforcement.
  • Does not change Protocol or Server HTTP APIs.

Production change: 5 insertions, 12 deletions (-7 net) across packages/core/src.

Testing

  • cd packages/core && bun run test test/tool-schema.test.ts test/session-runner-tool-registry.test.ts test/codemode.test.ts (31 passed)
  • cd packages/core && bun typecheck
  • Push hook: bun turbo typecheck --concurrency=3 (33/33 tasks successful)
  • bun run lint packages/core/src/tool.ts packages/core/src/tool/runtime.ts packages/core/src/codemode/tool.ts packages/core/test/tool-schema.test.ts packages/core/test/session-runner-tool-registry.test.ts (0 errors; 17 warnings on pre-existing lines)
  • git diff --check
  • Scoped Prettier was run on the five changed files. Its whole-file rewrites on four already-unformatted files were reverted to avoid unrelated churn; bunx prettier --check ... continues to report that pre-existing formatting drift.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant