diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 67bb203..0d2ef1f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -114,7 +114,7 @@ jobs: env: # Pinned to a commit on stackone-ai-node's main, not the branch, so a Node change never # silently changes what this job grades. Bump it deliberately. - NODE_SDK_REF: 099fd1e3405f8a56125f9691e20ccd1333dda12f + NODE_SDK_REF: 8c7af617a4c62c0eedccda4fea1254b77de10e8e steps: - name: Check conformance token is configured env: @@ -134,7 +134,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 diff --git a/stackone_ai/tools.py b/stackone_ai/tools.py index 486b6aa..acdce1d 100644 --- a/stackone_ai/tools.py +++ b/stackone_ai/tools.py @@ -1674,7 +1674,6 @@ def _first_per_name(self) -> list[StackOneTool]: name would not find. OpenAI was sent two functions of one name, and LangChain and Pydantic AI each kept whichever their own lookup happened to find. """ - self._warn_duplicate_names() return list(self._tool_map.values()) def __getitem__(self, index: int) -> StackOneTool: diff --git a/tests/test_multi_account.py b/tests/test_multi_account.py index 3f27c2d..31e423f 100644 --- a/tests/test_multi_account.py +++ b/tests/test_multi_account.py @@ -663,7 +663,7 @@ def test_a_case_or_space_variant_of_an_sdk_owned_header_is_dropped(self): def _duplicated() -> Tools: - """hris_list on acc1 and acc2. Constructing it warns, so a test clears caplog after.""" + """hris_list on acc1 and acc2. Constructing it warns once; the adapters do not repeat it.""" def tool(name: str, account: str) -> StackOneMcpTool: return StackOneMcpTool( @@ -684,6 +684,20 @@ class TestAdaptersKeepTheFirstOfEachName: "from the lowest account id, is used — pass account ids to choose." ) + def test_construction_warns_once(self, caplog): + with caplog.at_level(logging.WARNING, logger="stackone.tools"): + _duplicated() + assert [r.getMessage() for r in caplog.records] == [self.DUPLICATE_WARNING] + + def test_merging_collections_warns_once(self, caplog): + tools = _duplicated() + first = Tools([t for t in tools if t.get_account_id() == "acc1"]) + second = Tools([t for t in tools if t.get_account_id() == "acc2"]) + caplog.clear() + with caplog.at_level(logging.WARNING, logger="stackone.tools"): + Tools([*first, *second]).to_openai() + assert [r.getMessage() for r in caplog.records] == [self.DUPLICATE_WARNING] + def test_openai(self, caplog): tools = _duplicated() caplog.clear() @@ -693,7 +707,7 @@ def test_openai(self, caplog): ("hris_list", "on acc1"), ("other", "on acc1"), ] - assert [r.getMessage() for r in caplog.records] == [self.DUPLICATE_WARNING] + assert caplog.records == [] def test_langchain(self, caplog): tools = _duplicated() @@ -704,7 +718,7 @@ def test_langchain(self, caplog): ("hris_list", "on acc1"), ("other", "on acc1"), ] - assert [r.getMessage() for r in caplog.records] == [self.DUPLICATE_WARNING] + assert caplog.records == [] def test_pydantic_ai(self, caplog): tools = _duplicated() @@ -715,7 +729,7 @@ def test_pydantic_ai(self, caplog): ("hris_list", "on acc1"), ("other", "on acc1"), ] - assert [r.getMessage() for r in caplog.records] == [self.DUPLICATE_WARNING] + assert caplog.records == [] def test_no_warning_without_a_clash(self, caplog): unique = _duplicated().tools[:2] diff --git a/tests/test_shared_vectors.py b/tests/test_shared_vectors.py index 1ac2dad..bddc5c7 100644 --- a/tests/test_shared_vectors.py +++ b/tests/test_shared_vectors.py @@ -464,11 +464,10 @@ def _skip_account(mp, log) -> Emitted: def _duplicate_tool_names(mp, log) -> Emitted: tools = Tools([_served_tool({"type": "object", "properties": {}}, "t") for _ in range(2)]) - # Once by the collection, and again by each adapter that keeps the first of each name. + # Once by the collection; the adapter drops the duplicate without repeating it. tools.to_openai() - collection, adapter = _warnings(log) - assert collection == adapter - return adapter, {"count": 1, "names": "t"} + (warning,) = _warnings(log) + return warning, {"count": 1, "names": "t"} def _account_id_env_ignored(mp, log) -> Emitted: diff --git a/tests/vectors/messages.json b/tests/vectors/messages.json index b5a1d47..7a33528 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 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",