{"record":{"id":"8ed993a67e2d701e","repo":"run-llama/llama_index","slug":"no-runs-found-in-workflow","errorCode":null,"errorMessage":"No runs found in workflow","messagePattern":"No runs found in workflow","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/workflow/drawing.py","lineNumber":98,"sourceCode":"    notebook: bool = False,\n) -> None:\n    \"\"\"Draws the most recent execution of the workflow.\"\"\"\n    from importlib.metadata import version\n    from packaging.version import Version\n\n    if Version(version(\"workflows\")) >= Version(\"2.9.0\"):\n        raise ValueError(\n            \"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.\"\n        )\n\n    from pyvis.network import Network\n\n    net = Network(directed=True, height=\"750px\", width=\"100%\")\n\n    # Add nodes and edges based on execution history\n    existing_context = next(iter(workflow._contexts), None)  # type: ignore\n    if existing_context is None:\n        raise ValueError(\"No runs found in workflow\")\n\n    accepted_events = existing_context._accepted_events  # type: ignore\n    for i, (step, event) in enumerate(accepted_events):\n        event_node = f\"{event}_{i}\"\n        step_node = f\"{step}_{i}\"\n        net.add_node(\n            event_node, label=event, color=\"#90EE90\", shape=\"ellipse\"\n        )  # Light green for events\n        net.add_node(\n            step_node, label=step, color=\"#ADD8E6\", shape=\"box\"\n        )  # Light blue for steps\n        net.add_edge(event_node, step_node)\n\n        if i > 0:\n            prev_step_node = f\"{accepted_events[i - 1][0]}_{i - 1}\"\n            net.add_edge(prev_step_node, event_node)\n\n    net.show(filename, notebook=notebook)","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/workflow/drawing.py#L80-L116","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Run the workflow at least once (await/complete workflow.run(...)) before calling draw_most_recent_execution","Verify the instance you are drawing is the same instance that was run, not a newly constructed one","If a run fails before recording a context, fix the run failure first, then draw"],"exampleFix":"// before\nwf = MyWorkflow()\ndraw_most_recent_execution(wf)  # ValueError: No runs found in workflow\n\n// after\nwf = MyWorkflow()\nawait wf.run()  # record at least one execution\ndraw_most_recent_execution(wf)","handlingStrategy":"validation","validationCode":"def has_runs(workflow) -> bool:\n    contexts = getattr(workflow, \"_contexts\", None)\n    return bool(contexts)","typeGuard":null,"tryCatchPattern":"try:\n    draw_most_recent_execution(wf)\nexcept ValueError as e:\n    if \"No runs found\" in str(e):\n        logger.info(\"workflow has not run yet; skipping draw\")\n    else:\n        raise","preventionTips":["Always await workflow.run(...) to completion before drawing","Draw from the same workflow instance that executed, not a re-created one","In notebooks, order cells: run first, draw second"],"tags":["workflow","visualization","state-validation","python"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}