Skip to content

Python: preserve Responses replay metadata across AG-UI continuations - #3

Closed
eavanvalkenburg wants to merge 20 commits into
mainfrom
eavanvalkenburg-agui-provider-matrix
Closed

Python: preserve Responses replay metadata across AG-UI continuations#3
eavanvalkenburg wants to merge 20 commits into
mainfrom
eavanvalkenburg-agui-provider-matrix

Conversation

@eavanvalkenburg

Copy link
Copy Markdown
Owner

Motivation & Context

AG-UI supports both stateless snapshot replay and provider-managed conversation continuation. These modes must not leak into each other: stateless runs should replay complete message history without restoring a provider response ID, while service-session runs should send only the incremental turn and restore private provider continuation state.

A cross-provider multi-turn matrix also found that real Responses output_text.logprobs were parsed into response-level metadata but were not retained on assistant content for direct replay. This loses provider-supplied data and prevents conformant replay when the receiving endpoint requires that field.

Description & Review Guide

  • What are the major changes?

    • Persist and restore provider service-session IDs only when AG-UI service-session mode is active.
    • Reject use_service_session=True with an explicit store=False using a clear configuration error.
    • Preserve real assistant output_text.logprobs on parsed content and mirror them during direct Responses replay without fabricating empty values.
    • Add live two-turn AG-UI integration matrices for OpenAI Responses, OpenAI Chat Completions, FoundryChatClient, Foundry Prompt Agents, and Foundry Hosted Agents across stateless, conversation, and previous-response modes where applicable.
    • Keep the known Hosted Agent stateless replay incompatibility as a strict expected failure with a TODO to remove it when the upstream service accepts standard output-text replay without logprobs.
  • What is the impact of these changes?

    • Stateless AG-UI history no longer accidentally combines full replay with a stored provider response ID.
    • Invalid disabled-storage service-session configurations fail before a provider request.
    • Provider-supplied logprobs survive direct assistant-message replay; messages without logprobs remain unchanged.
    • Multi-turn continuation behavior is continuously exercised across the supported OpenAI and Foundry client surfaces.
  • What do you want reviewers to focus on?

    • The boundary between stateless snapshot state and provider-owned continuation state.
    • Selective logprobs preservation without synthetic defaults.
    • Matrix coverage and cleanup of temporary provider conversations and Prompt Agents.
    • The strict xfail scope for the known Hosted Agent stateless replay issue.

Related Issue

Fixes microsoft#7905

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.

Copilot AI and others added 20 commits August 25, 2026 11:10
…soft#7842)

* Initial plan

* Honor cancellation before response completion

Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
* Initial plan

* Use Responses API for hosted web search

Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>

* .NET: Use OpenAI SDK for AG-UI web search

Copilot-Session: 2b346dcb-1702-4296-bf22-b434b73fd26c

* .NET: Keep AG-UI web search history local

Copilot-Session: 2b346dcb-1702-4296-bf22-b434b73fd26c

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
Copilot-Session: 2b346dcb-1702-4296-bf22-b434b73fd26c
* chore: annotate validated attachment paths

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 104d342a-090c-4feb-9bb3-662915b9c390

* fix: update attachment handling

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 104d342a-090c-4feb-9bb3-662915b9c390

* chore: preserve analysis annotations

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 104d342a-090c-4feb-9bb3-662915b9c390

* fix: use attachment upload descriptor

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 104d342a-090c-4feb-9bb3-662915b9c390

* chore: correct analysis annotations

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 104d342a-090c-4feb-9bb3-662915b9c390

---------

Copilot-Session: 104d342a-090c-4feb-9bb3-662915b9c390
* Bump Aspire.Hosting from 13.1.0 to 13.5.2

---
updated-dependencies:
- dependency-name: Aspire.Hosting
  dependency-version: 13.5.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix Aspire 13.5.2 restore/build regressions

Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>

* Use Aspire AppHost SDK 13.5.2 with temporary _AspireUseSdkPickBestRid workaround

Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>

