Python: Support checkpoint hydration and new input in a single workflow run (#7863) - #7910
Shivani . (Shivani767) wants to merge 1 commit into
Conversation
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.
There was a problem hiding this comment.
Pull request overview
Adds single-call checkpoint hydration plus new input for Python workflows.
Changes:
- Supports
messagewithcheckpoint_idin 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.
| *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*. |
| 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: |
|
We appreciate you taking this on, Shivani . (@Shivani767). This is going to require some deeper design from the team first, before we go and work on the implementation. Closing so I can take this over. |
|
Understood — Evan Mattson (@moonbox3)'s note on #7863 says any community PRs for this will be closed so the MAF team can own the design, so I am not opening a replacement for #7910. Leaving the design with you. When the design does land, these were the two things worth carrying over from this attempt: 1. Don't restore the step replay cache on a message-plus-checkpoint run. 2. Ordering: restore must complete before fresh-turn bookkeeping, with message seeding after restore. In the graph workflow the combined path restored after Also worth noting for whoever implements it: Happy to rebase this sample/tests against the team's implementation, or to review, when it is ready — just ping me here or on #7863. |
Motivation & Context
Resuming a multi-turn workflow from a persisted checkpoint previously required two
workflow.runcalls: 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?
Workflow.run(message=..., checkpoint_id=...)(and the functional-workflow mirror): restore/validate first, then seed start-executor input in the same run.checkpoint_idis present, because restore replaces the runner context before the new message is applied.WorkflowAgent’s restore-then-run path into oneworkflow.runwhen both checkpoint and input are provided (HITL usesresponses+checkpoint_id; idle turns usemessage+checkpoint_id).responses); clarify the branch comments.python/samples/03-workflows/checkpoint/checkpoint_hydrate_with_input.py.What is the impact of these changes?
checkpoint_id+responsesremain supported.What do you want reviewers to focus on?
WorkflowAgentpeekingcheckpoint.pending_request_info_eventsis the right HITL vs idle discriminator.Related Issue
Fixes #7863
Related: #7809
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.