Skip to content

refactor: Add metadata parameters to TaskUpdater and MessageResponder methods - #394

Merged
darrelmiller merged 6 commits into
a2aproject:mainfrom
SergeyMenshykh:add-metadata-parameter
Jun 1, 2026
Merged

darrelmiller merged 6 commits into
a2aproject:mainfrom
SergeyMenshykh:add-metadata-parameter

Conversation

@SergeyMenshykh

@SergeyMenshykh SergeyMenshykh commented Apr 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Extends all TaskUpdater and MessageResponder methods with an optional Dictionary<string, JsonElement>? metadata parameter, allowing callers to attach protocol-level metadata to tasks, status update events, artifacts, and messages.

Changes

All new parameters are optional (= null) and placed before CancellationToken, preserving backward compatibility for callers using named arguments.

Caller updates

Updated all existing call sites that passed CancellationToken positionally to use the named cancellationToken: syntax, across samples, tests, and the IAgentHandler default implementation.

Tests

Added 11 new unit tests verifying metadata flows through to the correct model objects for every method on both classes.

Extend all TaskUpdater and MessageResponder methods with an optional
Dictionary<string, JsonElement>? metadata parameter, allowing callers
to attach protocol-level metadata to tasks, status update events,
artifacts, and messages.

- SubmitAsync: metadata flows to AgentTask.Metadata
- Status update methods (StartWorkAsync, CompleteAsync, FailAsync,
  CancelAsync, RejectAsync, RequireInputAsync, RequireAuthAsync):
  metadata flows to TaskStatusUpdateEvent.Metadata
- AddArtifactAsync: metadata flows to Artifact.Metadata
- ReplyAsync (both overloads): metadata flows to Message.Metadata
- Update all callers using positional CancellationToken to named args
- Add 11 unit tests covering metadata propagation for every method

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@SergeyMenshykh SergeyMenshykh changed the title Add metadata parameters to TaskUpdater and MessageResponder methods feature: Add metadata parameters to TaskUpdater and MessageResponder methods Apr 22, 2026
@SergeyMenshykh SergeyMenshykh self-assigned this Apr 22, 2026

@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 introduces optional metadata support across the agent communication framework, specifically within MessageResponder and TaskUpdater, and standardizes the use of named arguments for cancellationToken throughout the codebase. The changes are supported by new unit tests and updates to sample agents. Feedback suggests that the default implementation of CancelAsync in IAgentHandler should propagate metadata from the RequestContext to ensure protocol-level metadata is correctly attached to cancellation events.

Comment thread src/A2A/Server/IAgentHandler.cs
@SergeyMenshykh SergeyMenshykh changed the title feature: Add metadata parameters to TaskUpdater and MessageResponder methods refactor: Add metadata parameters to TaskUpdater and MessageResponder methods Apr 22, 2026
@darrelmiller
darrelmiller added this pull request to the merge queue Jun 1, 2026
Merged via the queue into a2aproject:main with commit 3b1511b Jun 1, 2026
5 checks passed
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.

2 participants