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:
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
Constructor Arguments
TeamPipeline takes the following arguments:
Each member is described by a
TeamMember with these fields:
Assign Tasks
On its first run, the pipeline registers an external tool namedTeamAssign 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.
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
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.