Skip to content

fix: relax A2A.V0_3.AgentMessage kind/messageId requirements - #435

Merged
tracyboehrer merged 8 commits into
a2aproject:mainfrom
chopmob-cloud:fix/v03-message-optional-kind-messageid
Sep 16, 2026
Merged

tracyboehrer merged 8 commits into
a2aproject:mainfrom
chopmob-cloud:fix/v03-message-optional-kind-messageid

Conversation

@chopmob-cloud

@chopmob-cloud chopmob-cloud commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #396.

Problem

Real-world v0.3 agents return status.message payloads that omit kind and
messageId, a discrepancy between the .proto and JSON Schema definitions of
v0.3. A2A.V0_3.AgentMessage marked both [JsonRequired], so the whole task
response failed to deserialize with JSON deserialization for type 'A2A.V0_3.AgentMessage' was missing required properties including: 'kind', 'messageId'., even though the outer "kind": "task" discriminator was handled
correctly.

Fix

  • Kind (declared on the shared A2AEvent base): removed [JsonRequired].
    Presence of the discriminator is already enforced independently by
    BaseKindDiscriminatorConverter.Read for polymorphic deserialization
    (through A2AEvent or A2AResponse). The attribute only mattered for the
    concretely-typed path, where the converter never runs, exactly the case here
    (AgentTaskStatus.Message is declared as concrete AgentMessage?, not the
    polymorphic base). Verified the existing A2AEvent_Deserialize_MissingKind_Throws
    and A2AEvent_Deserialize_UnknownKind_Throws_A2AException tests, which exercise
    the polymorphic path, are unaffected: they still throw via the converter's own
    presence check, independent of the attribute.
  • MessageId: removed [JsonRequired]. Falls back to a lazily generated id
    (per review, a backing field with a lazy getter, so the default is only
    generated if the property is read without having been set, not on every
    construction) instead of an empty string, so a message deserialized without
    one still has a usable, unique identifier.

Tests

Adds tests/A2A.V0_3.UnitTests/GitHubIssues/Issue396.cs, mirroring the existing
GitHubIssues/Issue160.cs convention:

  • Issue_396_Passes: the exact payload shape from the issue report deserializes successfully.
  • MessageId_WhenNotSet_IsLazyAndUniquePerInstance: two separately constructed messages get distinct generated ids; repeated reads on the same instance return the same cached value.
  • MessageId_WhenSetFromJson_IsPreservedExactly: an explicit messageId in the payload is never overwritten by the lazy default.

Testing performed

No local .NET SDK in my primary environment, so built and tested on a separate
machine against a fresh clone of main (commit 8fe65cfaa6):

  • Regression-proof: added the new test against the unmodified source first, confirmed it fails with the exact error quoted in the issue (missing required properties including: 'kind', 'messageId'). Applied the fix, confirmed it passes.
  • Full suite (dotnet build/dotnet test --framework net10.0, root A2A.slnx, matching the buildSamples CI job): all 4 test projects passed, 827/827 tests.
  • dotnet build ./src/A2ALibs.slnx --framework net8.0 (buildLibs net8.0 leg): succeeded, 0 warnings, 0 errors.

…ization

A2AEvent.Kind was marked [JsonRequired], but presence of the discriminator
is already enforced independently by BaseKindDiscriminatorConverter.Read
for polymorphic deserialization (through A2AEvent or A2AResponse). The
attribute only mattered for concretely-typed deserialization, where the
converter never runs, e.g. AgentTaskStatus.Message : AgentMessage. Some
v0.3 producers omit kind there, and deserialization failed even though
the property already has a correct default from the constructor.

Part of a2aproject#396.
Some v0.3 producers return status.message without messageId (a
discrepancy between the .proto and JSON Schema definitions of v0.3).
[JsonRequired] rejected the whole response as a result. Defaults to a
freshly generated id, matching messageId being a stable identifier
rather than an empty placeholder.

Fixes a2aproject#396.
…ageId)

