> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Output Variables

> Pass values between tasks with output_variable

An `output_variable` names a task's result so later tasks can read it.

> [!NOTE]
>
> Available under `PraisonAIAgents` / `AgentTeam` as of PraisonAI [PR #4907](https://github.com/MervinPraison/PraisonAI/pull/4907). Earlier releases only exposed `output_variable` inside the standalone `Workflow` engine and its YAML syntax. PraisonAI [#4932](https://github.com/MervinPraison/PraisonAI/pull/4932) fixed the parallel-branch case, where an `output_variable` set inside `parallel([...])` was previously discarded.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    A[🔍 Task A] -->|output_variable=research| S[📦 variables]
    S -->|{{research}}| B[✍️ Task B]

    classDef task fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef store fill:#6366F1,stroke:#7C90A0,color:#fff

    class A,B task
    class S store
```

## Quick Start

**1. Store one task's output**

Name the result with `output_variable`.

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent, Task

researcher = Agent(name="Researcher", instructions="Research the topic and list key facts.")

research = Task(
    name="research",
    action="Research renewable energy trends",
    agent=researcher,
    output_variable="research_data",
)
```

**2. Read it in the next task**

Reference the stored value with `{{research_data}}` in a later task's `action`.

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent, Task, PraisonAIAgents

writer = Agent(name="Writer", instructions="Write a short report.")

report = Task(
    action="Write a report using {{research_data}}",
    agent=writer,
    context=[research],
)

PraisonAIAgents(
    agents=[researcher, writer],
    tasks=[research, report],
).start()
```

***

## How It Works

After any task completes — agent or handler — its raw output is stored under the given name in the team's shared variables.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    T[✅ Task done] --> V[📦 variables&#91;name&#93; = output]
    V --> N[▶️ Next task reads it]

    classDef task fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef store fill:#6366F1,stroke:#7C90A0,color:#fff

    class T,N task
    class V store
```

***

## Reading Variables

Substitute a stored value directly in `action` or `description` with `{{name}}`.

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent, Task

writer = Agent(name="Writer", instructions="Write a report.")

Task(action="Summarise {{research_data}} in three bullets", agent=writer)
```

Read the same value inside a handler or `should_run` with `ctx.variables["name"]`.

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Task

def summarise(ctx):
    return {"summary": ctx.variables["research_data"][:200]}

Task(name="summarise", handler=summarise)
```

***

## Inside parallel blocks

An `output_variable` set inside a `parallel([...])` branch is visible to every step after the block, keyed by that exact name.

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import AgentFlow, Task, WorkflowContext, StepResult, parallel

def score_a(ctx: WorkflowContext) -> StepResult:
    return StepResult(output="9")

def score_b(ctx: WorkflowContext) -> StepResult:
    return StepResult(output="7")

compare = Task(action="Compare {{branch_a_score}} and {{branch_b_score}}")

workflow = AgentFlow(steps=[
    parallel([
        Task(name="branch_a", handler=score_a, output_variable="branch_a_score"),
        Task(name="branch_b", handler=score_b, output_variable="branch_b_score"),
    ]),
    compare,
])
workflow.start("go")
```

If two branches use the same `output_variable`, the later-declared branch wins and a warning is logged — give them distinct names. See [Named outputs from branches](https://praison.ai/docs/features/workflow-parallel.md#named-outputs-from-branches) for the full merge rule.

***

## Best Practices

> [accordion] Name variables for what they hold
>
> Use clear names like `research_data` or `score` so downstream `{{name}}` references read naturally.

> [accordion] Set output\_variable on the producing task
>
> Attach `output_variable` to the task that creates the value, not the one that reads it.

> [accordion] Order dependent tasks with context
>
> Pass `context=[producer_task]` on the consumer so the team runs them in the right order.

***

## Related

> [card] [Handler Tasks](https://praison.ai/docs/features/handler-tasks.md)
>
> Run Python code as a task step

> [card] [Conditions](https://praison.ai/docs/features/conditions.md)
>
> Gate tasks with should\_run

> [card] [Workflows](https://praison.ai/docs/features/workflows.md)
>
> Chain agents into pipelines


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.