Open
Description
Bug Description
When running the workflow (code listed in Steps to reproduce) in stepwise mode, one of the steps didn't work.
But when I run the workflows as always (with .run()
) it works.
I knew something was off! Hope this time I didn't make a mistake.
Version
0.12.25
Steps to Reproduce
Diagram:
import asyncio
from typing import Optional
from llama_index.core.workflow import Context, Event, StartEvent, StopEvent, Workflow, step
class EventA(Event):
pass
class EventB(Event):
pass
class TestWorkflow(Workflow):
@step
async def start(self, ev: StartEvent) -> EventA:
return EventA()
@step
async def make_b(self, ev: EventA) -> EventB:
return EventB()
@step
async def finish(self, ctx: Context, evs: EventA | EventB) -> Optional[StopEvent]:
got = ctx.collect_events(evs, [EventA, EventB])
if not got:
return None
return StopEvent()
async def main():
w = TestWorkflow(verbose=True)
await w.run()
asyncio.run(main())
When run in step-wise mode:
async def main():
w = TestWorkflow(verbose=True)
handler = w.run(stepwise=True)
while produced_events := await handler.run_step():
for ev in produced_events:
handler.ctx.send_event(ev)
print("Awaiting results")
result = await handler
print("Finished")
asyncio.run(main())
Produces these logs that are in the specialized section of the issue.
But when run simply with .run()
, everything is perfect:
Running step start
Step start produced event EventA
Running step finish
Step finish produced no event
Running step make_b
Step make_b produced event EventB
Running step finish
Step finish produced event StopEvent
Relevant Logs/Tracebacks
Running step start
Step start produced event EventA
Running step finish
Step finish produced no event
Running step make_b
Step make_b produced event EventB
Awaiting results
Exception in callback Dispatcher.span.<locals>.wrapper.<locals>.handle_future_result()() at [REDACTED]/.venv/lib/python3.13/site-packages/llama_index/core/instrumentation/dispatcher.py:274
handle: <Handle Dispatcher.span.<locals>.wrapper.<locals>.handle_future_result()() at [REDACTED]/.venv/lib/python3.13/site-packages/llama_index/core/instrumentation/dispatcher.py:274>
Traceback (most recent call last):
File "/usr/lib/python3.13/asyncio/events.py", line 89, in _run
self._context.run(self._callback, *self._args)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "[REDACTED]/.venv/lib/python3.13/site-packages/llama_index/core/instrumentation/dispatcher.py", line 286, in handle_future_result
raise exception
File "[REDACTED]/.venv/lib/python3.13/site-packages/llama_index/core/workflow/workflow.py", line 401, in _run_workflow
raise WorkflowTimeoutError(msg)
llama_index.core.workflow.errors.WorkflowTimeoutError: Operation timed out after 10.0 seconds
Traceback (most recent call last):
File "[REDACTED]/test.py", line 56, in <module>
asyncio.run(main())
~~~~~~~~~~~^^^^^^^^
File "/usr/lib/python3.13/asyncio/runners.py", line 195, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "/usr/lib/python3.13/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/usr/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "[REDACTED]/test.py", line 43, in main
result = await handler
^^^^^^^^^^^^^
File "[REDACTED]/.venv/lib/python3.13/site-packages/llama_index/core/workflow/workflow.py", line 401, in _run_workflow
raise WorkflowTimeoutError(msg)
llama_index.core.workflow.errors.WorkflowTimeoutError: Operation timed out after 10.0 seconds