Skip to content

Python: Support checkpoint hydration and new input in a single workflow run (#7863) - #7910

Draft
Shivani . (Shivani767) wants to merge 1 commit into
microsoft:mainfrom
Shivani767:fix/7863-checkpoint-hydrate-and-input
Draft

Python: Support checkpoint hydration and new input in a single workflow run (#7863)#7910
Shivani . (Shivani767) wants to merge 1 commit into
microsoft:mainfrom
Shivani767:fix/7863-checkpoint-hydrate-and-input

Conversation

@Shivani767

@Shivani767 Shivani . (Shivani767) commented Aug 27, 2026

Copy link
Copy Markdown

Motivation & Context

Resuming a multi-turn workflow from a persisted checkpoint previously required two workflow.run calls: hydrate from the checkpoint, then submit the new user input. That adds an unnecessary round trip, can surface intermediate hydrate events to adapters, and complicates HTTP/hosted request handlers that receive one logical request (#7863).

Description & Review Guide

  • What are the major changes?

    • Allow Workflow.run(message=..., checkpoint_id=...) (and the functional-workflow mirror): restore/validate first, then seed start-executor input in the same run.
    • Skip the leftover in-flight-message guard when checkpoint_id is present, because restore replaces the runner context before the new message is applied.
    • Collapse WorkflowAgent’s restore-then-run path into one workflow.run when both checkpoint and input are provided (HITL uses responses + checkpoint_id; idle turns use message + checkpoint_id).
    • Keep AG-UI pure checkpoint resume behavior (messages still map through HITL responses); clarify the branch comments.
    • Add unit tests for graph + functional workflows, including “invalid checkpoint does not execute message”.
    • Add runnable sample: python/samples/03-workflows/checkpoint/checkpoint_hydrate_with_input.py.
  • What is the impact of these changes?

    • Hosts can hydrate and continue in one lifecycle (tracing, cancellation, streaming).
    • Existing two-step usage and checkpoint_id + responses remain supported.
    • Foundry hosting still uses its two-step path when restore/save storages can differ; that adapter can adopt the single-call API in a follow-up.
  • What do you want reviewers to focus on?

    • Semantics of restore-then-seed vs restore-only.
    • Whether WorkflowAgent peeking checkpoint.pending_request_info_events is the right HITL vs idle discriminator.

Related Issue

Fixes #7863

Related: #7809

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Restore and validate the checkpoint before seeding start-executor input so
hosts can resume multi-turn workflows without a separate hydrate round trip
(microsoft#7863). Keep the prior two-step path working.
Copilot AI balanced review requested due to automatic review settings August 27, 2026 11:12
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Aug 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds single-call checkpoint hydration plus new input for Python workflows.

Changes:

  • Supports message with checkpoint_id in graph and functional workflows.
  • Updates workflow adapters and adds checkpoint-resume coverage.
  • Adds a runnable hydration sample.

Reviewed changes

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

Show a summary per file
File Description
python/samples/03-workflows/checkpoint/checkpoint_hydrate_with_input.py Demonstrates combined hydration and input.
python/packages/core/tests/workflow/test_workflow.py Updates parameter validation tests.
python/packages/core/tests/workflow/test_functional_workflow.py Tests functional combined runs.
python/packages/core/tests/workflow/test_checkpoint.py Tests graph hydration, streaming, and validation failure.
python/packages/core/agent_framework/_workflows/_workflow.py Implements graph restore-then-seed behavior.
python/packages/core/agent_framework/_workflows/_functional.py Enables the functional API combination.
python/packages/core/agent_framework/_workflows/_agent.py Consolidates agent checkpoint continuation.
python/packages/ag-ui/agent_framework_ag_ui/_workflow_run.py Clarifies AG-UI checkpoint routing.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +827 to +829
*message* may be combined with *checkpoint_id* to restore a checkpoint
and apply new start input in a single call (#7863). *message* remains
mutually exclusive with *responses*.
Comment on lines 661 to +664
await self._runner.restore_from_checkpoint(checkpoint_id, checkpoint_storage)

# Handle initial message
elif message is not None:
# Seed start-executor input for a new turn (alone or after restore).
if message is not None:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: Support checkpoint hydration and new input in a single workflow run

2 participants