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:

Rendering diagram...

πŸ› οΈ 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 Team
2from kern.agent import Agent
3from kern.models.openai import OpenAIChat
4
5# Connect to local Ollama server πŸ’»
6local_model = OpenAIChat(id="llama3.2:3b", base_url="http://localhost:11434/v1")
7
8translator_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)
31
32# 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?

BenefitHow 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:

  1. TeamMode.coordinate (Default): The leader acts as a project manager, dynamically chatting with members, collecting reports, and synthesizing the final answer.
  2. 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!
  3. 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, TeamMode
2
3team = Team(
4 name="Quick Research Team",
5 members=[...],
6 mode=TeamMode.broadcast, # Broadcast query to all members πŸ“’
7)

πŸ“š Guides & Next Steps