Drop Workflow.reset(); checkpointing is the recovery path

The in-flight-messages guard prevented silent misbehavior, but the
companion Workflow.reset() escape hatch only cleared _messages while
leaving iteration count, executor-local state, and shared State
mutations in an indeterminate condition after a mid-run failure. That
gave a false sense of recovery.

Recovery from a mid-run failure is supported only via checkpoint
restoration. Keep the guard and reframe its error message accordingly;
remove reset() and its tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
alliscode
2026-04-28 13:29:01 -07:00
Unverified
parent 8252ec6fb2
commit 62150df256
2 changed files with 6 additions and 48 deletions
@@ -960,8 +960,8 @@ async def test_workflow_run_inflight_messages_guard(simple_executor: Executor) -
calls. If a prior run aborted before the runner drained those pending
messages (e.g. it raised :class:`WorkflowConvergenceException`), the next
fresh-message call should fail loudly instead of silently mixing the
leftover messages with the new turn. Callers can recover via
:meth:`Workflow.reset`.
leftover messages with the new turn. The supported recovery path is to
resume from a checkpoint; there is no in-process recovery hatch.
"""
workflow = WorkflowBuilder(start_executor=simple_executor).add_edge(simple_executor, simple_executor).build()
test_message = WorkflowMessage(data="test", source_id="test", target_id=None)
@@ -977,25 +977,6 @@ async def test_workflow_run_inflight_messages_guard(simple_executor: Executor) -
async for _ in workflow.run(test_message, stream=True):
pass
# ``Workflow.reset`` is the documented escape hatch.
await workflow.reset()
assert not await workflow._runner.context.has_messages()
# After reset, a new run is accepted again.
result = await workflow.run(test_message)
assert result.get_final_state() == WorkflowRunState.IDLE
async def test_workflow_reset_rejects_concurrent_runs(simple_executor: Executor) -> None:
"""``Workflow.reset`` must not stomp on an in-progress run."""
workflow = WorkflowBuilder(start_executor=simple_executor).add_edge(simple_executor, simple_executor).build()
workflow._is_running = True
try:
with pytest.raises(RuntimeError, match="run is in progress"):
await workflow.reset()
finally:
workflow._is_running = False
async def test_workflow_run_parameter_validation(simple_executor: Executor) -> None:
"""Test that stream properly validate parameter combinations."""