Get started with Agno through 12 essential examples covering agents, tools, memory, workflows, and teams.
Welcome to the Agno quickstart guide! These examples will get you up and running with the core concepts of the framework. Each example builds on the previous one, showing you how to create increasingly powerful AI agents.
Your first Agno agent: a data-driven financial analyst that retrieves market data and delivers insights.
This example shows how to give an agent tools to interact with external data sources.
agent_with_tools.py
from agno.agent import Agentfrom agno.models.google import Geminifrom agno.tools.yfinance import YFinanceToolsinstructions = """You are a Finance Agent — a data-driven analyst who retrieves market data,computes key ratios, and produces concise, decision-ready insights.## Workflow1. Clarify: Identify tickers from company names (e.g., Apple → AAPL)2. Retrieve: Fetch price, change %, market cap, P/E, EPS, 52-week range3. Analyze: Compute ratios, identify key drivers and risks4. Present: Lead with a one-line summary, use tables for comparisons"""agent_with_tools = Agent( name="Agent with Tools", model=Gemini(id="gemini-3-flash-preview"), instructions=instructions, tools=[YFinanceTools(all=True)], add_datetime_to_context=True, markdown=True,)if __name__ == "__main__": agent_with_tools.print_response( "Give me a quick investment brief on NVIDIA", stream=True )
Try these prompts:
“What’s Apple’s current valuation? Is it expensive?”
“Compare Google and Microsoft as investments”
“Show me key metrics for the top AI stocks: NVDA, AMD, GOOGL, MSFT”
Memory persists user preferences across all conversations.
agent_with_memory.py
from agno.agent import Agentfrom agno.db.sqlite import SqliteDbfrom agno.memory import MemoryManagerfrom agno.models.google import Geminifrom agno.tools.yfinance import YFinanceToolsagent_db = SqliteDb(db_file="tmp/agents.db")memory_manager = MemoryManager( model=Gemini(id="gemini-3-flash-preview"), db=agent_db, additional_instructions=""" Capture the user's favorite stocks, their risk tolerance, and their investment goals. """,)user_id = "[email protected]"agent_with_memory = Agent( name="Agent with Memory", model=Gemini(id="gemini-3-flash-preview"), instructions=instructions, tools=[YFinanceTools(all=True)], db=agent_db, memory_manager=memory_manager, enable_agentic_memory=True, add_datetime_to_context=True, add_history_to_context=True, num_history_runs=5, markdown=True,)if __name__ == "__main__": # Tell the agent about yourself agent_with_memory.print_response( "I'm interested in AI and semiconductor stocks. My risk tolerance is moderate.", user_id=user_id, stream=True, ) # The agent now knows your preferences agent_with_memory.print_response( "What stocks would you recommend for me?", user_id=user_id, stream=True, )
Memory vs Storage
Storage: “What did we discuss?” (conversation history)Memory: “What do you know about me?” (user preferences)Memory persists across sessions and is linked to a specific user_id.
Manage persistent state like watchlists, counters, or flags.
agent_with_state.py
from agno.agent import Agentfrom agno.run import RunContextfrom agno.models.google import Geminifrom agno.tools.yfinance import YFinanceToolsdef add_to_watchlist(run_context: RunContext, ticker: str) -> str: """Add a stock ticker to the watchlist.""" ticker = ticker.upper().strip() watchlist = run_context.session_state.get("watchlist", []) if ticker in watchlist: return f"{ticker} is already on your watchlist" watchlist.append(ticker) run_context.session_state["watchlist"] = watchlist return f"Added {ticker} to watchlist. Current watchlist: {', '.join(watchlist)}"instructions = """You are a Finance Agent that manages a stock watchlist.## Current Watchlist{watchlist}## Capabilities1. Manage watchlist: use add_to_watchlist and remove_from_watchlist tools2. Get stock data: use YFinance tools to fetch prices for watched stocks"""agent_with_state = Agent( name="Agent with State Management", model=Gemini(id="gemini-3-flash-preview"), instructions=instructions, tools=[add_to_watchlist, YFinanceTools(all=True)], session_state={"watchlist": []}, add_session_state_to_context=True, markdown=True,)if __name__ == "__main__": agent_with_state.print_response( "Add NVDA, AAPL, and GOOGL to my watchlist", stream=True, ) agent_with_state.print_response( "How are my watched stocks doing today?", stream=True, )
Write custom tools to extend your agent’s capabilities.
custom_tools.py
import jsonfrom datetime import datetime, timezonefrom agno.knowledge import Knowledge# Any function can become a tooldef save_learning(title: str, learning: str) -> str: """ Save a reusable insight to the knowledge base for future reference. Args: title: Short descriptive title learning: The insight to save — be specific and actionable Returns: Confirmation message """ payload = { "title": title.strip(), "learning": learning.strip(), "saved_at": datetime.now(timezone.utc).isoformat(), } learnings_kb.insert( name=payload["title"], text_content=json.dumps(payload, ensure_ascii=False), skip_if_exists=True, ) return f"Saved: '{title}'"self_learning_agent = Agent( name="Self-Learning Agent", model=Gemini(id="gemini-3-flash-preview"), tools=[ YFinanceTools(all=True), save_learning, # Your custom tool! ], knowledge=learnings_kb, search_knowledge=True,)
from agno.agent import Agentfrom agno.team import Teamfrom agno.models.google import Geminifrom agno.tools.yfinance import YFinanceTools# Bull Agent — makes the case FOR investingbull_agent = Agent( name="Bull Analyst", role="Make the investment case FOR a stock", model=Gemini(id="gemini-3-flash-preview"), tools=[YFinanceTools(all=True)], instructions="Find the positives: growth drivers, competitive advantages, strong financials.",)# Bear Agent — makes the case AGAINST investingbear_agent = Agent( name="Bear Analyst", role="Make the investment case AGAINST a stock", model=Gemini(id="gemini-3-flash-preview"), tools=[YFinanceTools(all=True)], instructions="Find the risks: valuation concerns, competitive threats, weak spots.",)# Team Leader coordinates and synthesizesmulti_agent_team = Team( name="Investment Research Team", model=Gemini(id="gemini-3-flash-preview"), members=[bull_agent, bear_agent], instructions=""" Send the stock to BOTH analysts, let each make their case independently, then synthesize into a balanced recommendation. """, show_members_responses=True, markdown=True,)if __name__ == "__main__": multi_agent_team.print_response( "Should I invest in NVIDIA (NVDA)?", stream=True, )
from agno.agent import Agentfrom agno.workflow import Step, Workflowfrom agno.models.google import Geminifrom agno.tools.yfinance import YFinanceTools# Step 1: Data Gathererdata_agent = Agent( name="Data Gatherer", model=Gemini(id="gemini-3-flash-preview"), tools=[YFinanceTools(all=True)], instructions="Fetch comprehensive market data. Don't analyze — just gather.",)# Step 2: Analystanalyst_agent = Agent( name="Analyst", model=Gemini(id="gemini-3-flash-preview"), instructions="Interpret the metrics, identify strengths and weaknesses.",)# Step 3: Report Writerreport_agent = Agent( name="Report Writer", model=Gemini(id="gemini-3-flash-preview"), instructions="Synthesize into a concise investment brief. Max 200 words.", markdown=True,)sequential_workflow = Workflow( name="Stock Research Pipeline", description="Data → Analysis → Report", steps=[ Step(name="Data Gathering", agent=data_agent), Step(name="Analysis", agent=analyst_agent), Step(name="Report Writing", agent=report_agent), ],)if __name__ == "__main__": sequential_workflow.print_response( "Analyze NVIDIA (NVDA) for investment", stream=True, )
Workflow vs Team
Workflow: Explicit step order, predictable execution, clear data flowTeam: Dynamic collaboration, leader decides who does whatUse Workflow when steps must happen in a specific order. Use Team when agents need to collaborate dynamically.