Skip to content

Conversation

@moonbox3
Copy link
Contributor

Motivation and Context

Fixes a streaming resume bug in AgentExecutor where continuation context could be lost, causing provider errors like:

No tool call found for function call output with call_id ...

The issue is that AgentExecutor._run_agent_streaming iterated streamed updates and rebuilt the final response from collected updates, instead of finalizing the ResponseStream via get_final_response(). That bypassed stream result hooks, which are responsible for persisting thread/conversation state needed for follow-up tool output continuation.

Description

  • Updated AgentExecutor streaming flow to call await stream.get_final_response() after iteration.
  • Preserved request-info behavior by merging user_input_requests from:
    • streamed updates, and
    • finalized response
      with request-id deduplication.
  • Updated streaming thread state update logic to use conversation_id extracted from raw streaming updates (instead of response_id).
  • Added regression tests for:
    • streaming thread id uses conversation_id,
    • streaming path does not incorrectly use response_id,
    • AgentExecutor streaming executes stream result hooks by finalizing the stream.
  • Handoff checkpoint Sample cleanup:
    • better final conversation output formatting,
    • buffered/normalized streamed text printing,
    • typing fixes for output narrowing.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@moonbox3 moonbox3 self-assigned this Feb 12, 2026
@moonbox3 moonbox3 marked this pull request as ready for review February 12, 2026 11:39
Copilot AI review requested due to automatic review settings February 12, 2026 11:39
@github-actions github-actions bot changed the title Fix streamed workflow agent continuation context by finalizing AgentExecutor streams Python: Fix streamed workflow agent continuation context by finalizing AgentExecutor streams Feb 12, 2026
@moonbox3 moonbox3 added the workflows Related to Workflows in agent-framework label Feb 12, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a streaming resume/continuation bug by ensuring agent streaming paths finalize ResponseStream instances (so result hooks run and state is persisted), and updates streaming thread-id handling to rely on conversation_id rather than response_id.

Changes:

  • Update AgentExecutor streaming to call await stream.get_final_response() and merge/dedupe user_input_requests.
  • Update streaming thread-id updates to extract and use conversation_id from raw streaming updates.
  • Add regression tests for stream finalization hooks and for thread-id behavior in streaming.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
python/packages/core/agent_framework/_workflows/_agent_executor.py Finalizes agent response streams and dedupes user_input_requests after streaming completes.
python/packages/core/agent_framework/_agents.py Changes streaming thread-id update logic to extract conversation_id from raw streaming updates.
python/packages/core/tests/workflow/test_agent_executor.py Adds regression test ensuring AgentExecutor streaming finalizes streams and runs result hooks.
python/packages/core/tests/core/test_agents.py Adds tests asserting streaming thread-id uses conversation_id and does not fall back to response_id.
python/packages/core/agent_framework/azure/_responses_client.py Formatting-only changes (no functional behavior change).
python/samples/getting_started/orchestrations/handoff/handoff_with_tool_approval_checkpoint_resume.py Updates sample to use streaming workflow runs and prints streamed agent output during resume.

@moonbox3 moonbox3 moved this to In Review in Agent Framework Feb 12, 2026
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Feb 12, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   _agents.py3124087%476, 876, 912, 984, 989–992, 1056–1058, 1172, 1185, 1198, 1204, 1240, 1242, 1251–1256, 1262, 1264, 1274–1275, 1282, 1284–1285, 1293–1297, 1305–1306, 1308, 1313, 1315
   _mcp.py4066484%104–105, 115–120, 131, 136, 182–183, 193–198, 208–209, 261, 270, 333, 341, 362, 476, 543, 578, 580, 584–585, 587–588, 642, 657, 675, 716, 822, 835–840, 862, 908–909, 915–917, 936, 961–962, 966–970, 987–991, 1135
packages/core/agent_framework/_workflows
   _agent_executor.py1982686%97, 145, 163–164, 216–217, 219–220, 250–252, 260–262, 270–272, 274, 278, 282, 286–287, 386–387, 433, 451
TOTAL20444324984% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3908 225 💤 0 ❌ 0 🔥 1m 8s ⏱️

@moonbox3 moonbox3 requested a review from a team as a code owner February 12, 2026 12:01
@moonbox3 moonbox3 enabled auto-merge February 12, 2026 12:05
@moonbox3 moonbox3 removed the request for review from a team February 12, 2026 22:30
@moonbox3 moonbox3 added this pull request to the merge queue Feb 12, 2026
Merged via the queue into microsoft:main with commit a276c12 Feb 12, 2026
25 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in Agent Framework Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python workflows Related to Workflows in agent-framework

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants