Registry / llm-agents / llama-index-workflows

llama-index-workflows

JSON →
library2.23.3pypypi✓ verified 25d ago

LlamaIndex Workflows is an event-driven, async-first, step-based framework designed to control the execution flow of AI applications, especially agents. It allows developers to build complex, multi-step processes by orchestrating various components, including Large Language Models (LLMs) and external APIs, and to maintain state across different steps. The library is currently at version 2.17.3 and undergoes frequent updates to enhance features and improve performance. [1, 7, 25, 26]

pip install llama-index-workflows
INSTALL
IMPORT
SIG · LLAMA-INDEX-WORKFL
L
llama-index-workflows
llm-agentspythonv2.23.3
Install
4.2s avg
Import
891ms
Disk
28MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.23.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.922s · 30.3MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 4.2s · import 0.860s · 30MB
28MB installed
● package 28MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Workflow
from workflows import Workflow
from llama_index.workflows import Workflow
When installing `llama-index-workflows` directly (the standalone package), core classes are imported from the top-level `workflows` package. If using `llama-index-core` which re-exports Workflows, use `from llama_index.core.workflow import Workflow`.
step
from workflows import step
Decorator to mark an async function as a workflow step.
Context
from workflows import Context
WorkflowEvent
from workflows.events import WorkflowEvent
from llama_index.workflows.events import WorkflowEvent
Similar to `Workflow`, event classes for the standalone package are imported from `workflows.events`.
StartEvent
from workflows.events import StartEvent
Special event class to initiate a workflow run.
StopEvent
from workflows.events import StopEvent
Special event class to signal the completion of a workflow run.

This quickstart demonstrates a simple event-driven workflow to generate and refine a joke using an LLM. It defines custom event types, creates asynchronous steps with the `@step` decorator, registers them with a `Workflow` instance, and then runs the workflow by emitting a `StartEvent`. The example uses OpenAI as the LLM provider, requiring `llama-index-llms-openai` and an `OPENAI_API_KEY` environment variable. [5, 7, 8]