Deserializes the exact payload shape from the issue report: a v0.3
task response whose status.message omits both kind and messageId.
Asserts both fields fall back to sensible defaults instead of failing
deserialization.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request removes the [JsonRequired] attribute from the Kind property in A2AEvent and the MessageId property in AgentMessage to prevent deserialization failures when these properties are omitted by some producers. Additionally, MessageId now defaults to a newly generated GUID, and a unit test has been added to verify the changes. The feedback suggests optimizing the MessageId property using lazy initialization to avoid unnecessary allocations when the property is provided in the JSON payload.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/A2A.V0_3/Models/AgentMessage.cs Resolved
Per review: generating the default in the auto-property initializer ran
on every AgentMessage construction, including deserialization where the
JSON already carries a messageId, discarding the generated id
immediately. Uses a backing field and a lazy getter instead, so the
default is only generated if the property is actually read without
having been set.
Adds MessageId_WhenNotSet_IsLazyAndUniquePerInstance (two separately
constructed messages get distinct generated ids, and repeated reads on
the same instance return the same cached value) and
MessageId_WhenSetFromJson_IsPreservedExactly (an explicit messageId in
the payload is not overwritten by the lazy default).
@chopmob-cloud
chopmob-cloud force-pushed the fix/v03-message-optional-kind-messageid branch from b257514 to cedfd67 Compare August 4, 2026 07:13
@tracyboehrer
tracyboehrer added this pull request to the merge queue Sep 16, 2026
Merged via the queue into a2aproject:main with commit 83c5643 Sep 16, 2026
6 checks passed
github-actions Bot pushed a commit to EelcoLos/nx-tinkering that referenced this pull request Nov 10, 2026
Updated [A2A](https://github.com/a2aproject/a2a-dotnet) from
1.0.0-preview2 to 1.0.0-preview4.

<details>
<summary>Release notes</summary>

_Sourced from [A2A's
releases](https://github.com/a2aproject/a2a-dotnet/releases)._

## 1.0.0-preview4

## What's Changed
* fix: harden JSON-RPC requests and document blocking migration by
@​xu-shanshan in a2aproject/a2a-dotnet#546
* fix(http): ignore request tenant fields by @​tracyboehrer in
a2aproject/a2a-dotnet#539
* fix(itk): enable push notifications by @​tracyboehrer in
a2aproject/a2a-dotnet#549
* feat: add registry-backed extension negotiation by @​MertBasar0 in
a2aproject/a2a-dotnet#548
* fix: raise an error when a streaming call is not answered with an
event stream by @​Anuja-jayasinghe in
a2aproject/a2a-dotnet#552
* chore: chore(deps):Bump xunit.runner.visualstudio from 4.0.0 to 4.0.1
by @​dependabot[bot] in
a2aproject/a2a-dotnet#561
* docs: explain extension negotiation error mappings by @​MertBasar0 in
a2aproject/a2a-dotnet#562
* feat: add registry-aware extension activation helpers by @​MertBasar0
in a2aproject/a2a-dotnet#563
* refactor!: consolidate context-aware request handler contract by
@​tracyboehrer in a2aproject/a2a-dotnet#553
* fix: align Copilot setup with .NET 8 and 10 by @​tracyboehrer in
a2aproject/a2a-dotnet#557
* chore: Bump version to preview4 by @​tracyboehrer in
a2aproject/a2a-dotnet#565
* feat: add a conditional extension declaration helper by @​MertBasar0
in a2aproject/a2a-dotnet#564
* feat: expose extension activation on custom operation context by
@​MertBasar0 in a2aproject/a2a-dotnet#567
* feat: add proactive task continuation and push-enabled sample by
@​tracyboehrer in a2aproject/a2a-dotnet#554
* chore(deps): Bump the opentelemetry group with 5 updates by
@​dependabot[bot] in a2aproject/a2a-dotnet#577
* chore(deps): Bump JsonSchema.Net from 9.4.0 to 9.4.1 by
@​dependabot[bot] in a2aproject/a2a-dotnet#578
* fix: translate v0.3 client exceptions at adapter boundary by
@​chopmob-cloud in a2aproject/a2a-dotnet#575
* chore(deps): Bump Microsoft.Extensions.AI.Abstractions from 10.10.1 to
10.11.0 by @​dependabot[bot] in
a2aproject/a2a-dotnet#579
* chore: Bump Microsoft.NET.Test.Sdk from 18.10.1 to 18.11.0 by
@​dependabot[bot] in a2aproject/a2a-dotnet#581
* chore(deps): Bump Microsoft.VisualStudio.Threading.Analyzers from
18.7.23 to 18.12.1 by @​dependabot[bot] in
a2aproject/a2a-dotnet#582
* docs: guide durable push notification sender implementations by
@​tracyboehrer in a2aproject/a2a-dotnet#571
* chore: chore(deps): Bump System.CommandLine from 2.0.12 to 2.0.13 by
@​dependabot[bot] in a2aproject/a2a-dotnet#583
* chore(deps): update shared .NET dependencies to 10.0.13 by
@​dependabot[bot] in a2aproject/a2a-dotnet#580
* test: synchronize cleanup cancellation with initial task admission by
@​tracyboehrer in a2aproject/a2a-dotnet#587
* chore: Bump the opentelemetry group with 5 updates by
@​dependabot[bot] in a2aproject/a2a-dotnet#589
* feat: auto-delete terminal push notification configs by @​tracyboehrer
in a2aproject/a2a-dotnet#588
* docs: guide secure persistent push notification stores by
@​tracyboehrer in a2aproject/a2a-dotnet#570
* ci: update ITK and ACTS to latest upstream by @​tracyboehrer in
a2aproject/a2a-dotnet#576
* ci: report ACTS advisory failures on pull requests by @​tracyboehrer
in a2aproject/a2a-dotnet#573


**Full Changelog**:
a2aproject/a2a-dotnet@v1.0.0-preview3...v1.0.0-preview4

## 1.0.0-preview3

## What's Changed
* fix: Return pre-stream errors as JSON-RPC responses by @​tracyboehrer
in a2aproject/a2a-dotnet#476
* chore: Bump System.Net.ServerSentEvents from 10.0.10 to 10.0.11 by
@​dependabot[bot] in a2aproject/a2a-dotnet#467
* chore: build(deps): bump actions/checkout from 4 to 7 by
@​dependabot[bot] in a2aproject/a2a-dotnet#481
* chore: build(deps): bump actions/setup-dotnet from 4 to 6 by
@​dependabot[bot] in a2aproject/a2a-dotnet#482
* chore: build(deps): bump actions/cache from 4 to 6 by
@​dependabot[bot] in a2aproject/a2a-dotnet#483
* chore: build(deps): bump docker/setup-buildx-action from 3 to 4 by
@​dependabot[bot] in a2aproject/a2a-dotnet#484
* fix: return REST pre-stream errors before SSE headers by
@​tracyboehrer in a2aproject/a2a-dotnet#486
* chore: build(deps): bump softprops/action-gh-release from 2 to 3 by
@​dependabot[bot] in a2aproject/a2a-dotnet#479
* chore: Bump System.Text.Json from 10.0.11 to 10.0.12 by
@​dependabot[bot] in a2aproject/a2a-dotnet#491
* chore: build(deps): Bump Microsoft.Extensions.Logging.Abstractions
from 10.0.11 to 10.0.12 by @​dependabot[bot] in
a2aproject/a2a-dotnet#487
* chore: build(deps): Bump System.Net.ServerSentEvents from 10.0.11 to
10.0.12 by @​dependabot[bot] in
a2aproject/a2a-dotnet#490
* chore: build(deps): Bump System.CommandLine from 2.0.11 to 2.0.12 by
@​dependabot[bot] in a2aproject/a2a-dotnet#488
* chore: Bump System.Linq.AsyncEnumerable from 10.0.8 to 10.0.12 by
@​dependabot[bot] in a2aproject/a2a-dotnet#489
* chore: build(deps): bump docker/build-push-action from 6 to 7 by
@​dependabot[bot] in a2aproject/a2a-dotnet#480
* chore: build(deps): Bump Microsoft.SemanticKernel.Agents.Core from
1.79.0 to 1.80.1 by @​dependabot[bot] in
a2aproject/a2a-dotnet#477
* chore: Bump Roslynator.Analyzers from 4.16.1 to 5.0.0 by
@​dependabot[bot] in a2aproject/a2a-dotnet#470
* chore: build(deps): Bump Roslynator.CodeAnalysis.Analyzers from 4.16.1
to 5.0.0 by @​dependabot[bot] in
a2aproject/a2a-dotnet#471
* chore: build(deps): Bump xunit.runner.visualstudio from 3.1.5 to 4.0.0
by @​dependabot[bot] in
a2aproject/a2a-dotnet#468
* chore: build(deps): Bump Microsoft.VisualStudio.Threading.Analyzers
from 17.14.15 to 18.7.23 by @​dependabot[bot] in
a2aproject/a2a-dotnet#430
* feat: Map JSON DataContent to Part.Data by @​SergeyMenshykh in
a2aproject/a2a-dotnet#448
* fix: flatten TaskPushNotificationConfig to match v1 spec by
@​darrelmiller in a2aproject/a2a-dotnet#418
* chore: build(deps): Bump Microsoft.NET.Test.Sdk from 18.9.0 to 18.10.0
by @​dependabot[bot] in
a2aproject/a2a-dotnet#494
* chore: Bump Microsoft.Extensions.AI.Abstractions from 10.9.0 to
10.10.0 by @​dependabot[bot] in
a2aproject/a2a-dotnet#493
* docs: Add docs about handling cookies and HttpClient by @​cincuranet
in a2aproject/a2a-dotnet#496
* chore: build(deps): Bump Polly from 8.7.0 to 8.8.0 by
@​dependabot[bot] in a2aproject/a2a-dotnet#497
* fix: enforce first-persisted terminal state under the task lock
(#​401) by @​chopmob-cloud in
a2aproject/a2a-dotnet#449
* fix: Return capability-aware extended card errors by @​tracyboehrer in
a2aproject/a2a-dotnet#475
* fix: Add AgentCard HTTP caching metadata by @​tracyboehrer in
a2aproject/a2a-dotnet#492
* chore: build(deps): Bump Microsoft.NET.Test.Sdk from 18.10.0 to
18.10.1 by @​dependabot[bot] in
a2aproject/a2a-dotnet#498
* fix: relax A2A.V0_3.AgentMessage kind/messageId requirements by
@​chopmob-cloud in a2aproject/a2a-dotnet#435
* chore: Bump the opentelemetry group with 5 updates by
@​dependabot[bot] in a2aproject/a2a-dotnet#501
* chore: build(deps): Bump Moq from 4.20.72 to 4.21.0 by
@​dependabot[bot] in a2aproject/a2a-dotnet#503
* fix(server): surface streaming persistence failures instead of ending
the stream (#​495) by @​chopmob-cloud in
a2aproject/a2a-dotnet#505
* feat: switch ITK to a2a-itk shared scenarios and onboard ACTS by
@​JakubWorek in a2aproject/a2a-dotnet#499
* chore: Bump coverlet.collector from 10.0.1 to 10.1.0 by
@​dependabot[bot] in a2aproject/a2a-dotnet#506
* chore: Bump Microsoft.Extensions.AI.Abstractions from 10.10.0 to
10.10.1 by @​dependabot[bot] in
a2aproject/a2a-dotnet#507
* feat: Add gRPC binding: client, ASP.NET Core server, and tests by
@​janosSarusiKis in a2aproject/a2a-dotnet#432
* fix: preserve HTTP JSON task responses and filters by
@​Anuja-jayasinghe in a2aproject/a2a-dotnet#509
* chore: build(deps): Bump Google.Protobuf from 3.35.1 to 3.36.2 by
@​dependabot[bot] in a2aproject/a2a-dotnet#517
* chore: build(deps): Bump Roslynator.CodeAnalysis.Analyzers from 5.0.0
to 5.0.1 by @​dependabot[bot] in
a2aproject/a2a-dotnet#522
* chore: build(deps): Bump Roslynator.Analyzers from 5.0.0 to 5.0.1 by
@​dependabot[bot] in a2aproject/a2a-dotnet#521
* ci: pin GitHub Actions to commit SHAs by @​chopmob-cloud in
a2aproject/a2a-dotnet#523
* chore: Bump Grpc.Tools from 2.80.0 to 2.84.0 by @​dependabot[bot] in
a2aproject/a2a-dotnet#520
* chore: Bump Grpc.Net.Client from 2.80.0 to 2.84.0 by @​dependabot[bot]
in a2aproject/a2a-dotnet#519
* fix: map capabilities.extensions in v0.3 compat agent card by
@​hwanders in a2aproject/a2a-dotnet#515
* chore: Bump Grpc.AspNetCore from 2.80.0 to 2.84.0 by @​dependabot[bot]
in a2aproject/a2a-dotnet#518
* fix: restrict task status filters to wire values by @​Anuja-jayasinghe
in a2aproject/a2a-dotnet#526
* ci: run every test project on net8.0 and net10.0 by @​janosSarusiKis
in a2aproject/a2a-dotnet#528
* fix: enforce ACTS conformance and make checks blocking by
@​tracyboehrer in a2aproject/a2a-dotnet#530
 ... (truncated)

Commits viewable in [compare
view](a2aproject/a2a-dotnet@v1.0.0-preview2...v1.0.0-preview4).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=A2A&package-manager=nuget&previous-version=1.0.0-preview2&new-version=1.0.0-preview4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Eelco Los <5102501+EelcoLos@users.noreply.github.com>
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.

Relax v0.3 response deserialization status.message missing 'kind' and 'messageId'

2 participants