fix(tools): warn about duplicate tool names once, when a collection is built
The duplicate-tool-names warning is now logged once, when Tools is built. Before, _first_per_name repeated it on every adapter call that dropped the duplicate: to_openai, to_langchain and to_pydantic_ai. A caller that converts one collection more than once saw the same line each time. The adapters still keep the first tool per name, the one get_tool returns. Only the repeat goes.
Changes
stackone_ai/tools.py:_first_per_nameno longer calls_warn_duplicate_names.__init__already does, so every collection, including one a caller merges from separate fetches, still warns once.tests/test_multi_account.py: newtest_construction_warns_once, plustest_merging_collections_warns_oncefor a caller-merged collection. The adapter tests now assert that the adapters log nothing.tests/test_shared_vectors.pyandtests/vectors: synced from sdk-conformance branchs2d2/warn-duplicate-names-once. That branch changes theopenai-adapter-duplicate-namesscenario to expect no warning fromto_openai. The message text is unchanged.
#262 changed the _warn_duplicate_names docstring to "on every call". A commit on that branch puts the original "Warn once" back, so the two PRs agree.
CI and merge order
The conformance job pins sdk-conformance and the Node SDK by commit. The last commit on this branch points those pins at the sdk-conformance change (6aba490) and the matching Node branch (8c7af61), so CI grades this branch against the new scenario. Those are PR heads, not main commits.
Order: merge the sdk-conformance change, then this PR and the matching Node PR. Once all three are in, re-pin both SDKs to the main commits.
How it was verified
| Check | Result |
|---|---|
uv run pytest | 873 passed |
ruff check, ruff format --check, ty check stackone_ai examples | clean |
| sdk-conformance full suite with this branch and the matching Node build | RESULT: PASS (openai-adapter-duplicate-names 11 checks each) |
Gates
The gates ran on 05398a3, the last code commit. 9bb35ff changes only the two pins in .github/workflows/ci.yaml.
| Gate | Result |
|---|---|
| /forge:forge | meter on all three branches: 0 findings, 0 copies, longest added comment 2 lines; one dash in a doc comment this change touched was removed |
| Security scan + Aikido | no dependency or manifest change, so the dependency reviewer does not apply. Aikido open issues in all three repos sit in lockfiles, workflows and unrelated scripts, none on a file this change touches |
| Codex security | first pass (all three branches): one finding. Node collections built by hand, e.g. two fetches merged with new Tools([...a, ...b]), dropped duplicates with no warning at all. Fixed by warning in the Tools constructor (Node 8c7af61), with conformance wording to match (6aba490). Re-check on 8c7af61: 2 P2s, both declined. filter() warns again when duplicates survive: it builds a new collection, every new Python Tools warns the same way, and the contract defines the warning per built collection. Changing a tool's name after construction bypasses the check, but that predates this change. A third P2 is left as a follow-up: the warning text says the lowest account id is used, which is wrong for a collection a caller merged in another order. That text is a shared vector both SDKs emit, so changing it needs its own conformance change |
| /security-review | only log calls move; no secret, header or account id is newly logged, and the warning text is unchanged |
| /code-review | Reviewer agent: one test gap fixed (Python now has the merged-collection test, 05398a3). Two items declined: the Node vector note was already synced, and the dashes flagged are in lines this change did not add |
| CI | 9bb35ff: every job passes, conformance included |
| Unresolved review threads | 0 |
Requested by guillaume@stackone.com in Slack (repo audit thread).
š¤ Generated with Claude Code