Power of Teams: Multi-Agent Collaboration π€
Why use one giant model when you can build a team of small, highly specialized local agents?
Single agents hit a ceiling fast. Their context windows get crowded, their reasoning gets muddy, and fixing them becomes a debugging nightmare.
This is especially true for local 1-7B parameter models. A 3B model is too small to be a master researcher, writer, database admin, and coder all at once.
But what if you split those roles among specialized agents and let them work as a Team? π€
A Team coordinates multiple specialized agents (and sub-teams) to tackle complex tasks. A leader agent coordinates the request and delegates sub-tasks to members based on their designated expertise.
πΊοΈ Visualizing Team Structure
Here's how a team divides labor under a leader:
π οΈ Code: Building a Local Team
Here's how to build a translation team consisting of English, Chinese, and German specialists running locally:
1from kern.team import Team2from kern.agent import Agent3from kern.models.openai import OpenAIChat45# Connect to local Ollama server π»6local_model = OpenAIChat(id="llama3.2:3b", base_url="http://localhost:11434/v1")78translator_team = Team(9 name="Global Translation Agency",10 members=[11 Agent(12 name="English Translator",13 model=local_model,14 role="English localization expert",15 instructions="Translate inputs accurately into natural English.",16 ),17 Agent(18 name="Chinese Translator",19 model=local_model,20 role="Chinese localization expert",21 instructions="Translate inputs accurately into natural Chinese.",22 ),23 Agent(24 name="German Translator",25 model=local_model,26 role="German localization expert",27 instructions="Translate inputs accurately into natural German.",28 ),29 ]30)3132# Run the team! The coordinator will delegate tasks to the appropriate members. π33translator_team.print_response("Translate the welcome message: 'Welcome to Kern, your local agent engine!' into German and Chinese", stream=True)βοΈ Why use Teams?
| Benefit | How it helps (especially for Local Models!) |
|---|---|
| Domain Specialization π§ | Each agent focuses on a narrow prompt, making 3B models behave like domain experts. |
| Parallel Execution β‘ | Independent sub-tasks run concurrently, speeding up total runtimes. |
| Easy Maintenance π οΈ | If the German translation breaks, you only edit the German translator agent, not the whole pipeline. |
| Smarter Context Control π | Individual context histories stay clean instead of cluttering a single giant chat context. |
βοΈ Team Modes: How Leaders Collaborate
Kern offers three collaboration topologies via TeamMode. You choose how the team leader delegates tasks to members:
TeamMode.coordinate(Default): The leader acts as a project manager, dynamically chatting with members, collecting reports, and synthesizing the final answer.TeamMode.broadcast: The leader sends the user query to all members simultaneously, gathers their outputs, and aggregates them. Great for comparison or multi-language translations!TeamMode.route: The leader acts as a router, forwarding the query to the single most relevant agent who then responds directly.
1from kern.team import Team, TeamMode23team = Team(4 name="Quick Research Team",5 members=[...],6 mode=TeamMode.broadcast, # Broadcast query to all members π’7)