Reasoning Team
Build a reasoning team that handles complex queries by combining web search, financial data, and transparent analytical thinking. This example demonstrates how reasoning tools make the team's decision-making process visible.
What You'll Learn
By building this team, you'll understand:
- How to integrate reasoning tools for transparent analytical thinking
- How to combine multiple specialized agents with different data sources
- How to use domain-specific search with Exa for financial information
- How to stream reasoning events to see the team's thought process in real-time
Use Cases
Build financial research platforms, investment analysis tools, market intelligence systems, or decision support applications.
How It Works
The team coordinates specialized agents with transparent reasoning:
- Analyze: Team leader uses reasoning tools to plan the approach
- Search: Web agent finds general information using DuckDuckGo
- Research: Finance agent retrieves financial data from trusted sources
- Synthesize: Team combines findings with visible reasoning process
- Present: Outputs structured data with supporting logic
Reasoning tools provide transparency into how the team thinks through complex queries.
Code
1from kern.agent import Agent2from kern.models.anthropic import Claude3from kern.models.openai import OpenAIResponses4from kern.team import Team5from kern.tools.duckduckgo import DuckDuckGoTools6from kern.tools.reasoning import ReasoningTools7from kern.tools.exa import ExaTools89web_agent = Agent(10 name="Web Search Agent",11 role="Handle web search requests",12 model=OpenAIResponses(id="gpt-5.2"),13 tools=[DuckDuckGoTools()],14 instructions=["Always include sources"],15)1617finance_agent = Agent(18 name="Finance Agent",19 role="Handle financial data requests",20 model=OpenAIResponses(id="gpt-5.2"),21 tools=[22 ExaTools(23 include_domains=["cnbc.com", "reuters.com", "bloomberg.com", "wsj.com"],24 show_results=True,25 text=False,26 highlights=False,27 )28 ],29 instructions=["Use tables to display data"],30)3132team_leader = Team(33 name="Reasoning Team Leader",34 model=Claude(id="claude-sonnet-4-5"),35 members=[36 web_agent,37 finance_agent,38 ],39 tools=[ReasoningTools(add_instructions=True)],40 markdown=True,41 show_members_responses=True,42)4344team_leader.print_response(45 "Tell me 1 company in New York, 1 in San Francisco and 1 in Chicago and the stock price of each",46 stream=True,47 show_full_reasoning=True,48)What to Expect
The team will research companies and stock prices by coordinating between web search and financial data agents. You'll see the reasoning process as the team plans its approach, delegates tasks, and synthesizes information.
The output includes visible thinking through reasoning tools, showing how the team decides which agent to use and how to combine their findings. Financial data is presented in tables with sources from trusted financial news outlets.
Usage
Set up your virtual environment
1uv venv --python 3.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateSet your API keys
1export OPENAI_API_KEY=xxx2export ANTHROPIC_API_KEY=xxx3export EXA_API_KEY=xxxInstall dependencies
1uv pip install -U kern-ai openai anthropic ddgs exa-pyRun Team
1python reasoning_team.py1python reasoning_team.pyNext Steps
- Modify the query to research different types of companies or markets
- Adjust
include_domainsin ExaTools to focus on specific financial sources - Toggle
show_full_reasoningto control visibility of the thinking process - Explore Reasoning Tools for advanced analytical capabilities