import asyncio import os from pydantic import BaseModel, Field from workflows import Context, Workflow, step from workflows.events import WorkflowEvent, StartEvent, StopEvent from llama_index.core.llms import LLM from llama_index.llms.openai import OpenAI # Ensure llama-index-llms-openai is installed # Define custom event types for the workflow class JokeTopicEvent(WorkflowEvent): topic: str = Field(description="The topic for the joke.") class JokeEvent(WorkflowEvent): joke: str = Field(description="The generated joke.") class CritiqueEvent(WorkflowEvent): joke: str = Field(description="The original joke.") critique: str = Field(description="The critique of the joke.") class FinalJokeEvent(WorkflowEvent): final_joke: str = Field(description="The final, refined joke.") async def main(): # Initialize an LLM (requires OPENAI_API_KEY environment variable) llm = OpenAI(model="gpt-4o-mini", api_key=os.environ.get("OPENAI_API_KEY", "")) # Create a Workflow instance workflow = Workflow() # Define workflow steps using the @step decorator @step async def generate_joke(ctx: Context, event: JokeTopicEvent): print(f"[Step] Generating joke about: {event.topic}") response = await llm.complete(f"Tell me a short joke about {event.topic}.") return JokeEvent(joke=response.text) @step async def critique_joke(ctx: Context, event: JokeEvent): print(f"[Step] Critiquing joke: {event.joke}") response = await llm.complete(f"Critique this joke and suggest an improvement: '{event.joke}'") return CritiqueEvent(joke=event.joke, critique=response.text) @step async def refine_joke(ctx: Context, event: CritiqueEvent): print(f"[Step] Refining joke based on critique: {event.critique}") response = await llm.complete(f"Original joke: '{event.joke}'\nCritique: '{event.critique}'\nRefine the joke based on the critique to make it funnier or clearer.") return FinalJokeEvent(final_joke=response.text) # Register steps with the workflow workflow.add_step(generate_joke) workflow.add_step(critique_joke) workflow.add_step(refine_joke) print("Starting workflow to generate and refine a joke...") # Trigger the initial event to start the workflow events_stream = workflow.run(StartEvent(payload=JokeTopicEvent(topic="dogs"))) # Process events as they arrive async for event in events_stream: if isinstance(event, FinalJokeEvent): print(f"\n[Final Result] {event.final_joke}") break elif isinstance(event, StopEvent): print(f"\n[Workflow Stopped] {event.result}") break else: print(f"[Event Emitted] {event.__class__.__name__}: {event.payload}") if __name__ == "__main__": # Ensure OPENAI_API_KEY is set for the example to run correctly # For local testing without a real key, you can set a dummy key to bypass initialization errors # but LLM calls will fail without a valid key. if not os.environ.get("OPENAI_API_KEY"): print("WARNING: OPENAI_API_KEY environment variable not set. LLM calls will fail.") asyncio.run(main())
Debug
Known issues
breakingLlamaIndex Workflows became a standalone package (v1.0), deprecating older in-tree workflow-like implementations within `llama-index` itself (pre-0.11). Users migrating from `Query Pipelines` or older internal `AgentRunner`/`AgentWorker` classes in `llama-index.core.agent` must refactor their code to use the new `workflows` package structure. [1, 6, 14, 17, 22]
fix
Install `llama-index-workflows` and update imports to `from workflows import ...` or `from llama_index.core.workflow import ...` if using the `llama-index-core` re-export. Consult migration guides for `Query Pipelines` to `Workflows`.
affects: <1.0.0 (of `llama-index-workflows`) and <0.11.0 (of `llama-index`)
gotchaLlamaIndex Workflows are designed as 'async-first'. This means all steps and the `run` method are asynchronous. Users running workflows in non-async environments (e.g., top-level scripts) need to wrap their execution with `asyncio.run()` or similar. In Jupyter/Colab, this is often handled, but direct script execution requires explicit async handling. [5, 9, 10]
fix
Ensure your workflow execution is within an `async` function and called with `asyncio.run()`: `async def main(): ...; if __name__ == "__main__": asyncio.run(main())`.
affects: All versions
gotchaError handling is critical for robust workflows. External API calls (like to LLMs), data validation, and network issues can cause `WorkflowRuntimeError`, `WorkflowTimeoutError`, or other exceptions. Workflows do not automatically snapshot state for recovery without explicit integration. [5, 16, 19]
fix
Implement `try-except` blocks around external calls, use retry libraries (e.g., `tenacity` or built-in retry policies for steps), perform input validation, and integrate with external databases (e.g., Redis) for manual state snapshotting and recovery for long-running processes.
affects: All versions
deprecatedThe `Query Pipelines` feature in `llama-index` was deprecated in favor of Workflows in LlamaIndex version 0.11. Existing code using `Query Pipelines` should be migrated. [6, 22]
fix
Refactor `Query Pipelines` logic into a `Workflow` using `@step` decorated functions and `WorkflowEvent`s.
affects: LlamaIndex <0.11.0
gotchaComplex workflows, especially those involving multiple LLM calls or external services, can experience high latency. Default configurations might not be optimized for performance. [18]
fix
Implement strategies like asynchronous operations, batch processing, pre-computing and caching embeddings, optimizing retrieval and reranking steps, and profiling code to identify and address bottlenecks. Leverage `asyncio` fully within workflow steps.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'llama_index.core.workflow'
This error often occurs when you try to import `llama_index.core.workflow` but have only installed the standalone `llama-index-workflows` package, or if there's a version mismatch between `llama-index-core` and `llama-index-workflows`.
fix
If you intend to use Workflows as part of `llama-index-core`, ensure you have `llama-index-core` installed (which includes workflows) and use `from llama_index.core.workflow import Workflow`. If you want to use the standalone workflows library, the import path is `from workflows import Workflow`. Ensure all `llama-index-*` packages are updated to compatible versions.
WorkflowRuntimeError: Error in step 'run_agent_step': LLM must be a FunctionCallingLLM
This error happens when an `AgentWorkflow` (specifically `FunctionAgent` internally) is configured to use an LLM that does not support function calling, but the workflow or agent logic expects it.
fix
Ensure the Large Language Model (LLM) provided to your `AgentWorkflow` or `FunctionAgent` is a function-calling model. If using a custom LLM, it must implement the `FunctionCallingLLM` class and have `llm.metadata.is_function_calling_model=True`. Alternatively, use a `ReactAgent` if your LLM doesn't support direct function calling, or integrate an `OpenAILike` LLM if your private server's API matches the OpenAI spec.
AttributeError: 'AgenticLLMWorkflow' object has no attribute '_sessions'
This `AttributeError` typically indicates a problem with the initialization or internal state management of the `AgenticLLMWorkflow` class, possibly due to version incompatibilities or specific environmental differences (e.g., local vs. server deployments). The `_sessions` attribute might not be properly defined or accessible at the point it's being called.
fix
Ensure all `llama-index-*` packages (including `core`, `workflows`, `agent`, etc.) are on compatible and up-to-date minor versions. Review the `AgenticLLMWorkflow`'s `__init__` method or its superclass (`Workflow`) to ensure `_sessions` or equivalent session management is correctly initialized across different environments.
WorkflowRuntimeError: Error in step 'run_agent_step': 'NoneType' object has no attribute 'automatic_function_calling_history'
This specific `WorkflowRuntimeError` suggests a critical dependency or context issue within an agent workflow, often related to mismatched package versions. A required object or attribute related to function calling history is `None` when it should have been initialized, preventing proper agent execution.
fix
Update all `llama-index-*` packages to their latest compatible versions to resolve potential dependency conflicts. Verify that the agent's memory and context operations are correctly set up and passed through the workflow, especially for async operations. Ensure the context is established before `automatic_function_calling_history` is accessed.
Upgrade
Version history
2.23.3latest on PyPI · released Aug 22, 2026
Audit
Dependencies
pydanticrequiredUsed for defining typed workflow events and state models.
llama-index-coreoptionalProvides core LlamaIndex functionalities like LLM abstractions. Workflows can be used standalone but often integrate with LlamaIndex components.
llama-index-llms-openaioptionalCommonly used LLM integration for examples and agentic workflows.
llama-index-instrumentationoptionalOptional integration for observability with tools like OpenTelemetry and Arize Phoenix.
Agent activity
44 hits · last 30 days
node
40
Amazon
1
OpenAI (training)
1
Resources
llama-index-workflows — pip install llama-index-workflows · libregistry