#2 CRITICAL: Sleep/resume mechanism marks sleeping tasks as executed - workflows skip event waiting

closed critical Created 2025-11-24 22:56 · Updated 2025-11-24 23:03

Description

Edit
## Bug Description Workflows using wait_for_event (including approval tool) complete immediately without actually waiting for the event. The sleep/resume mechanism incorrectly marks sleeping tasks as 'executed' which causes dependent tasks to run prematurely. ## Root Cause Analysis From logs analysis: 1. Task enters sleep correctly: - Task wait_for_approval entering sleep state - Marked sleeping task wait_for_approval as executed before sleep <-- BUG - Event not yet emitted, propagating sleep error - Task entering SLEEPING state 2. On next execution/poll, the interpreter sees: - Start task already executed (resume), finding ready tasks - Found ready task: log_result, deps=[wait_for_approval] - Processing ready task: log_result, executed_tasks={send_email, wait_for_approval} 3. The sleeping task wait_for_approval is in executed_tasks even though event was NEVER received ## Expected Behavior - Sleeping tasks should remain in sleeping state, NOT executed - On resume, check if event was received before considering task complete - Dependent tasks should NOT run until sleeping task event is received ## Affected Code - engine/interpreters/inline_executor.py (WorkflowInterpreter sleep handling) - engine/durable_context.py (wait_for_event implementation) - engine/tools/approval_tool.py (uses wait_for_event) ## Impact - ALL workflows using wait_for_event are broken - Human approval workflows complete without waiting - Event coordination between parallel branches broken - Data integrity risk: workflows proceed without required approval ## Reproduction 1. Submit examples/email_approval_test.py workflow 2. Observe workflow completes immediately 3. Check logs: approval_result is None ## Fix Strategy 1. Track sleeping tasks separately from executed tasks 2. On resume, check checkpoint for sleeping tasks and event status 3. Only mark task executed AFTER event received and task completes 4. Add sleeping state to task tracking alongside executed

Comments

Loading comments...

Context

Loading context...

Audit History

View All
Loading audit history...