Skip to content

fix(translation): rewrite colliding anthropic tool-call ids (#502) - #868

Open
jsvisa wants to merge 2 commits into
NVIDIA-NeMo:mainfrom
jsvisa:fix/issue-502-unique-tool-call-ids
Open

jsvisa wants to merge 2 commits into
NVIDIA-NeMo:mainfrom
jsvisa:fix/issue-502-unique-tool-call-ids

Conversation

@jsvisa

@jsvisa jsvisa commented Sep 29, 2026

Copy link
Copy Markdown

A backend that reuses OpenAI tool-call ids across responses (e.g. Grok emitting call_0, call_1, call_0) made Switchyard translate that conversation to Anthropic with duplicate tool_use ids. Anthropic returns 400 "tool_use ids must be unique", and clients pair results to calls by id, so agent loops never terminated.

Translation now treats id uniqueness as an Anthropic-facing invariant: first-seen ids pass through unchanged; a repeat mints sydup2_call_0-style ids (distinct from the sy64_ scheme, original readable after stripping the prefix). The Anthropic request decoder records the ids a conversation already used in request extensions, and both buffered and streaming response encoders seed from that — no new cross-request state. Every tool_result is rewritten to match its own call.

Verified: new buffered/streaming/extension tests fail before the fix and pass after; full translation suite (231 tests), cargo fmt --all --check and cargo clippy --workspace --all-targets -- -D warnings clean.

Fixes #502

@jsvisa
jsvisa requested a review from a team as a code owner September 29, 2026 11:31

This branch has not been deployed

No deployments
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.

[bug] Reused OpenAI tool-call IDs break multi-turn Anthropic tool workflows

1 participant