From c3b0b7fca0f2ecfb7d3692040611b55b18ca3218 Mon Sep 17 00:00:00 2001 From: S2D2 Date: Wed, 11 Nov 2026 09:55:14 +0000 Subject: [PATCH 1/3] fix(tools): warn about duplicate tool names once, at fetch fetchTools() already warns when two accounts serve the same tool name. Every adapter (toOpenAI, toAISDK, toLangChain, toClaudeAgentSdk and the rest) repeated the same warning each time it dropped the duplicate, so a caller that converts one collection several times saw the line again and again. The adapters still keep the first tool per name; they just stop repeating the warning. Matches sdk-conformance openai-adapter-duplicate-names, which now expects toOpenAI to add no warning, and syncs tests/vectors to that branch. Co-Authored-By: Claude Opus 5.5 Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com> --- src/tool.ts | 6 ++---- src/toolsets.test.ts | 5 ++--- tests/vectors/messages.json | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/tool.ts b/src/tool.ts index 868c2916..43fc7398 100644 --- a/src/tool.ts +++ b/src/tool.ts @@ -705,7 +705,6 @@ export class Tools implements Iterable { * Claude Agent SDK refuses the second outright. */ #uniqueTools(): BaseTool[] { - warnOnDuplicateNames(this.tools); const seen = new Set(); return this.tools.filter((tool) => { if (seen.has(tool.name)) { @@ -951,9 +950,8 @@ export class Tools implements Iterable { /** * Two accounts on one provider serve identically named tools. Every lookup and adapter keeps the - * first one listed — the lowest account id — and drops the rest, so warn that the others are - * unreachable by name: once when the tools are fetched, and again from each adapter that drops - * them. + * first one listed (the lowest account id) and drops the rest, so warn once, when the tools are + * fetched, that the others are unreachable by name. */ export function warnOnDuplicateNames(tools: readonly BaseTool[]): void { const counts = new Map(); diff --git a/src/toolsets.test.ts b/src/toolsets.test.ts index 61bc1d96..d4d26adc 100644 --- a/src/toolsets.test.ts +++ b/src/toolsets.test.ts @@ -1099,9 +1099,8 @@ describe('duplicate tool names', () => { expect(Object.keys(aiSdk)).toEqual(expected); expect(aiSdk.hibob_list_employees?.description).toBe('on a'); await expect(tools.toClaudeAgentSdk()).resolves.toBeDefined(); - // Once from fetchTools(), then once from each adapter call that dropped a duplicate. - expect(warnSpy).toHaveBeenCalledTimes(8); - expect(new Set(warnSpy.mock.calls.map(([message]: unknown[]) => message)).size).toBe(1); + // Once from fetchTools(); the adapters drop the duplicate without repeating it. + expect(warnSpy).toHaveBeenCalledTimes(1); }); it('stays quiet when names are unique', async () => { diff --git a/tests/vectors/messages.json b/tests/vectors/messages.json index b5a1d477..f74d00f5 100644 --- a/tests/vectors/messages.json +++ b/tests/vectors/messages.json @@ -190,7 +190,7 @@ "python": true, "node": true }, - "notes": "Language-neutral wording: neither SDK's method or parameter names. Emitted once when a fetched collection holds a clashing name, and again by every adapter that keeps the first tool per name and drops the rest: OpenAI, LangChain, Pydantic AI, AI SDK and Claude Agent SDK. Listing order is ascending account id, so the first is the lowest account id's." + "notes": "Language-neutral wording: neither SDK's method or parameter names. Emitted once, when a fetched collection holds a clashing name. The adapters that keep the first tool per name and drop the rest (OpenAI, LangChain, Pydantic AI, AI SDK and Claude Agent SDK) do not repeat it. Listing order is ascending account id, so the first is the lowest account id's." }, { "id": "mcp-timeout", From 8c7af617a4c62c0eedccda4fea1254b77de10e8e Mon Sep 17 00:00:00 2001 From: S2D2 Date: Wed, 11 Nov 2026 10:00:18 +0000 Subject: [PATCH 2/3] fix(tools): warn about duplicate names when a Tools collection is built Moving the warning out of the adapters left fetchTools() as its only source, so a collection built by hand, for example two separately fetched collections merged with new Tools([...a, ...b]), dropped the duplicate from every adapter without a warning. The Tools constructor now warns, as the Python SDK's does, and fetchTools() relies on it. Co-Authored-By: Claude Opus 5.5 Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com> --- src/tool.ts | 7 ++++--- src/toolsets.test.ts | 15 ++++++++++++++- src/toolsets.ts | 3 +-- tests/vectors/messages.json | 2 +- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/tool.ts b/src/tool.ts index 43fc7398..322f5096 100644 --- a/src/tool.ts +++ b/src/tool.ts @@ -682,6 +682,7 @@ export class Tools implements Iterable { constructor(tools: BaseTool[]) { this.tools = [...tools]; + warnOnDuplicateNames(this.tools); } /** @@ -950,10 +951,10 @@ export class Tools implements Iterable { /** * Two accounts on one provider serve identically named tools. Every lookup and adapter keeps the - * first one listed (the lowest account id) and drops the rest, so warn once, when the tools are - * fetched, that the others are unreachable by name. + * first one listed and drops the rest, so warn once, when the collection is built, that the others + * are unreachable by name. */ -export function warnOnDuplicateNames(tools: readonly BaseTool[]): void { +function warnOnDuplicateNames(tools: readonly BaseTool[]): void { const counts = new Map(); for (const tool of tools) { counts.set(tool.name, (counts.get(tool.name) ?? 0) + 1); diff --git a/src/toolsets.test.ts b/src/toolsets.test.ts index d4d26adc..9d271d1a 100644 --- a/src/toolsets.test.ts +++ b/src/toolsets.test.ts @@ -14,7 +14,7 @@ import { server } from '../mocks/node'; import { FAILED_ACCOUNT_RETRY_MS } from './consts'; import { listMcpTools } from './mcp-client'; import type { McpToolDefinition as ListedTool } from './mcp-client'; -import { StackOneMcpTool, StackOneTool } from './tool'; +import { StackOneMcpTool, StackOneTool, Tools } from './tool'; import type { BaseTool } from './tool'; import { StackOneToolSet } from './toolsets'; import { StackOneAPIError } from './utils/error-stackone-api'; @@ -1103,6 +1103,19 @@ describe('duplicate tool names', () => { expect(warnSpy).toHaveBeenCalledTimes(1); }); + it('warns when collections fetched separately are merged into one', async () => { + fakeListing(() => [def('hibob_list_employees')]); + const toolset = newToolSet(); + const a = await toolset.fetchTools({ accountIds: ['a'] }); + const b = await toolset.fetchTools({ accountIds: ['b'] }); + expect(warnSpy).not.toHaveBeenCalled(); + + const merged = new Tools([...a, ...b]); + merged.toOpenAI(); + + expect(warnSpy).toHaveBeenCalledTimes(1); + }); + it('stays quiet when names are unique', async () => { await newToolSet().fetchTools({ accountIds: ['acc1', 'acc2'] }); expect(warnSpy).not.toHaveBeenCalled(); diff --git a/src/toolsets.ts b/src/toolsets.ts index 2e226cc3..a40cbcbd 100644 --- a/src/toolsets.ts +++ b/src/toolsets.ts @@ -23,7 +23,7 @@ import { } from './mcp-client'; import type { EndUserSource, McpToolDefinition } from './mcp-client'; import { cloneJson, toolParametersFromInputSchema } from './schema'; -import { StackOneMcpTool, Tools, warnOnDuplicateNames } from './tool'; +import { StackOneMcpTool, Tools } from './tool'; import type { StackOneTool } from './tool'; import type { ActionResult, @@ -1177,7 +1177,6 @@ export class StackOneToolSet { isAskedFor(tool.name, mode === 'search_execute' ? { actions: options.actions } : options), ); - warnOnDuplicateNames(tools); return new Tools(tools); } catch (error) { // StackOneAPIError carries the HTTP status. Re-wrapping it would throw that away, so a diff --git a/tests/vectors/messages.json b/tests/vectors/messages.json index f74d00f5..7a33528b 100644 --- a/tests/vectors/messages.json +++ b/tests/vectors/messages.json @@ -190,7 +190,7 @@ "python": true, "node": true }, - "notes": "Language-neutral wording: neither SDK's method or parameter names. Emitted once, when a fetched collection holds a clashing name. The adapters that keep the first tool per name and drop the rest (OpenAI, LangChain, Pydantic AI, AI SDK and Claude Agent SDK) do not repeat it. Listing order is ascending account id, so the first is the lowest account id's." + "notes": "Language-neutral wording: neither SDK's method or parameter names. Emitted once, when a tool collection holding a clashing name is built: by listing, or by the caller combining collections. The adapters that keep the first tool per name and drop the rest (OpenAI, LangChain, Pydantic AI, AI SDK and Claude Agent SDK) do not repeat it. Listing order is ascending account id, so the first is the lowest account id's." }, { "id": "mcp-timeout", From 8e2183ffd4c8ea745813961b29f6ca84389384f7 Mon Sep 17 00:00:00 2001 From: S2D2 Date: Wed, 11 Nov 2026 09:57:38 +0000 Subject: [PATCH 3/3] ci(conformance): grade against the warn-once conformance and Python changes Pins sdk-conformance to the commit that expects adapters not to repeat the duplicate-tool-names warning, and the Python SDK to its matching change. Re-pin both to their main commits once those PRs merge. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f15e94dc..1ad14ede 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -146,7 +146,7 @@ jobs: env: # Pinned to a commit on stackone-ai-python's main, not the branch, so a Python change never # silently changes what this job grades. Bump it deliberately. - PYTHON_SDK_REF: d76c26663c9141bf106a19d385252da9a8c7e75d + PYTHON_SDK_REF: 05398a3f1e119297beb7e514f92c17601a75583e steps: - name: Check conformance token is configured env: @@ -166,7 +166,7 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: repository: StackOneHQ/sdk-conformance - ref: 4ead1c25bb443ef1fd1986d5f053b2d1475d0e90 + ref: 6aba490ee49b298643e3a0bb9fbbaecf36c0edd7 token: ${{ secrets.CONFORMANCE_REPO_TOKEN }} path: sdk-conformance persist-credentials: false