fix(vertexai): record every function_response part of a content, not just the last - #3812
Open
Harsh23Kashyap wants to merge 3 commits into
Open
Harsh23Kashyap wants to merge 3 commits into
Harsh23Kashyap wants to merge 3 commits into
Conversation
This was referenced Sep 22, 2026
This branch has not been deployed
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.
Fixes #3811
When one input content carries several
function_responseparts (the reply to parallel function calls), the vertexai instrumentor keeps only the last part. Every part writesmessage.role,message.name, andmessage.contentat the same message index, so later parts overwrite earlier ones. The code carried a FIXME about retaining only one. A mixed content (text +function_response) had a second symptom: its role was overwritten to "tool".This change records each
function_responsepart as its own input message withmessage.role = "tool",message.name, andmessage.content, placed right after the content that carries it:function_responseparts no longer emits an empty wrapper message. Its span attributes land at the same index as before, so single-part requests are unchanged.function_responsefollows as its own tool message.This is the same fix shape as #3810 (anthropic), per spec/tool_calling.md.
Test plan:
test_instrumentor_multiple_function_responsesin tests/test_gapic_client.py covers a two-part content and a mixed content; it fails on main and passes with this change.pytest tests/in python/instrumentation/openinference-instrumentation-vertexai - 151 passed, including the existing single-function_response assertions, which are unchanged.