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

> ## Agent Instructions
> For AgentScope Python, use https://docs.agentscope.io/stable/en/index for new projects. For existing projects, check the installed agentscope version and use matching versioned documentation.
> The /latest/ alias points to the newest documentation and may move ahead of /stable/ when a development version exists. Do not mix AgentScope 1.x and 2.x APIs.
> State the AgentScope version when providing installation commands or code examples. ReMe uses its own continuously updated /reme/latest/ documentation.

# Overview

> Run several agents by a fixed logic behind a single interface

A pipeline composes several agents: the developer settles their order and the conditions that move work between them before the run starts, and nothing changes it afterwards. To a caller it looks exactly like one agent, taking inputs and streaming events back.

A pipeline takes on three things:

| Responsibility | What it means |
| - | - |
| Fixed logic | Who goes first, what sends work back, how many rounds are allowed: all settled when the pipeline is built, never left to the model |
| One event stream | Every event from every agent inside leaves through the same `reply_stream` |
| Human interaction | When an agent stops for tool authorization the pipeline ends the stream instead of suspending, and hands the answer back to whichever agent was waiting |

> [!TIP]
>
> Every agent's events leave through the same `reply_stream`. A developer rendering them needs `reply_id` to tell which agent an event belongs to; it matches that agent's `agent.state.reply_id`.

> [!NOTE]
>
> The pipeline module is experimental. Its interfaces may change in later releases.

## Interface

`PipelineProtocol` names one capability: take inputs, stream events.

```python PipelineProtocol theme={null}
class PipelineProtocol(Protocol):
    def reply_stream(
        self,
        inputs: Msg
        | list[Msg]
        | UserConfirmResultEvent
        | UserInterruptEvent
        | ExternalExecutionResultEvent,
    ) -> AsyncGenerator[AgentEvent | Msg, None]:
        """Reply to the inputs and stream what happens."""
```

`Agent` already satisfies it, an agent being a pipeline of one. So a pipeline goes wherever an agent goes:

```python Accepting either theme={null}
async def watch(target: Agent | PipelineProtocol, inputs) -> None:
    # Both are driven the same way, with nothing to branch on
    async for event in target.reply_stream(inputs):
        print(event)
```

`launch_console` in the [console](https://docs.agentscope.io/en/versions/2.0.11/building-blocks/console.md) was widened this way, so a developer can hand a pipeline straight to the terminal.

## Implementations

AgentScope ships two pipelines so far:

| Class | Arrangement |
| - | - |
| [`GoalPipeline`](https://docs.agentscope.io/en/versions/2.0.11/building-blocks/pipeline/goal) | An executor produces, a verifier judges, a refusal goes back with its reason, until the work passes or the attempts run out |
| [`TeamPipeline`](https://docs.agentscope.io/en/versions/2.0.11/building-blocks/pipeline/team) | A leader assigns tasks to members through tool calls, and each member's final reply comes back to the leader as the tool result |

## Further Reading

> **[Goal Pipeline](https://docs.agentscope.io/en/versions/2.0.11/building-blocks/pipeline/goal.md)**
>
> Keep an executor working until a verifier accepts the result.

> **[Team Pipeline](https://docs.agentscope.io/en/versions/2.0.11/building-blocks/pipeline/team.md)**
>
> Let a leader coordinate specialized agents to accomplish complex tasks together.

> **[Console](https://docs.agentscope.io/en/versions/2.0.11/building-blocks/console.md)**
>
> Run a pipeline in the terminal and answer its authorization prompts.

> **[Planning](https://docs.agentscope.io/en/versions/2.0.11/building-blocks/plan.md)**
>
> Let the model keep its own task list, which pipelines complement.

> **[Human in the Loop](https://docs.agentscope.io/en/versions/2.0.11/building-blocks/agent/human-in-the-loop.md)**
>
> Authorize tools and resume after an interruption on a single agent.


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