Skip to main content
TeamPipeline is a pipeline of one leader and several members: the leader assigns tasks to members through a tool call, each member works in its own context, and its final reply comes back to the leader as the tool result. The assignment flow looks like this:
Unlike the fixed loop of the Goal Pipeline, a team pipeline only fixes who can be assigned work and where the results go. Whom to assign, and how many times, is up to the leader. Its main properties are:
The pipeline module is experimental, and its interfaces may change in later releases.

Run the Pipeline

The following example builds a team of a leader, a researcher and a programmer, where the leader decides whom to assign each task to:
team_pipeline.py
When members need to collaborate through files, let them share one workspace, like the LocalWorkspace the researcher and programmer share above, so files one member produces can be read directly by another.

Constructor Arguments

TeamPipeline takes the following arguments: Each member is described by a TeamMember with these fields:
Member names must be unique and must differ from the leader’s name, otherwise the constructor raises ValueError.

Assign Tasks

On its first run, the pipeline registers an external tool named TeamAssign in the leader’s toolkit. Its parameters are: A full assignment goes through these steps:
1

The Leader Assigns

The leader calls TeamAssign with a member and a task. This tool skips permission checks; the member’s own tools are still checked under their own permissions.
2

The Member Works

The pipeline hands prompt to the member as a user message. The member runs in its own context, and its events stream out of the pipeline’s reply_stream.
3

The Result Returns

The member’s final reply (text and data blocks) goes back to the leader as the TeamAssign tool result. Results of several assignments in one round are ordered by the leader’s calls.
4

The Leader Continues

After reading the results, the leader keeps reasoning: it can assign again or give its final reply.
How a member’s reply ends determines the state of the tool result: reset_members decides what context members start the next assignment with. It defaults to True: within one leader reply, the leader can follow up with a member on the same matter; once the leader reply ends, every member’s context and summary are cleared, and assignments in the next reply start fresh. Set it to False to let members keep their conversations across replies.

Interrupt and Resume

When anyone in the team stops on a tool authorization, it is handled just like a single agent: reply_stream ends once every participant has finished or parked, and the developer feeds the answer back in to continue.
Resume after a pause
While a member is parked, the leader also waits on that assignment; once the member finishes, its reply comes back as the tool result and the leader continues. Members in the same round that did not park run to completion as usual, and results that are already finished reach the leader first. reply_stream accepts these inputs:
When the pipeline’s coroutine is cancelled, it closes the parked leader and members as if it had received a UserInterruptEvent, then re-raises the cancellation only if the leader’s interruption_raise_cancelled_error is set.