Skip to content

Python: Move InMemory history provider injection to the first invocation#5236

Merged
eavanvalkenburg merged 2 commits intomainfrom
feature/python-move-in-memory-history-provider-injection-for-workflow-as-agent
Apr 14, 2026
Merged

Python: Move InMemory history provider injection to the first invocation#5236
eavanvalkenburg merged 2 commits intomainfrom
feature/python-move-in-memory-history-provider-injection-for-workflow-as-agent

Conversation

@TaoChenOSU
Copy link
Copy Markdown
Contributor

@TaoChenOSU TaoChenOSU commented Apr 13, 2026

Motivation and Context

Move the InMemoryHistoryProvider injection to when the agent is first invoked, similar to how a normal agent works. This is required by hosted agent as it doesn't need a history provider preconfigured.

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.

Copilot AI review requested due to automatic review settings April 13, 2026 23:19
@TaoChenOSU TaoChenOSU self-assigned this Apr 13, 2026
@github-actions github-actions bot changed the title Move InMemory history provider injection to the first invocation Python: Move InMemory history provider injection to the first invocation Apr 13, 2026
@moonbox3
Copy link
Copy Markdown
Contributor

moonbox3 commented Apr 13, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework/_workflows
   _agent.py3607180%66, 74–80, 116–117, 210, 271, 284, 351, 362, 364, 424, 430, 440–441, 448, 450, 456, 518–519, 528, 535, 561, 594–596, 598, 600, 602, 607, 612, 659, 689, 706, 745–748, 754, 760, 764–765, 768–774, 778–779, 787, 848, 855, 861–862, 873, 905, 912, 933, 942, 946, 948–950, 957
TOTAL27205318588% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
5458 20 💤 0 ❌ 0 🔥 1m 27s ⏱️

Copy link
Copy Markdown
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 PR changes when WorkflowAgent auto-injects InMemoryHistoryProvider, moving it from construction time to the first invocation so the workflow-wrapped agent behaves more like a “normal” agent lifecycle.

Changes:

  • Removed default InMemoryHistoryProvider injection from WorkflowAgent.__init__.
  • Added runtime injection of InMemoryHistoryProvider in _run_impl and _run_stream_impl when no “loading” HistoryProvider is detected.

Comment thread python/packages/core/agent_framework/_workflows/_agent.py Outdated
Comment thread python/packages/core/agent_framework/_workflows/_agent.py Outdated
Comment thread python/packages/core/agent_framework/_workflows/_agent.py Outdated
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Apr 14, 2026
Merged via the queue into main with commit 7bb0fec Apr 14, 2026
31 checks passed
@TaoChenOSU TaoChenOSU deleted the feature/python-move-in-memory-history-provider-injection-for-workflow-as-agent branch April 15, 2026 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants