Skip to content

Conversation

@moonbox3
Copy link
Contributor

Motivation and Context

Fixes #2754 - Workflows wrapped as agents via as_agent() now properly include thread conversation history when running.

When using workflow.as_agent() with an AgentThread, the thread's conversation history was not being passed to the workflow execution. This caused the workflow participants to lose context from previous turns, making multi-turn conversations impossible.

Modified WorkflowAgent._run_stream_impl() to retrieve messages from thread.message_store.list_messages() and prepend them to the input messages before calling workflow.run_stream().

Also added support for checkpoint_id and checkpoint_storage parameters in WorkflowAgent.run() and run_stream() to enable workflow state persistence.

Description

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 Dec 11, 2025
@moonbox3 moonbox3 added the workflows Related to Workflows in agent-framework label Dec 11, 2025
Copilot AI review requested due to automatic review settings December 11, 2025 03:07
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation python labels Dec 11, 2025
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Dec 11, 2025

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework/_workflows
   _agent.py2414182%56, 64–70, 98–99, 250, 292, 332–335, 341, 347, 351–352, 355–361, 365–366, 405, 412, 418–419, 425, 437, 469, 476, 497, 504, 508, 519
TOTAL16610257384% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
2392 130 💤 0 ❌ 0 🔥 56.664s ⏱️

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

This pull request fixes issue #2754 by enabling WorkflowAgent to properly include thread conversation history when running workflows and adds support for checkpoint storage parameters.

Key changes:

  • Modified _run_stream_impl() to retrieve and prepend thread message history to input messages for workflow execution
  • Added checkpoint_id and checkpoint_storage parameters to WorkflowAgent.run() and run_stream() methods
  • Added comprehensive test coverage for thread history handling and checkpoint storage integration

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
python/packages/core/agent_framework/_workflows/_agent.py Core implementation: added checkpoint parameters to run/run_stream methods and modified _run_stream_impl to prepend thread history to messages before workflow execution
python/packages/core/tests/workflow/test_workflow_agent.py Added ConversationHistoryCapturingExecutor test helper and four new test cases covering thread history inclusion, empty threads, and checkpoint storage
python/samples/getting_started/workflows/agents/workflow_as_agent_with_thread.py New sample demonstrating multi-turn conversations with workflow-as-agent using AgentThread for conversation history persistence
python/samples/getting_started/workflows/checkpoint/workflow_as_agent_checkpoint.py New sample demonstrating checkpoint storage usage with workflow-as-agent for state persistence and resume capability
python/samples/getting_started/workflows/README.md Added table entries for the two new sample files in the agents and checkpoint sections

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@moonbox3 moonbox3 enabled auto-merge December 12, 2025 04:00
@moonbox3 moonbox3 added this pull request to the merge queue Dec 12, 2025
Merged via the queue into microsoft:main with commit 0fc7933 Dec 12, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python workflows Related to Workflows in agent-framework

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Python: Workflow as an Agent don't work with threads

4 participants