Repository navigation
fix(openai): use call_id as the Responses tool call id - #4632
Open
pcbeingused333 wants to merge 2 commits into
Open
pcbeingused333 wants to merge 2 commits into
pcbeingused333 wants to merge 2 commits into
Conversation
Responses function_call items have an item id (fc_...) and a call_id (call_...). The function_call_output sent back to the model refers to the call by call_id, and the instrumentation already records that as the tool_call_response id, but the tool call itself was recorded with the item id in gen_ai.output.messages, and with the item id first in gen_ai.input.messages. The ids of a tool call and its response never matched. Use call_id for the tool call id, falling back to the item id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A Responses API
function_callhas two ids: the itemid(fc_...) and thecall_id(call_...). Thefunction_call_outputsent back to the model refers to the call bycall_id, and the instrumentation already recordscall_idas thetool_call_responsepart id. But the tool call part itself was recorded with the item id:gen_ai.output.messages:"id": block_dict.get("id"), so alwaysfc_....gen_ai.input.messages:"id": block_dict.get("id") or block_dict.get("call_id"), sofc_...whenever the replayed item keeps its id (it does when you passresponse.outputback).So a tool call and its response never had matching ids. In the GenAI semantic conventions they're meant to carry the same tool call id, so traces can't pair them.
Change
responses_wrappers.pynow usescall_idfor the tool call part id on both sides, falling back to the item id whencall_idis absent.Tests
test_responses_tool_callsnow also checks the output tool call ids against the existing cassette's realcall_ids (call_tYDv1b…,call_lC079U…; the items arefc_685ff894…). It fails on main and passes with the change.test_responses_input_tool_call_id_matches_tool_call_response: a follow-up turn whose input has thefunction_callitem (with both ids) and itsfunction_call_output. The tool call and tool call response ids must match. It fails on main and passes with the change.packages/opentelemetry-instrumentation-openaitests: 297 passed, 1 skipped. 2 failures intest_responses_with_raw_response_streaming_does_not_crash(sync/async) are atyping.Union/__discriminator__error from openai 1.99.7 in this local environment and fail the same way on main.ruff checkclean.Also seen on a real streamed Responses call to gpt-oss on Bedrock's OpenAI-compatible endpoint: the function call item has
id: fc_a723…andcall_id: call_95e0…, so the same mismatch.This PR was made with Claude Code (Anthropic); the tests above were run on main and on this branch.
🤖 Generated with Claude Code
Summary by CodeRabbit