Python: [BREAKING] consolidate workflow run APIs (#1723)

* consolidate workflow run apis

* improve validation, add tests

* Proper code tags for docs

* Update sample output

* Remove cycle validation

* PR feedback

* Validation

* Cleanup
This commit is contained in:
Evan Mattson
2025-11-04 08:34:59 +09:00
committed by GitHub
Unverified
parent b0ee7028a6
commit 50d9b13bfc
26 changed files with 722 additions and 477 deletions
@@ -250,7 +250,7 @@ async def run_interactive_session(
event_stream = workflow.run_stream(initial_message)
elif checkpoint_id:
print("\nStarting workflow from checkpoint...\n")
event_stream = workflow.run_stream_from_checkpoint(checkpoint_id)
event_stream = workflow.run_stream(checkpoint_id)
else:
raise ValueError("Either initial_message or checkpoint_id must be provided")
@@ -47,7 +47,7 @@ What you learn:
- How to configure FileCheckpointStorage and call with_checkpointing on WorkflowBuilder.
- How to list and inspect checkpoints programmatically.
- How to interactively choose a checkpoint to resume from (instead of always resuming
from the most recent or a hard-coded one) using run_stream_from_checkpoint.
from the most recent or a hard-coded one) using run_stream.
- How workflows complete by yielding outputs when idle, not via explicit completion events.
Prerequisites:
@@ -281,7 +281,7 @@ async def main():
new_workflow = create_workflow(checkpoint_storage=checkpoint_storage)
print(f"\nResuming from checkpoint: {chosen_cp_id}")
async for event in new_workflow.run_stream_from_checkpoint(chosen_cp_id, checkpoint_storage=checkpoint_storage):
async for event in new_workflow.run_stream(checkpoint_id=chosen_cp_id, checkpoint_storage=checkpoint_storage):
print(f"Resumed Event: {event}")
"""
@@ -356,7 +356,7 @@ async def main() -> None:
workflow2 = build_parent_workflow(storage)
request_info_event: RequestInfoEvent | None = None
async for event in workflow2.run_stream_from_checkpoint(
async for event in workflow2.run_stream(
resume_checkpoint.checkpoint_id,
):
if isinstance(event, RequestInfoEvent):