Repository navigation
Python: Sramsey/python continuation token fix - #9002
Eduard van Valkenburg (eavanvalkenburg) merged 8 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Completed responses converted with to_updates() can still fail to clear a previously aggregated continuation token.
Review effort: Balanced
Findings: 1
What changed in this PR
Adds explicit terminal-state signaling so streaming aggregation preserves active continuation tokens until completion.
Changes:
- Adds and propagates
is_operation_terminal. - Marks terminal OpenAI and A2A events.
- Adds aggregation and provider regression tests.
| File | Description |
|---|---|
python/packages/core/agent_framework/_types.py |
Adds terminal signaling and token aggregation logic. |
python/packages/core/agent_framework/_workflows/_agent.py |
Propagates terminal state through workflows. |
python/packages/core/tests/core/test_types.py |
Tests aggregation, mapping, and serialization. |
python/packages/core/tests/workflow/test_workflow_agent.py |
Tests workflow metadata propagation. |
python/packages/openai/agent_framework_openai/_chat_client.py |
Marks terminal Responses API events. |
python/packages/openai/tests/openai/test_openai_chat_client.py |
Tests OpenAI terminal handling. |
python/packages/a2a/agent_framework_a2a/_agent.py |
Emits A2A terminal markers. |
python/packages/a2a/tests/test_a2a_agent.py |
Tests A2A completion and artifact streams. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Code Coverage OverviewLanguages: Python Python / code-coverage/pythonThe overall line coverage in commit 46d13cd in the Show a line coverage summary of the most impacted files.
Updated |
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (2 commit(s)): d298983a1397, 2b67d6b3571d
Model: gpt-5.6-sol
Overview
The PR introduces an explicit terminal-operation signal and applies it consistently in the changed A2A, OpenAI, chat-to-agent, and workflow-update paths, with focused tests for token preservation, terminal clearing, serialization, and artifact deduplication. The remaining risk is in compatibility paths outside those direct producers: response-to-update round-trips discard the new signal, and existing custom providers do not emit it, so both paths can retain stale continuation tokens after completion.
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: python/packages/core/agent_framework/_types.py
|
sophia-ramsey The response round-trip still drops terminality: |
2b67d6b to
df1a3e8
Compare
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
|
Copilot the last commit broke everything, please fix |
Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com>
Restored the missing |
Jose Alvarez (jpalvarezl)
left a comment
There was a problem hiding this comment.
Found two continuation-lifecycle gaps not covered by the existing review threads; details are attached inline.
Jose Alvarez (jpalvarezl)
left a comment
There was a problem hiding this comment.
The two follow-up commits address the outstanding continuation-lifecycle findings: operation state now survives update serialization round-trips, and OpenAI streaming error/terminal-created events clear resume state and surface errors. The added regressions cover both paths, and the current CI suite is fully green.

Motivation & Context
Tokenless intermediate streaming updates currently overwrite an active continuation token, incorrectly indicating that the provider operation has completed. This change preserves the token while an operation remains in progress and clears it when the operation reaches a terminal state, including after responses are buffered and converted back into updates.
Description & Review Guide
_OperationStateis preserved through aggregation, response-to-update conversion, workflow forwarding, and buffered middleware. OpenAIcompleted,incomplete, andfailedevents and A2Acompleted,failed,canceled, andrejectedstates are markedterminal; intermediate provider updates are markedin_progress.Related Issue
Fixes #8826
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.