* Reuse AspireAppHostSdkVersion for Aspire packages

Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
* Suppress false positive Zip Slip alert

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b8c7b4b0-21bf-4b63-ba64-75e5c4b7ab34

* Fix FeatureDeclaration analyzer warning

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b8c7b4b0-21bf-4b63-ba64-75e5c4b7ab34

* Remove unnecessary CodeAnalysis import

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b8c7b4b0-21bf-4b63-ba64-75e5c4b7ab34

* Restore FeatureRegistry test imports

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b8c7b4b0-21bf-4b63-ba64-75e5c4b7ab34

* Suppress platform-specific unused import warning

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b8c7b4b0-21bf-4b63-ba64-75e5c4b7ab34

---------

Copilot-Session: b8c7b4b0-21bf-4b63-ba64-75e5c4b7ab34
…soft#7850)

The Anthropic and Mistral chat clients looked their finish reason maps up
without a default, so any provider value the map did not cover was reported
to the caller as no finish reason at all. Anthropic's
model_context_window_exceeded and Mistral's error both disappeared this way.

Fall back to the raw provider value instead, the way the other provider
clients have since microsoft#7105. Every already-mapped value keeps mapping as
before, and an absent reason stays absent.

Fixes microsoft#7849
…les. (microsoft#7792)

* added Mem0Sharp integration for in-memory storage in agent samples.

microsoft#7467

* formatting fix

* Remove Mem0Sharp integration from agent memory samples and update README links

* Fix: Add missing newline at end of solution file

* Fix: Add missing newline at end of solution file
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 42a18a81-57d5-4912-8dbd-f1a48db57a45
…osoft#7864)

* Move CodeQL suppression above SendAsync

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b1089839-7a12-4a45-b492-1a984e702bd5

* Add CodeQL suppression for DevUI trailing-slash redirect

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b1089839-7a12-4a45-b492-1a984e702bd5

---------

Copilot-Session: b1089839-7a12-4a45-b492-1a984e702bd5
…osoft#7878)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
* .NET: Simplify A2A function tool samples

Split whole-agent and per-skill function tool concepts into focused samples.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 31ff03bb-ffc6-43ba-be4a-7b235c3c7da9

* .NET: Use Foundry in A2A tool samples

Replace the Azure OpenAI setup with the canonical Foundry project client in both A2A samples.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 31ff03bb-ffc6-43ba-be4a-7b235c3c7da9

---------

Co-authored-by: SergeyMenshykh <SergeMenshikh@outlook.com>
Copilot-Session: 31ff03bb-ffc6-43ba-be4a-7b235c3c7da9
* ci: adds dependabot cooldown for python and dotnet

Signed-off-by: Vincent Biret <vibiret@microsoft.com>

* ci: adds cooldown for pip as well

---------

Signed-off-by: Vincent Biret <vibiret@microsoft.com>
….6 (microsoft#7886)

---
updated-dependencies:
- dependency-name: Azure.AI.AgentServer.Invocations
  dependency-version: 1.0.0-beta.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…soft#7869)

* docs: updates the contributing information for CFS users

* chore: typos fix

Co-authored-by: westey <164392973+westey-m@users.noreply.github.com>

* chore: typo fix

Co-authored-by: westey <164392973+westey-m@users.noreply.github.com>

---------

Co-authored-by: westey <164392973+westey-m@users.noreply.github.com>
…oft#7888)

---
updated-dependencies:
- dependency-name: CommunityToolkit.VectorData.InMemory
  dependency-version: 1.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* fix(python): separate provider input from UI snapshot in AG-UI service-session mode

* fix(python): separate provider input from UI snapshot in AG-UI service-session mode

* fix: use identity matching for service-session split and snapshot reconstruction

* fix(python): validate AG-UI service-session continuations

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* test(python): cover explicit hosted conversation history

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* test(python): cover AG-UI service storage boundary

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* test(python): clarify hosted-agent test wiring

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* test(python): cover AF primitive conversation history

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* fix(python): separate AG-UI thread and provider sessions

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* fix(python): make AG-UI service mapping explicit

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: eavanvalkenburg <github@vanvalkenburg.eu>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Eduard van Valkenburg <eavanvalkenburg@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@eavanvalkenburg

Copy link
Copy Markdown
Owner Author

Closed because this draft was intended for the upstream microsoft/agent-framework repository.

@github-actions

Copy link
Copy Markdown

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/ag-ui/agent_framework_ag_ui
   _agent.py48295%82, 145
   _agent_run.py147714790%161, 221, 240, 287, 305, 321–322, 444, 497–498, 505, 614, 618, 620, 637, 664–665, 719, 748, 762, 766, 770, 773, 778, 783, 795, 802–808, 819, 833, 840, 850, 865, 868, 900, 935, 959, 972, 1021, 1039, 1041, 1067, 1069, 1071, 1074–1078, 1102, 1133, 1169, 1224–1225, 1267, 1281, 1326–1332, 1341, 1349, 1377, 1399, 1403, 1406, 1408, 1468–1469, 1475–1481, 1584, 1588–1589, 1592, 1597–1598, 1601, 1607–1608, 1612–1614, 1632–1634, 1659–1660, 1683–1684, 1697, 1739–1741, 1752–1754, 1756, 1770–1772, 1900, 1908, 1938, 1942, 1987, 2152–2153, 2239, 2348, 2353, 2425, 2427, 2434, 2450, 2455, 2512, 2517, 2521, 2570, 2620, 2695, 2841, 2879, 2887, 2889, 2892, 2898, 2953, 2956, 2966–2967, 2974, 3021
   _run_common.py6623095%100, 175–176, 178, 180, 183, 189, 191, 205, 212, 236–237, 250, 269, 292–294, 305, 349, 361, 369, 372, 560, 581, 875–876, 1200–1201, 1267, 1270
   _snapshots.py83495%139, 222, 233–234
packages/anthropic/agent_framework_anthropic
   _chat_client.py5423493%483, 486, 572, 709, 809, 843, 933, 972–973, 1051, 1053, 1083–1084, 1166–1168, 1172–1174, 1178–1181, 1216, 1332, 1342, 1394, 1542–1543, 1560, 1573, 1586, 1611–1612
packages/core/agent_framework
   _agents.py4624490%600, 655, 1225, 1270, 1341–1345, 1444, 1474, 1511, 1606, 1634, 1647, 1696, 1698, 1707–1712, 1717, 1719, 1725–1726, 1733, 1735–1736, 1744–1745, 1748–1750, 1760–1765, 1769, 1774, 1776
packages/mistral/agent_framework_mistral
   _chat_client.py4621097%285, 287–289, 296, 300, 304, 307–308, 310
packages/openai/agent_framework_openai
   _chat_client.py140911491%361, 374, 728–734, 743–746, 752–756, 764, 808–813, 817–820, 822–824, 831–833, 836, 893, 901, 924, 1141, 1200, 1202, 1204, 1206, 1272, 1286, 1366, 1376, 1381, 1424, 1536–1537, 1552, 1831, 1943, 1948–1949, 2032, 2042, 2069, 2075, 2085, 2091, 2096, 2102, 2107–2108, 2188, 2232, 2235–2238, 2252, 2262–2263, 2275, 2317, 2382, 2399, 2402, 2429–2431, 2470, 2487, 2490, 2552, 2559, 2596–2597, 2638, 2676–2677, 2695–2696, 2868–2869, 2887, 2978–2981, 3159, 3174, 3263–3265, 3275–3276, 3282, 3297, 3430–3431
TOTAL48234448190% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
9764 36 💤 0 ❌ 0 🔥 2m 40s ⏱️

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.

Python: Preserve Responses replay metadata across AG-UI continuations

8 participants