Create multi-agent teams with execution modes and delegation.
To build a team, create member agents and compose them under a Team with an execution mode.
content_team.py
from definable.agent import Agentfrom definable.agent.team import Team, TeamModeresearcher = Agent(model="gpt-4o", instructions="You are a research specialist. Find facts and data.")writer = Agent(model="gpt-4o", instructions="You are a technical writer. Write clear, accurate content.")editor = Agent(model="gpt-4o", instructions="You are an editor. Polish prose and fix errors.")team = Team( name="content-team", model="gpt-4o", members=[researcher, writer, editor], mode=TeamMode.coordinate, instructions="Produce well-researched, polished technical content.",)result = await team.arun("Write about the state of AI agents in 2026.")print(result.content)
Run Your Team
1
Set up your environment
python3 -m venv .venvsource .venv/bin/activate
python -m venv .venv.venv\Scripts\activate
uv venv --python 3.12source .venv/bin/activate
2
Install Definable
pip install definable
uv pip install definable
poetry add definable
3
Export your API key
export OPENAI_API_KEY=sk-***
setx OPENAI_API_KEY sk-***
4
Run
python content_team.py
Constructor Reference
str
Human-readable team name. Auto-generated if not set.
str | Model
Model for the leader agent. Accepts string shorthand ("gpt-4o") or a Model instance.
List[Agent | Team]
Agents or nested teams the leader can delegate to.
TeamMode
default:"coordinate"
Execution mode: coordinate, route, collaborate, or tasks.
str
Instructions for the leader agent.
int
default:"10"
Maximum delegation rounds (relevant for tasks mode).
bool
default:"false"
When true, member responses are shared with subsequent delegations.
List[Function]
Additional tools for the leader (on top of auto-injected delegation tools).
Type[BaseModel]
Pydantic model for structured output from the leader.