Skip to content

fix(vertexai): record tool definitions as llm.tools - #4463

Open
abhishekacharya200 wants to merge 1 commit into
Arize-ai:mainfrom
abhishekacharya200:fix/vertexai-tools
Open

abhishekacharya200 wants to merge 1 commit into
Arize-ai:mainfrom
abhishekacharya200:fix/vertexai-tools

Conversation

@abhishekacharya200

Copy link
Copy Markdown

Fixes #4450

The vertexai instrumentor now records the tools passed in a GenerateContentRequest as llm.tools.N.tool.json_schema.

Before this change _update_span never looked at req.tools, so a span for a request with function declarations had no llm.tools attributes. The tool schemas were only visible inside the raw input.value JSON. The google-genai instrumentor already records them, and this does the same for vertexai.

Changes:

  • _wrapper.py: new _get_tool_attributes yields one llm.tools.N.tool.json_schema per function declaration, as {name, description, parameters} like the google-genai instrumentor. A tool with no function declarations (for example google_search) is recorded whole. This works for both the v1 and v1beta1 request types. The existing hide_inputs / hide_llm_tools config already hides these attributes.
  • Tests: the existing test_gapic_client.py span tests assert that every attribute is accounted for, so with this change they check the get_current_weather schema from the tool fixture. Added a test with two Tools to check the numbering across tools.

Without the source change the 34 affected tests fail (the schema attribute is missing); with it the vertexai test suite passes, apart from test_entrypoint_for_opentelemetry_instrument, which fails the same way on main in my environment.

@github-actions

Copy link
Copy Markdown
Contributor

CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request

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 instrumentation does not record request tools as llm.tools

1 participant