Align GenAI message dataclasses with semconv message schemas#284
Open
lmolkova wants to merge 2 commits into
Open
Align GenAI message dataclasses with semconv message schemas#284lmolkova wants to merge 2 commits into
lmolkova wants to merge 2 commits into
Conversation
Add `name` to InputMessage/OutputMessage, add Compaction, SystemInstructionPart, MemoryRecord, and RetrievalDocument, extend Modality with `document`, and update FinishReason to the schema enum (`tool_calls` -> `tool_call`, add `compaction`). Message and tool-definition serialization now omits None-valued fields (new `asdict_without_none` helper) to match the semconv JSON schemas, on the span, event, and upload-hook paths.
Contributor
There was a problem hiding this comment.
Pull request overview
Aligns opentelemetry-util-genai message/tool dataclasses and their JSON serialization with the GenAI semantic-conventions message schemas (notably: omit unset optional fields instead of emitting JSON null), and updates Google GenAI instrumentation tests to match.
Changes:
- Added/updated message schema dataclasses and enums in
opentelemetry-util-genai(e.g.,nameon messages,Compaction, updatedFinishReason, extendedModality). - Introduced
asdict_without_noneand switched message/tool serialization paths to omitNonefields for schema parity. - Updated Google GenAI instrumentation parsing and tests for the new
GenericPartshape and tool-definition JSON output.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| util/opentelemetry-util-genai/tests/test_upload.py | Updates expected uploaded tool-definition JSON to omit parameters: null. |
| util/opentelemetry-util-genai/src/opentelemetry/util/genai/utils.py | Adds asdict_without_none helper for schema-aligned dataclass serialization. |
| util/opentelemetry-util-genai/src/opentelemetry/util/genai/types.py | Updates/extends semconv-aligned message/tool dataclasses and literals. |
| util/opentelemetry-util-genai/src/opentelemetry/util/genai/_upload/completion_hook.py | Uses asdict_without_none for tool/message serialization in upload paths. |
| util/opentelemetry-util-genai/src/opentelemetry/util/genai/_invocation.py | Uses asdict_without_none for span/event content attributes. |
| util/opentelemetry-util-genai/.changelog/+message-schema-parity.changed | Adds a changelog fragment (but filename currently violates CI naming rules). |
| instrumentation/opentelemetry-instrumentation-google-genai/tests/interactions/test_parser.py | Asserts GenericPart.type is preserved in the generic fallback. |
| instrumentation/opentelemetry-instrumentation-google-genai/tests/interactions/base.py | Updates expected tool-definition JSON to omit parameters: null. |
| instrumentation/opentelemetry-instrumentation-google-genai/tests/generate_content/nonstreaming_base.py | Updates expected tool-definition JSON fixtures to omit parameters: None/null. |
| instrumentation/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/interactions.py | Populates GenericPart(type=..., value=...) for unsupported parts. |
- Rename changelog fragment to PR number - Default Compaction.id/content to None (optional and omitted) - Bridge google-genai oldest env to workspace util-genai (needs 1.1b0 None-omitting serialization) Assisted-by: Claude Opus 4.8 (1M context)
lmolkova
force-pushed
the
genai-message-schema-parity
branch
from
July 18, 2026 05:20
5e83670 to
ac13891
Compare
Pull request dashboard status
|
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.
Add
nameto InputMessage/OutputMessage, add Compaction, SystemInstructionPart, MemoryRecord, and RetrievalDocument, extend Modality withdocument, and update FinishReason to the schema enum (tool_calls->tool_call, addcompaction).Message and tool-definition serialization now omits None-valued fields (new
asdict_without_nonehelper) to match the semconv JSON schemas, on the span, event, and upload-hook paths.