Team Tools
Equip team members with specialized tools for collaborative workflows.
While a single agent can use tools, cramming too many tools into a small model's prompt can confuse it.
With Teams, you can split your tools across highly specialized agents. When the team leader receives a task, it automatically determines which team member has the right tools for the job and delegates accordingly. 🤝
🛠️ Equipping Team Members
To give a team tools, you simply provide the tools directly to the member Agents. The Team coordinator will analyze the user's request and assign sub-tasks to the agents with the appropriate tools.
Here is an example of a research team where one agent searches the web and the other calculates numbers:
1from kern.agent import Agent2from kern.team import Team3from kern.models.openai import OpenAIChat4from kern.tools.duckduckgo import DuckDuckGo5from kern.tools.python import PythonTools67local_model = OpenAIChat(id="llama3.2:3b", base_url="http://localhost:11434/v1")89# 1. Equip the researcher with search tools 🔍10researcher = Agent(11 name="Researcher",12 role="Web search specialist",13 model=local_model,14 tools=[DuckDuckGo()],15 instructions="Search the web for the latest information on the topic.",16)1718# 2. Equip the calculator with math tools 🧮19calculator = Agent(20 name="Calculator",21 role="Math specialist",22 model=local_model,23 tools=[PythonTools()],24 instructions="Write and execute python to solve math problems.",25)2627# 3. Form the team! The coordinator handles delegation automatically.28research_team = Team(29 name="Research Squad",30 members=[researcher, calculator],31)3233research_team.print_response(34 "Search for the current population of Tokyo and Paris, then calculate the difference.", 35 stream=True36)⚙️ How Delegation Works
When you run a team, the coordinator agent handles the heavy lifting:
- Analysis: The coordinator reads the user's prompt and analyzes the roles and toolsets of its members.
- Delegation: It generates a plan and delegates the first sub-task (e.g. "search for population") to the agent equipped with the web search tool.
- Execution: The specialized agent executes the tool and reports back.
- Handoff: The coordinator passes the results to the next agent (e.g. "calculate the difference") who uses its Python tools to run the math.
- Synthesis: The coordinator combines all tool outputs into a final, coherent response for the user.
By spreading tools across a team, you keep each individual agent's system prompt small and focused. This is critical for maximizing the reasoning capabilities of 1-7B parameter models! 🧠