Examples
- Examples
- Getting Started
- Agents
- Teams
- Workflows
- Applications
- Streamlit Apps
- Evals
Agent Concepts
- Reasoning
- Agents
- Models
- Teams
- Tools
- Multimodal
- RAG
- User Control Flows
- Knowledge
- Memory
- Async
- Hybrid Search
- Storage
- Tools
- Vector Databases
- Context
- Embedders
- Agent State
- Observability
- Miscellaneous
Models
- Anthropic
- AWS Bedrock
- AWS Bedrock Claude
- Azure AI Foundry
- Azure OpenAI
- Cerebras
- Cerebras OpenAI
- Cohere
- DeepInfra
- DeepSeek
- Fireworks
- Gemini
- Groq
- Hugging Face
- IBM
- LM Studio
- LiteLLM
- LiteLLM OpenAI
- Meta
- Mistral
- NVIDIA
- Ollama
- OpenAI
- Perplexity
- Together
- XAI
- Vercel
Teams
Team with Knowledge Tools
This is a team reasoning example with knowledge tools.
Enabling the reasoning option on the team leader helps optimize delegation and enhances multi-agent collaboration by selectively invoking deeper reasoning when required.
Code
cookbook/reasoning/teams/knowledge_tool_team.py
from textwrap import dedent
from agno.agent import Agent
from agno.knowledge.url import UrlKnowledge
from agno.models.openai import OpenAIChat
from agno.team.team import Team
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.knowledge import KnowledgeTools
from agno.tools.yfinance import YFinanceTools
from agno.vectordb.lancedb import LanceDb, SearchType
agno_docs = UrlKnowledge(
urls=["https://www.paulgraham.com/read.html"],
# Use LanceDB as the vector database and store embeddings in the `agno_docs` table
vector_db=LanceDb(
uri="tmp/lancedb",
table_name="agno_docs",
search_type=SearchType.hybrid,
),
)
knowledge_tools = KnowledgeTools(
knowledge=agno_docs,
think=True,
search=True,
analyze=True,
add_few_shot=True,
)
web_agent = Agent(
name="Web Search Agent",
role="Handle web search requests",
model=OpenAIChat(id="gpt-4o-mini"),
tools=[DuckDuckGoTools()],
instructions="Always include sources",
add_datetime_to_instructions=True,
)
finance_agent = Agent(
name="Finance Agent",
role="Handle financial data requests",
model=OpenAIChat(id="gpt-4o-mini"),
tools=[
YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True)
],
add_datetime_to_instructions=True,
)
team_leader = Team(
name="Reasoning Finance Team",
mode="coordinate",
model=OpenAIChat(id="gpt-4o"),
members=[
web_agent,
finance_agent,
],
tools=[knowledge_tools],
instructions=[
"Only output the final answer, no other text.",
"Use tables to display data",
],
markdown=True,
show_members_responses=True,
enable_agentic_context=True,
add_datetime_to_instructions=True,
success_criteria="The team has successfully completed the task.",
debug_mode=True,
)
def run_team(task: str):
# Comment out after first run
agno_docs.load(recreate=True)
team_leader.print_response(
task,
stream=True,
stream_intermediate_steps=True,
show_full_reasoning=True,
)
if __name__ == "__main__":
run_team("What does Paul Graham talk about the need to read in this essay?")
Usage
1
Create a virtual environment
Open the Terminal
and create a python virtual environment.
python3 -m venv .venv
source .venv/bin/activate
2
Set your API key
export OPENAI_API_KEY=xxx
3
Install libraries
pip install -U openai agno
4
Run Example
python cookbook/reasoning/teams/knowledge_tool_team.py
Was this page helpful?
Assistant
Responses are generated using AI and may contain mistakes.