run-llama/llama_index · error · ValueError

No runs found in workflow

Error message

No runs found in workflow

What it means

Raised by draw_most_recent_execution when the workflow object has no recorded execution contexts (workflow._contexts is empty). The function renders the most recent run by replaying accepted events from a stored context, so it can only be called after the workflow has actually run at least once. With zero contexts there is nothing to draw.

Source

Thrown at llama-index-core/llama_index/core/workflow/drawing.py:98

    notebook: bool = False,
) -> None:
    """Draws the most recent execution of the workflow."""
    from importlib.metadata import version
    from packaging.version import Version

    if Version(version("workflows")) >= Version("2.9.0"):
        raise ValueError(
            "draw_most_recent_execution function is deprecated and no longer works with the installed version of `workflows`. Install `llama-index-utils-workflow` and use the draw_most_recent_execution import `from llama_index.utils.workflow` instead."
        )

    from pyvis.network import Network

    net = Network(directed=True, height="750px", width="100%")

    # Add nodes and edges based on execution history
    existing_context = next(iter(workflow._contexts), None)  # type: ignore
    if existing_context is None:
        raise ValueError("No runs found in workflow")

    accepted_events = existing_context._accepted_events  # type: ignore
    for i, (step, event) in enumerate(accepted_events):
        event_node = f"{event}_{i}"
        step_node = f"{step}_{i}"
        net.add_node(
            event_node, label=event, color="#90EE90", shape="ellipse"
        )  # Light green for events
        net.add_node(
            step_node, label=step, color="#ADD8E6", shape="box"
        )  # Light blue for steps
        net.add_edge(event_node, step_node)

        if i > 0:
            prev_step_node = f"{accepted_events[i - 1][0]}_{i - 1}"
            net.add_edge(prev_step_node, event_node)

    net.show(filename, notebook=notebook)

View on GitHub (pinned to afd0fef371)

Solutions

  1. Run the workflow at least once (await/complete workflow.run(...)) before calling draw_most_recent_execution
  2. Verify the instance you are drawing is the same instance that was run, not a newly constructed one
  3. If a run fails before recording a context, fix the run failure first, then draw

Example fix

// before
wf = MyWorkflow()
draw_most_recent_execution(wf)  # ValueError: No runs found in workflow

// after
wf = MyWorkflow()
await wf.run()  # record at least one execution
draw_most_recent_execution(wf)
Defensive patterns

Strategy: validation

Validate before calling

def has_runs(workflow) -> bool:
    contexts = getattr(workflow, "_contexts", None)
    return bool(contexts)

Try / catch

try:
    draw_most_recent_execution(wf)
except ValueError as e:
    if "No runs found" in str(e):
        logger.info("workflow has not run yet; skipping draw")
    else:
        raise

Prevention

When it happens

Trigger: Calling draw_most_recent_execution(workflow) before ever calling workflow.run(...) on that workflow instance; calling it on a freshly constructed Workflow whose _contexts collection is still empty (next(iter(workflow._contexts), None) returns None).

Common situations: Notebook prototyping where the draw call is placed above the first workflow.run cell; drawing a new workflow instance after refactoring code so the previously-run instance is out of scope; drawing after a run that raised before a context was retained.

Related errors


AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15). Data as JSON: /api/errors/8ed993a67e2d701e. Report an issue: GitHub.