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

# Sequential Workflow

> Linear step chains where each step receives the previous step's output.

The simplest workflow pattern. Steps execute in order, each receiving context from the previous step.

```python theme={null}
from definable.agent import Agent
from definable.agent.workflow import Workflow, Step

researcher = Agent(model="gpt-4o", instructions="Research the given topic thoroughly.")
writer = Agent(model="gpt-4o", instructions="Write a clear article based on the research provided.")
editor = Agent(model="gpt-4o", instructions="Polish and improve the article.")

workflow = Workflow(
    name="content-pipeline",
    steps=[
        Step(name="research", agent=researcher),
        Step(name="write", agent=writer),
        Step(name="edit", agent=editor),
    ],
)

result = await workflow.arun("The future of AI agents")
print(result.content)  # Final edited article
```

## How It Works

1. `research` step receives the original input ("The future of AI agents").
2. `write` step receives the researcher's output as context.
3. `edit` step receives the writer's output as context.
4. `result.content` contains the editor's final output.

## Using Steps (Explicit Sequential)

For clarity, you can use the `Steps` wrapper:

```python theme={null}
from definable.agent.workflow import Workflow, Steps, Step

workflow = Workflow(
    name="pipeline",
    steps=[
        Steps(steps=[
            Step(name="research", agent=researcher),
            Step(name="write", agent=writer),
        ]),
        Step(name="edit", agent=editor),
    ],
)
```

## Custom Input Building

Override how context is passed between steps:

```python theme={null}
def build_writer_input(ctx):
    research = ctx.get_step_content("research")
    return f"Based on this research, write a 500-word article:\n\n{research}"

Step(name="write", agent=writer, input_builder=build_writer_input)
```
