Skip to main content
Build a team where the leader selects which members to delegate to based on the task.
1

Create the team

coordinate_team.py
import asyncio
from definable.agent import Agent
from definable.agent.team import Team, TeamMode

researcher = Agent(
    model="gpt-4o",
    instructions="You are a research specialist. Find facts, data, and sources.",
)
writer = Agent(
    model="gpt-4o",
    instructions="You are a technical writer. Write clear, well-structured content.",
)
editor = Agent(
    model="gpt-4o",
    instructions="You are an editor. Polish prose, fix errors, improve clarity.",
)

team = Team(
    name="content-team",
    model="gpt-4o",
    members=[researcher, writer, editor],
    mode=TeamMode.coordinate,
    instructions="Produce well-researched, polished technical articles.",
)

async def main():
    result = await team.arun("Write a 500-word article about AI agents in production.")
    print(result.content)

asyncio.run(main())
2

Install dependencies

pip install definable
3

Export your API key

export OPENAI_API_KEY=sk-***
4

Run

python coordinate_team.py
The leader delegates to the researcher first, passes findings to the writer, then sends the draft to the editor.