Skip to content

Python: .NET: Keep A2A streaming session state current - #8646

Merged
SergeyMenshykh merged 6 commits into
microsoft:mainfrom
SergeyMenshykh:sergeymenshykh-a2a-continuation-token-issue
Sep 22, 2026
Merged

SergeyMenshykh merged 6 commits into
microsoft:mainfrom
SergeyMenshykh:sergeymenshykh-a2a-continuation-token-issue

Conversation

@SergeyMenshykh

@SergeyMenshykh SergeyMenshykh commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation & Context

A streamed A2A response could be yielded before its context ID was checked against the context already associated with the provided session. This could allow callers to observe an update from a different context before the mismatch was reported.

Description & Review Guide

  • What are the major changes? Validate the context ID of message, task, status-update, and artifact-update payloads before yielding their corresponding updates. Apply the same behavior to the .NET and Python A2A implementations and add regression coverage for all four payload types.
  • What is the impact of these changes? When both the session and response contain context IDs, a mismatch now fails before the response update is exposed to the caller. Responses without a context ID remain accepted. Continuation requirements, session-persistence timing, and public API signatures are unchanged.
  • What do you want reviewers to focus on? The timing of context validation, parity between the .NET and Python implementations, and preservation of existing session and continuation behavior.

Related Issue

N/A.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

SergeyMenshykh and others added 2 commits September 22, 2026 14:19
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

Whitespace-only context IDs can bypass the new unbound-session validation.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Improves A2A continuation session validation and preserves streaming session state during interrupted enumeration.

Changes:

  • Requires context-bound sessions for continuation tokens.
  • Updates session state before yielding streaming responses.
  • Adds regression tests for continuation and streaming behavior.
File Description
dotnet/​src/​Microsoft.Agents.AI.A2A/​A2AAgent.cs Implements continuation validation and incremental session updates.
dotnet/​tests/​Microsoft.Agents.AI.A2A.UnitTests/​A2AAgentTests.cs Adds continuation and interrupted-stream coverage.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@github-actions github-actions 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.

MAF Automated Review — Iteration 1

Result: Findings reported
Scope: full PR (2 commit(s)): cf4c6f6734fa, a0bea7bcae57
Model: gpt-5.6-sol-fast

Overview

The change consistently requires a context-bound session for continuation calls and moves streaming session updates ahead of each yielded update, with strong regression coverage for mismatched contexts and early abandonment. The shared continuation guard and pre-yield validation prevent several cross-context failure modes. Two residual gaps remain: context-less continuation responses bypass the new binding guarantee, and artifact-only updates can erase persisted task state during an interrupted reconnection.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (2 medium) across 1 file. Details are attached to the affected lines below.

Affected areas: dotnet/src/Microsoft.Agents.AI.A2A/A2AAgent.cs

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@SergeyMenshykh SergeyMenshykh changed the title .NET: [BREAKING] Improve A2A continuation session handling .NET: Keep A2A streaming session state current Sep 22, 2026
@SergeyMenshykh SergeyMenshykh removed the breaking change Usage: [PRs], Target: all PRs that introduce changes that are not backward compatible label Sep 22, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Sep 22, 2026
@SergeyMenshykh SergeyMenshykh changed the title .NET: Keep A2A streaming session state current .NET/Python: Validate A2A streaming context before yielding Sep 22, 2026
@github-actions github-actions Bot changed the title .NET/Python: Validate A2A streaming context before yielding Python: .NET: Keep A2A streaming session state current Sep 22, 2026
@SergeyMenshykh
SergeyMenshykh added this pull request to the merge queue Sep 22, 2026
Merged via the queue into microsoft:main with commit 736e838 Sep 22, 2026
52 of 53 checks passed
@SergeyMenshykh
SergeyMenshykh deleted the sergeymenshykh-a2a-continuation-token-issue branch September 22, 2026 18:43

This branch was previously deployed

2 inactive deployments
github-app-auth — 1a2cb35c Deployed Sep 22, 2026 by SergeyMenshykh via add_label #23570
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Usage: [Issues, PRs], Target: .Net python Usage: [Issues, PRs], Target: Python

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants