Skip to content

Update message format to align with OTel spec completely#253

Merged
nikhilNava merged 2 commits into
mainfrom
nikhilc/updateMessageFormat
May 20, 2026
Merged

Update message format to align with OTel spec completely#253
nikhilNava merged 2 commits into
mainfrom
nikhilc/updateMessageFormat

Conversation

@nikhilNava
Copy link
Copy Markdown
Contributor

@nikhilNava nikhilNava commented May 20, 2026

Updates message format types and wrappers to fully align with the OpenTelemetry specification.

 Before (versioned envelope):
 {
   "version": "0.1.0",
   "messages": [
     {
       "role": "user",
       "parts": [{ "type": "text", "content": "Hello" }]
     }
   ]
 }

After (plain array per OTel spec):

 [
   {
     "role": "user",
     "parts": [{ "type": "text", "content": "Hello" }]
   }
 ]

For output messages, finish_reason is now always present:

 [
   {
     "role": "assistant",
     "parts": [{ "type": "text", "content": "Hi there" }],
     "finish_reason": "stop"
   }
 ]

The outer { "version", "messages" } wrapper is removed — messages serialize directly as an array.

Changes

  • Updated \MessageTypes.cs\ to align type naming with OTel spec
  • Refactored \MessageWrappers.cs\ for spec compliance
  • Updated \MessageUtils.cs\ accordingly
  • Updated all related tests to reflect the new format

@nikhilNava nikhilNava requested a review from a team as a code owner May 20, 2026 22:25
Copilot AI review requested due to automatic review settings May 20, 2026 22:25
@nikhilNava nikhilNava enabled auto-merge (squash) May 20, 2026 22:25
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 20, 2026

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the observability “gen_ai.*.messages” serialization and related helpers/tests to align the emitted message payloads more closely with the OpenTelemetry gen-ai semantic conventions (moving to a plain JSON array format and updating message model details).

Changes:

  • Changed message wrapper serialization from a versioned object wrapper to a plain JSON array.
  • Updated OutputMessage to always provide a finish_reason (defaulting to "stop").
  • Refreshed unit/integration tests to assert the new JSON array format.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Observability/Runtime/Tracing/MessageUtils.cs Updates normalization/serialization docs and changes diagnostic fallback payload format.
src/Observability/Runtime/Tracing/Contracts/Messages/MessageWrappers.cs Removes versioned wrapper surface and adds JSON converters to serialize wrappers as plain arrays.
src/Observability/Runtime/Tracing/Contracts/Messages/MessageTypes.cs Makes finish_reason non-null and defaults it to "stop".
src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/OutputScopeTest.cs Updates assertions to expect JSON arrays for output messages.
src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/InvokeAgentScopeTest.cs Updates assertions to expect JSON arrays for input/output messages.
src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/InferenceScopeTest.cs Updates assertions to expect JSON arrays for input/output messages.
src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/MessageUtilsTest.cs Updates serialization tests to validate array-root JSON and finish_reason defaults.
src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Etw/EtwLoggingBuilderTests.cs Updates ETW attribute assertions for array-root message payloads.
src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/OutputDataBuilderTests.cs Updates output message attribute assertions for new format.
src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/InvokeAgentDataBuilderTests.cs Updates input/output message attribute assertions for new format.
src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/ExecuteInferenceDataBuilderTests.cs Updates input/output message attribute assertions for new format.
src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/BaseDataBuilderTests.cs Updates joined message attribute assertions for new format.
src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterE2ETests.cs Updates E2E exporter assertions for input/output message payloads.
src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterAsyncE2ETests.cs Updates async E2E exporter assertions for input/output message payloads.
src/Tests/Microsoft.Agents.A365.Observability.Extensions.IntegrationTests/SemanticKernelSpanProcessorTests.cs Updates SK span processor integration assertions for array-root messages.
src/Tests/Microsoft.Agents.A365.Observability.Extensions.IntegrationTests/SemanticKernelInvokeAgentPipelineTests.cs Updates SK invoke-agent pipeline assertions for array-root messages.
src/Tests/Microsoft.Agents.A365.Observability.Extensions.IntegrationTests/AgentFrameworkSpanProcessorTests.cs Updates Agent Framework processor assertions for array-root messages.
src/Tests/Microsoft.Agents.A365.Observability.Extensions.IntegrationTests/AgentFrameworkInvokeAgentPipelineTests.cs Updates Agent Framework invoke-agent pipeline assertions for array-root messages.
src/Tests/Microsoft.Agents.A365.Observability.Extension.Tests/SemanticKernelSpanProcessorHelperTests.cs Updates helper tests to assert JSON array payloads.

Comment thread src/Observability/Runtime/Tracing/MessageUtils.cs
The ChatWithToolCall_ProcessorMapsToolCallParts test was filtering spans
by looking for 'version' in the input messages JSON. Since the envelope
was removed, update the filter to check for array format instead.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nikhilNava nikhilNava merged commit dc1d5ea into main May 20, 2026
7 checks passed
@nikhilNava nikhilNava deleted the nikhilc/updateMessageFormat branch May 20, 2026 22:41
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.

5 participants