Skip to content

fix(vertexai): record every function_response part of a content, not just the last - #3812

Open
Harsh23Kashyap wants to merge 3 commits into
Arize-ai:mainfrom
Harsh23Kashyap:fix/vertexai-multi-function-response
Open

Harsh23Kashyap wants to merge 3 commits into
Arize-ai:mainfrom
Harsh23Kashyap:fix/vertexai-multi-function-response

Conversation

@Harsh23Kashyap

Copy link
Copy Markdown

Fixes #3811

When one input content carries several function_response parts (the reply to parallel function calls), the vertexai instrumentor keeps only the last part. Every part writes message.role, message.name, and message.content at 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_response part as its own input message with message.role = "tool", message.name, and message.content, placed right after the content that carries it:

  • A content holding only function_response parts no longer emits an empty wrapper message. Its span attributes land at the same index as before, so single-part requests are unchanged.
  • A mixed content keeps its real role and its other parts; each function_response follows as its own tool message.

This is the same fix shape as #3810 (anthropic), per spec/tool_calling.md.

Test plan:

  • New regression test test_instrumentor_multiple_function_responses in 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.

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

Status: No status

Development

Successfully merging this pull request may close these issues.

[bug] vertexai: a content with several function_response parts records only the last one

1 participant