Python: preserve Responses replay metadata across AG-UI continuations - #7906
Conversation
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>
There was a problem hiding this comment.
Pull request overview
Preserves provider continuation boundaries and OpenAI Responses replay metadata across AG-UI turns.
Changes:
- Limits provider session-ID persistence to service-session mode.
- Preserves assistant logprobs for non-streaming replay.
- Adds unit and live provider-matrix coverage.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py |
Controls continuation-state persistence and validation. |
python/packages/ag-ui/tests/ag_ui/test_run.py |
Tests disabled-storage rejection. |
python/packages/openai/agent_framework_openai/_chat_client.py |
Preserves output-text logprobs. |
python/packages/openai/tests/openai/test_openai_chat_client.py |
Tests logprobs parsing and replay. |
python/packages/openai/tests/openai/test_agui_provider_matrix.py |
Adds OpenAI continuation matrices. |
python/packages/foundry/tests/foundry/test_agui_provider_matrix.py |
Adds Foundry continuation matrices. |
python/packages/foundry_hosting/tests/test_responses.py |
Tests stateless replay isolation. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (3 commit(s)): a076d28d8702, 477444d0c321, 74a1786cb2b0
Model: gpt-5.6-sol
Overview
The change cleanly separates the standard Responses continuation ID from stateless AG-UI replay and adds focused validation for unsupported storage configurations. It also preserves provider-supplied logprobs for direct non-streaming Responses replay without fabricating values. However, the stateless boundary remains incomplete for providers that keep their continuation identifier in AgentSession.state, allowing Foundry Hosted Agent sessions to be restored despite use_service_session=False.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
1 verified finding remained after source verification (1 medium) across 1 file. Details are attached to the affected lines below.
Affected areas: python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.logprobswere 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?
use_service_session=Truewith an explicitstore=Falseusing a clear configuration error.output_text.logprobson parsed content and mirror them during direct Responses replay without fabricating empty values.What is the impact of these changes?
What do you want reviewers to focus on?
Related Issue
Fixes #7905
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.