Skip to content

Conversation

@DylanRussell
Copy link
Contributor

Description

Add some sem conv attributes to the stable vertex AI and gen AI instrumentations that were missing.

Fix a bug in how system instructions were recorded in the gen ai system event in the stable gen AI instrumentation.

Fixes #3934 and #3979

Type of change

Please delete options that are not relevant.

  • [ x] Bug fix (non-breaking change which fixes an issue)
  • [x ] New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Unit tests

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • [x ] No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • [ x] Followed the style guidelines of this project
  • [x ] Changelogs have been updated
  • Unit tests have been added
  • [x ] Documentation has been updated

Comment on lines +515 to +520
if not content.parts:
return
# System instruction is required to be text. An error will be returned by the API if it isn't.
system_instruction = " ".join(
part.text for part in content.parts if part.text
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just model_dump the full provided system instructions Content object without converting into a string? It's true it should be text, but a user might pass non-text and need to debug.

Copy link
Contributor Author

@DylanRussell DylanRussell Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we use model_dump the output is nested and kind of ugly, also it'll look weird if the user just passed a string or a list of strings to system_instructions (which the gen AI SDK lets people do). The error will get surfaced to the user in the error.type attribute I believe, and also all their calls will be failing so I think they will be able to figure it out without this.

As an aside I'd like to add exclude_unset=True to the existing model_dumps that we do so we aren't dumping a long list of unset fields into the telemetry..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I'm tempted to just do that in this PR... Are you on board with that ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we use model_dump the output is nested and kind of ugly, also it'll look weird if the user just passed a string or a list of strings to system_instructions (which the gen AI SDK lets people do).

I think they will have the opposite problem with the PR's current code, if they pass Parts right now it will get converted to a joined string. It's true the error gets should surface but imo it's confusing if the error conflicts with the captured params. It's up to you on this one, I think it's minutiae either way.

As an aside I'd like to add exclude_unset=True to the existing model_dumps that we do so we aren't dumping a long list of unset fields into the telemetry..

SGTM

@aabmass aabmass enabled auto-merge (squash) December 5, 2025 21:44
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.

Update Google GenAI and vertex AI non-experimental instrumentations with sem convs from 1.30->1.35

7 participants