Skip to content

fix(llm): distinguish duplicate tool call IDs within a response - #41

Open
samirhvbr wants to merge 2 commits into
masterfrom
feat/backport-same-turn-tool-call-ids
Open

samirhvbr wants to merge 2 commits into
masterfrom
feat/backport-same-turn-tool-call-ids

Conversation

@samirhvbr

Copy link
Copy Markdown
Owner

Two tool calls in one model response can share a nonblank call_id. The current rewriter maps by that original ID, so it gives both calls the same replacement. This can lose call/result pairs in the SDK's conversation history and make the per-turn limiter count multiple calls as one.

Backport of usestrix#1615 to fork master at 8aa0791e, addressing usestrix#1611. The rewriter now identifies calls by real response item ID, or by output position for Chat Completions, and keeps that mapping stable across added/done/completed sightings.

The fork's UNNAMED_TOOL normalization is preserved. The regression matrix additionally combines duplicate IDs with blank function names, checks that both names are normalized, and verifies the original calls are not mutated. Existing blank-name tests remain intact. FORK.md tracks the backport.

Validation with Python 3.12.14, the fork's frozen lockfile, isolated HOME and environment:

  • 15 regression cases fail against the unchanged fork implementation.
  • pytest -q tests/test_tool_call_ids.py tests/test_tool_call_ids_providers.py tests/test_tool_call_limits.py: 464 passed, 3 xfailed, with 125 dependency warnings.
  • Coverage includes repeated stream events, historical collisions, output positions, limiter accounting, blank names and loopback HTTP provider routes.
  • Full Ruff lint/format, Mypy (174 source files), Bandit and git diff --check passed.
  • Pyright: 1,255 errors versus 1,259 on the base; no new diagnostic signatures after normalizing line positions.

The three expected failures are the existing SDK null-ID conversion cases. Provider routes were simulated locally; no real provider requests or full scans were performed. The complete repository suite was not run. Version stamping and release remain part of the fork's merge/delivery procedure.

GitHub Actions is currently unavailable for this account due to a billing lock (confirmed on the other backport PR runs). Remote CI is therefore not established.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant