エージェントに外部サービスと連携するためのツールを提供します。エージェントは HackerNewsTools を使用して、話題の記事やユーザーの詳細情報を取得します。
Agno 再入門 : SDK – 基本 : エージェント – 使用方法 (ツール, 構造化出力, ストレージ, メモリ, ナレッジ)
作成 : クラスキャット・セールスインフォメーション
作成日時 : 06/16/2026
バージョン : v2.6.16
* 本記事は docs.agno.com の以下のページを参考にしています :
- SDK – Basics : Agents – Usage : Agent with Tools
- SDK – Basics : Agents – Usage : Agent with Structured Output
- SDK – Basics : Agents – Usage : Agent with Storage
- SDK – Basics : Agents – Usage : Agent with Memory
- SDK – Basics : Agents – Usage : Agent with Knowledge
* サンプルコードの動作確認はしておりますが、必要な場合には適宜、追加改変しています。

Agno 再入門 : SDK – 基本 : エージェント – 使用方法 (ツールを備えたエージェント)
エージェントに外部サービスと連携するためのツールを提供します。エージェントは HackerNewsTools を使用して、話題の記事やユーザーの詳細情報を取得します。
- Python ファイルの作成
tools.py
from agno.agent import Agent from agno.models.anthropic import Claude from agno.tools.hackernews import HackerNewsTools agent = Agent( model=Claude(id="claude-sonnet-4-5"), tools=[HackerNewsTools()], instructions="Write a report on the topic.", markdown=True, ) agent.print_response("Trending AI startups on Hacker News", stream=True) - 仮想環境のセットアップ
uv venv --python 3.12 source .venv/bin/activate - 依存関係のインストール
uv pip install -U agno anthropic - Anthropic API キーのエクスポート
export ANTHROPIC_API_KEY="your_anthropic_api_key_here" - エージェントの実行
python tools.py
出力例
┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ Trending AI startups on Hacker News ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Tool Calls ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ • get_top_hackernews_stories(num_stories=30) ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Response (39.7s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ I'll fetch the top stories from Hacker News to identify trending AI startups for you.# Trending AI ┃
┃ Startups on Hacker News ┃
┃ ┃
┃ Based on the current top stories on Hacker News, here are the trending AI-related startups and ┃
┃ projects: ┃
┃ ┃
┃ Featured AI Startups ┃
┃ ┃
┃ 1. Drafted (YC P26) - AI Models for Residential Architecture ┃
┃ ┃
┃ • Website: drafted.ai ┃
┃ • Description: Drafted is training AI models that generate residential architecture from structured ┃
┃ design constraints ┃
┃ • Key Features: ┃
┃ • Generates complete floor plans and exterior elevations in seconds ┃
┃ • Allows users to design homes using simple inputs (square footage, footprint shapes, lot ┃
┃ boundaries, room placement) ┃
┃ • Offers 2D and 3D visualization ┃
┃ • Exports CAD, PDF, and other files for construction ┃
┃ • New capability to draw custom footprint shapes and generate complete home layouts ┃
┃ • Traction: Over 120,000 users in the past month, generating 325,000+ home designs ┃
┃ • Score: 52 points | 55 comments ┃
┃ ┃
┃ 2. Cohere - First Developer-Focused Model ┃
┃ ┃
┃ • Announcement: "North Mini Code" - Cohere's first model specifically for developers ┃
┃ • Score: 62 points | 15 comments ┃
┃ • Context: Cohere continues to compete in the enterprise AI space with specialized models ┃
┃ ┃
┃ 3. GrassDx - AI Lawn Diagnosis Platform ┃
┃ ┃
┃ • Website: grassdx.com ┃
┃ • Description: AI-powered lawn care diagnosis tool created by a veterinarian turned founder ┃
┃ • Key Features: ┃
┃ • Upload lawn pictures and get diagnosis in 15 seconds ┃
┃ • Location-specific recommendations based on ZIP code ┃
┃ • Completely free to use ┃
┃ • Monetized through affiliate sales and exclusive ZIP code rights for lawn care companies ┃
┃ • Score: 55 points | 51 comments ┃
┃ ┃
┃ AI-Related Discussions ┃
┃ ┃
┃ Local AI Models for Coding (858 points, 395 comments) ┃
┃ ┃
┃ A highly engaged discussion asking: "Has anyone replaced Claude/GPT with a local model for daily ┃
┃ coding?" ┃
┃ ┃
┃ • This reflects growing interest in self-hosted AI solutions ┃
┃ • Developers are exploring alternatives to commercial AI services ┃
┃ • Focus on performance metrics (tokens/second) and practical usage ┃
┃ ┃
┃ Homelab AI Dev Platform (289 points, 52 comments) ┃
┃ ┃
┃ • Community member shared their personal AI development platform setup ┃
┃ • Growing trend of developers building custom AI infrastructure at home ┃
┃ • Interest in self-hosted AI solutions continues to increase ┃
┃ ┃
┃ Intelligence Explosion Discussion (37 points, 82 comments) ┃
┃ ┃
┃ • Article from The Economist: "Humanity isn't ready for the coming intelligence explosion" ┃
┃ • Philosophical and practical discussions about AI's rapid advancement ┃
┃ ┃
┃ AI Coding Review Economics (51 points, 40 comments) ┃
┃ ┃
┃ • Article: "Reviews have become expensive, rewrites have become cheap" ┃
┃ • Discusses how AI is changing software development economics ┃
┃ • Code review vs. AI-assisted rewriting trade-offs ┃
┃ ┃
┃ Key Trends Observed ┃
┃ ┃
┃ 1 Vertical AI Applications: Startups are focusing on specific industries (architecture, lawn care) ┃
┃ rather than general-purpose AI ┃
┃ 2 Self-Hosted AI Movement: Strong community interest in running local AI models instead of cloud ┃
┃ services ┃
┃ 3 AI-Powered Design Tools: Multiple startups using AI for creative and design work ┃
┃ 4 Developer Tools: Continued focus on AI coding assistants and development platforms ┃
┃ 5 Accessibility: New AI tools emphasizing ease of use and free access to attract users ┃
┃ ┃
┃ Notable Acquisitions ┃
┃ ┃
┃ Salesforce to Acquire Fin (formerly Intercom) for $3.6B (300 points, 219 comments) ┃
┃ ┃
┃ • While not a pure AI startup announcement, this acquisition highlights the value of AI-powered ┃
┃ customer service platforms ┃
┃ • Demonstrates continued consolidation in the AI-powered business tools space ┃
┃ ┃
┃ ---------------------------------------------------------------------------------------------------- ┃
┃ ┃
┃ Summary: The Hacker News community is showing strong interest in practical AI applications, ┃
┃ particularly in niche verticals like architecture and home services. There's also significant ┃
┃ discussion around local AI models and self-hosted solutions, suggesting a maturing market where ┃
┃ developers are looking beyond major cloud providers. The startups gaining traction are those that ┃
┃ solve specific, tangible problems rather than offering general-purpose AI capabilities. ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Agno 再入門 : SDK – 基本 : エージェント – 使用方法 (構造化出力を備えたエージェント)
自由形式のテキストではなく、型付きの Pydantic レスポンスを取得します。
output_schema を使用すると、信頼できる構造化された型付きレスポンスを取得できます。エージェントは自由形式のテキストではなく、Pydantic モデルを返します。
structured_output.py
from typing import List, Optional
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.yfinance import YFinanceTools
from pydantic import BaseModel, Field
class StockAnalysis(BaseModel):
ticker: str = Field(..., description="Stock ticker symbol")
company_name: str = Field(..., description="Full company name")
current_price: float = Field(..., description="Current price in USD")
pe_ratio: Optional[float] = Field(None, description="P/E ratio")
summary: str = Field(..., description="One-line summary")
key_drivers: List[str] = Field(..., description="2-3 key growth drivers")
key_risks: List[str] = Field(..., description="2-3 key risks")
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
tools=[YFinanceTools()],
output_schema=StockAnalysis,
)
response = agent.run("Analyze NVIDIA stock")
# Access typed data directly
analysis: StockAnalysis = response.content
print(f"{analysis.company_name} ({analysis.ticker})")
print(f"Price: ${analysis.current_price}")
print(f"P/E Ratio: {analysis.pe_ratio or 'N/A'}")
print(f"Summary: {analysis.summary}")
print("Key Drivers:")
for driver in analysis.key_drivers:
print(f" - {driver}")
print("Key Risks:")
for risk in analysis.key_risks:
print(f" - {risk}")
出力例
NVIDIA Corporation (NVDA)
Price: $212.45
P/E Ratio: N/A
Summary: NVIDIA is the leading supplier of AI compute accelerators and related software, with performance driven primarily by hyperscale and enterprise AI infrastructure spending.
Key Drivers:
- Sustained demand for data-center GPUs (H100/H200 and newer platforms) and high attach of networking (InfiniBand/Ethernet) as AI clusters scale.
- Software/platform monetization and ecosystem lock-in (CUDA, inference stacks, enterprise AI, and developer tooling) that supports pricing power and repeat demand.
- Expanding AI use-cases beyond training (inference at scale, agentic workloads, edge/robotics, and industry vertical solutions) that broaden TAM over time.
Key Risks:
- Cyclicality or pause in AI capex (hyperscalers optimizing utilization, digestion periods, or macro-driven budget cuts) leading to revenue volatility.
- Competitive and architectural pressure (AMD/Intel accelerators, custom ASICs/TPUs, and open software stacks) that could reduce share or compress margins.
- Geopolitical/export controls and supply-chain constraints affecting shipments, product mix, and access to key markets.
Agno 再入門 : SDK – 基本 : エージェント – 使用方法 (ストレージを備えたエージェント)
実行間で会話履歴を永続化します。
ストレージ機能により、エージェントは会話内容を記憶できます。同じ session_id を使用すれば、再起動後でも前回中断したところから会話を再開できます。
agent_with_storage.py
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
from agno.tools.yfinance import YFinanceTools
db = SqliteDb(db_file="tmp/agents.db")
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
tools=[YFinanceTools()],
db=db,
add_history_to_context=True,
num_history_runs=5,
markdown=True,
)
session_id = "finance-session"
# Turn 1: Analyze a stock
agent.print_response(
"Give me a quick analysis of NVIDIA",
session_id=session_id,
stream=True,
)
# Turn 2: The agent remembers NVDA from turn 1
agent.print_response(
"Compare that to AMD",
session_id=session_id,
stream=True,
)
# Turn 3: Ask based on full conversation
agent.print_response(
"Which looks like the better investment?",
session_id=session_id,
stream=True,
)
出力例
┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ Give me a quick analysis of NVIDIA ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Tool Calls ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ • get_current_stock_price(symbol=NVDA) ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Response (15.0s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ NVIDIA (NVDA) — quick analysis ┃
┃ ┃
┃ Current price: ~$212.45 (spot) ┃
┃ ┃
┃ What NVIDIA is ┃
┃ ┃
┃ NVIDIA is the leading supplier of GPUs and a core infrastructure provider for AI training/inference (data-center accelerators), plus software ┃
┃ (CUDA, AI frameworks) and networking (e.g., InfiniBand/Ethernet via Mellanox heritage). ┃
┃ ┃
┃ Bull case (why it can keep working) ┃
┃ ┃
┃ • AI infrastructure leader: Strong demand for data-center GPUs used in training frontier models and increasingly for inference at scale. ┃
┃ • Ecosystem moat: CUDA + developer tooling + libraries create high switching costs beyond just hardware performance. ┃
┃ • Platform expansion: Networking, interconnect, and full “AI factory” stacks (hardware + software) increase share of wallet and stickiness. ┃
┃ • Secular tailwinds: AI capex cycles across hyperscalers/enterprises are still building out. ┃
┃ ┃
┃ Bear case / key risks ┃
┃ ┃
┃ • Valuation & expectations: The stock can be sensitive to any sign of slowing growth or margin pressure because expectations are high. ┃
┃ • Customer concentration: Hyperscalers represent a large share of demand; capex digestion or timing shifts can create volatility. ┃
┃ • Competition: AMD, custom ASICs (TPUs, in-house accelerators), and emerging architectures could pressure share/pricing over time. ┃
┃ • Export controls/geopolitics: Restrictions on selling advanced chips into certain regions can limit addressable market and add uncertainty. ┃
┃ • Supply chain/execution: Any hiccup in advanced packaging, HBM memory supply, or product ramps can impact deliveries. ┃
┃ ┃
┃ What to watch near-term ┃
┃ ┃
┃ • Data-center revenue growth and gross margin trends (pricing power vs. mix and cost). ┃
┃ • Guidance: next-quarter and full-year outlook vs. buy-side expectations. ┃
┃ • Inference mix: signs that inference demand is broadening beyond training-heavy customers. ┃
┃ • Competitive signals: large customer wins/losses, commentary on ASIC substitution, and new product adoption. ┃
┃ ┃
┃ If you tell me your time horizon (weeks vs. years) and whether you’re looking at it as a trade or a long-term hold, I can tailor the analysis ┃
┃ to that. ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ Compare that to AMD ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Tool Calls ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ • get_current_stock_price(symbol=NVDA) ┃
┃ • get_current_stock_price(symbol=AMD) ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Response (17.2s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ NVDA vs. AMD — quick comparison (AI + semis) ┃
┃ ┃
┃ Current prices (spot): ┃
┃ ┃
┃ • NVDA: ~$212.45 ┃
┃ • AMD: ~$547.26 ┃
┃ ┃
┃ ▌ Note: price alone isn’t comparable across companies (share counts differ). Market cap/valuation multiples matter more. ┃
┃ ┃
┃ 1) Core positioning ┃
┃ ┃
┃ • NVIDIA (NVDA): The incumbent leader in AI data-center GPUs plus a deep software moat (CUDA) and strong networking/platform stack. ┃
┃ • AMD (AMD): Strong CPU business (server/client) and a growing GPU/accelerator push; competing in AI accelerators with MI-series and broader ┃
┃ platform offerings. ┃
┃ ┃
┃ 2) AI accelerators: who’s winning? ┃
┃ ┃
┃ • NVDA advantage: Best-known end-to-end stack (hardware + CUDA + libraries + tooling), broadest developer adoption, and historically fastest ┃
┃ ramps with hyperscalers. ┃
┃ • AMD opportunity: Competes on price/performance, openness (more flexibility vs. CUDA lock-in), and can win share where customers want a ┃
┃ second source or lower TCO—but software maturity and ecosystem breadth are the usual gating factors. ┃
┃ ┃
┃ 3) Software moat (big differentiator) ┃
┃ ┃
┃ • NVDA: CUDA ecosystem = major switching costs; often the default choice for model training and many inference deployments. ┃
┃ • AMD: ROCm has improved, but generally perceived as behind CUDA in tooling polish, compatibility, and “it just works” adoption—though this ┃
┃ gap can narrow over time. ┃
┃ ┃
┃ 4) Business diversification ┃
┃ ┃
┃ • NVDA: Heavily levered to data-center AI right now (plus gaming and pro viz). That concentration can be a strength in an AI boom, but ┃
┃ increases cyclicality if AI capex pauses. ┃
┃ • AMD: More balanced exposure via server CPUs (EPYC), client CPUs, and some embedded; AI accelerators are a key growth vector but typically a ┃
┃ smaller share than NVDA’s AI exposure. ┃
┃ ┃
┃ 5) Competitive landscape ┃
┃ ┃
┃ • NVDA risks: Customer in-housing (ASICs), AMD competition, and any platform shift away from CUDA-centric workflows. ┃
┃ • AMD risks: Execution on GPU roadmap and, especially, software enablement and developer/customer adoption at scale. ┃
┃ ┃
┃ 6) How to think about them as investments ┃
┃ ┃
┃ • NVDA tends to trade like “AI infrastructure beta” with premium expectations; upside if demand keeps surprising, downside if growth/margins ┃
┃ decelerate. ┃
┃ • AMD can be a “share gain + catch-up” story in AI GPUs plus steady CPU competitiveness; upside if accelerator adoption inflects and software ┃
┃ friction drops. ┃
┃ ┃
┃ What to watch (practical checklist) ┃
┃ ┃
┃ • NVDA: data-center growth rate, margins, supply (HBM/packaging), and any signs of capex digestion. ┃
┃ • AMD: MI-series revenue trajectory, major customer deployments, ROCm momentum, and EPYC share vs. Intel. ┃
┃ ┃
┃ If you want, I can compare them on a specific angle (AI inference vs training, server CPUs, valuation/multiples, or a 6–12 month catalyst ┃
┃ view). ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ Which looks like the better investment? ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Response (7.8s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ “Better investment” depends on what you’re optimizing for ┃
┃ ┃
┃ I can’t know your goals/risk tolerance, but here’s a practical way to choose between NVDA and AMD. ┃
┃ ┃
┃ If you want the higher-confidence AI leader: NVDA ┃
┃ ┃
┃ Why: NVIDIA has the clearest dominance in AI accelerators and the strongest software moat (CUDA), which tends to translate into pricing power, ┃
┃ stickier customers, and faster product adoption. ┃
┃ Main risk: Expectations/valuation sensitivity—if AI capex growth slows, the stock can re-rate quickly. ┃
┃ ┃
┃ NVDA tends to be “quality/leadership” exposure to AI infrastructure. ┃
┃ ┃
┃ If you want a potentially higher-upside “share-gain / catch-up” bet: AMD ┃
┃ ┃
┃ Why: AMD can win share in AI accelerators (MI-series) as customers diversify suppliers and optimize cost, and it also has meaningful strength ┃
┃ in server CPUs (EPYC). If AMD executes well and the software ecosystem friction declines, the upside can be significant. ┃
┃ Main risk: Execution + ecosystem risk—AMD must keep proving large-scale deployments and software maturity; otherwise uptake can lag. ┃
┃ ┃
┃ AMD tends to be “optionality” exposure: more paths to upside, but a wider range of outcomes. ┃
┃ ┃
┃ ----------------------------------------------------------------------------------------------------------------------------------------------- ┃
┃ ┃
┃ A simple decision rule ┃
┃ ┃
┃ • Choose NVDA if you prioritize moat + market leadership + execution certainty. ┃
┃ • Choose AMD if you prioritize potential multiple expansion / share gains and can tolerate more uncertainty. ┃
┃ ┃
┃ What would change my answer ┃
┃ ┃
┃ • If you’re long-term (3–5+ years) and want the most resilient AI platform: I’d usually lean NVDA. ┃
┃ • If you’re more valuation-sensitive and specifically believe AMD’s AI GPU adoption accelerates materially: AMD may offer better risk/reward. ┃
┃ ┃
┃ If you share (1) your horizon and (2) whether you can tolerate a 30–50% drawdown, I’ll give a clearer pick for your situation. ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Agno 再入門 : SDK – 基本 : エージェント – 使用方法 (メモリを備えたエージェント)
会話をまたいで永続化されるユーザーの設定を保存します。
メモリを使用すると、エージェントは会話をまたいでユーザーに関する情報を記憶できます。ストレージ(会話履歴の永続化)とは異なり、メモリは好みやコンテキストなどのユーザーレベルの情報を保存します。
agent_with_memory.py
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.memory import MemoryManager
from agno.models.openai import OpenAIResponses
from agno.tools.yfinance import YFinanceTools
from rich.pretty import pprint
db = SqliteDb(db_file="tmp/agents.db")
memory_manager = MemoryManager(
model=OpenAIResponses(id="gpt-5.2"),
db=db,
)
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
tools=[YFinanceTools()],
db=db,
memory_manager=memory_manager,
enable_agentic_memory=True,
markdown=True,
)
user_id = "investor@example.com"
# Tell the agent about yourself
agent.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.print_response(
"What stocks would you recommend for me?",
user_id=user_id,
stream=True,
)
# View stored memories
memories = agent.get_user_memories(user_id=user_id)
print("\nStored Memories:")
pprint(memories)
出力例
┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ I'm interested in AI and semiconductor stocks. My risk tolerance is moderate. ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Tool Calls ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ • update_user_memory(task=Add user memory: User is interested in AI and semiconductor stocks and has a moderate risk tolerance.) ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Response (11.3s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ Noted. I’ll tailor stock-related discussions toward AI and semiconductor names with a moderate risk approach (i.e., emphasizing ┃
┃ diversification, position sizing, and avoiding overly speculative microcaps unless you ask). ┃
┃ ┃
┃ To calibrate recommendations, tell me: ┃
┃ ┃
┃ • Time horizon: months, 1–3 years, or 5+ years? ┃
┃ • Goal: growth vs. growth + some stability? ┃
┃ • Portfolio size / constraints: any max % per stock, or ETF-only vs. individual stocks? ┃
┃ • Any exclusions: e.g., no China ADRs, no options, no leverage? ┃
┃ ┃
┃ If you share those, I can suggest a watchlist structure (e.g., core ETFs + a few higher-conviction single names) aligned to moderate risk. ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ What stocks would you recommend for me? ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Response (13.4s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ A practical stock shortlist (moderate risk; AI + semiconductors tilt) ┃
┃ ┃
┃ I can’t know what’s suitable for you without a bit more context, but based on your stated interests (AI + semis) and moderate risk tolerance, ┃
┃ here are high-quality “core + satellites” ideas you can research. (Not financial advice.) ┃
┃ ┃
┃ 1) Core “safer” AI/compute infrastructure ┃
┃ ┃
┃ These tend to be more diversified and resilient than single-product names. ┃
┃ ┃
┃ • MSFT (Microsoft) — Broad AI distribution (Copilot), cloud (Azure), strong cash flows. ┃
┃ • GOOGL (Alphabet) — AI models + massive data + cloud; attractive relative to mega-cap peers at times. ┃
┃ • AMZN (Amazon) — AWS is a major AI beneficiary (training/inference demand), plus diversified businesses. ┃
┃ ┃
┃ 2) Semiconductor “core” (AI picks-and-shovels) ┃
┃ ┃
┃ Higher cyclicality than software, but key beneficiaries of AI capex. ┃
┃ ┃
┃ • NVDA (NVIDIA) — Leader in AI accelerators + software ecosystem; great business, but valuation and cycle risk. ┃
┃ • TSM (TSMC) — Foundry backbone for advanced chips; critical exposure to AI demand across the industry. ┃
┃ • ASML (ASML) — Essential lithography tools; near-monopoly in EUV, long-term secular demand. ┃
┃ ┃
┃ 3) Semiconductor “satellites” (more volatile, more idiosyncratic) ┃
┃ ┃
┃ Add only if you want a bit more risk/return potential. ┃
┃ ┃
┃ • AVGO (Broadcom) — AI networking + custom silicon + strong cash generation (also M&A/portfolio complexity). ┃
┃ • AMD (AMD) — Competing in GPUs/CPUs; execution matters, more “share-gain” uncertainty vs NVDA. ┃
┃ • AMAT or LRCX (Applied Materials / Lam Research) — Chip equipment exposure; cyclical but levered to capex. ┃
┃ ┃
┃ 4) If you want simpler diversification: ETFs ┃
┃ ┃
┃ Good if you don’t want single-stock risk. ┃
┃ ┃
┃ • SOXX / SMH — Broad semiconductor exposure. ┃
┃ • QQQ — Mega-cap tech heavy; indirect AI beneficiaries. ┃
┃ ┃
┃ ----------------------------------------------------------------------------------------------------------------------------------------------- ┃
┃ ┃
┃ A simple way to structure it (fits “moderate risk”) ┃
┃ ┃
┃ • 60–80% “core” (e.g., MSFT/GOOGL/AMZN + TSM/ASML) ┃
┃ • 20–40% “satellites” (e.g., NVDA/AVGO/AMD/equipment) ┃
┃ Or replace most single names with SOXX/SMH + a couple of convictions. ┃
┃ ┃
┃ ----------------------------------------------------------------------------------------------------------------------------------------------- ┃
┃ ┃
┃ Quick questions so I can tailor recommendations to you ┃
┃ ┃
┃ 1 Time horizon: 1–3 years, 3–7, or 7+? ┃
┃ 2 Account type: taxable vs IRA/401(k)? ┃
┃ 3 Concentration: are you comfortable with 5–8 stocks, or prefer ETFs? ┃
┃ 4 Any constraints: avoid China/Taiwan geopolitical exposure, avoid mega-caps, dividend focus, etc. ┃
┃ 5 Rough portfolio size and how much you plan to add monthly? ┃
┃ ┃
┃ Answer those and I’ll propose a tighter list (with suggested % weights and a simple “buy plan” like DCA vs staged entries). ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Stored Memories:
[
│ UserMemory(
│ │ memory='User is interested in AI and semiconductor stocks and has a moderate risk tolerance.',
│ │ memory_id='daf02d16-1da4-4e76-b67a-57baa21344ae',
│ │ topics=['interests', 'finance', 'risk_tolerance'],
│ │ user_id='investor@example.com',
│ │ input='Add user memory: User is interested in AI and semiconductor stocks and has a moderate risk tolerance.',
│ │ created_at=1781597673,
│ │ updated_at=1781597673,
│ │ feedback=None,
│ │ agent_id=None,
│ │ team_id=None
│ )
]
Agno 再入門 : SDK – 基本 : エージェント – 使用方法 (ナレッジを備えたエージェント)
エージェントに検索可能なナレッジベースを提供します (Agentic RAG)。
ナレッジベースは、エージェントが実行時に検索できる情報を提供します。このパターンは Agentic RAG として知られています。エージェントは、ユーザーの質問に基づいて検索のタイミングを判断します。
agent_with_knowledge.py
from agno.agent import Agent
from agno.knowledge.embedder.openai import OpenAIEmbedder
from agno.knowledge.knowledge import Knowledge
from agno.models.openai import OpenAIResponses
from agno.vectordb.lancedb import LanceDb, SearchType
knowledge = Knowledge(
vector_db=LanceDb(
uri="tmp/lancedb",
table_name="recipes",
search_type=SearchType.hybrid,
embedder=OpenAIEmbedder(id="text-embedding-3-small"),
),
)
# Load a PDF into the knowledge base
knowledge.insert(
url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf",
)
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
knowledge=knowledge,
instructions="Search your knowledge base for Thai recipes. Be concise.",
markdown=True,
)
agent.print_response("How do I make Pad Thai?", stream=True)
agent.print_response("What ingredients do I need for green curry?", stream=True)
出力例
INFO Creating table: recipes
[2026-06-16T08:34:18Z WARN lance::dataset::write::insert] No existing dataset at /Users/masao/ws.agno26/usage/tmp/lancedb/recipes.lance, it will be created
INFO Adding content from URL https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf
WARNING Cannot create pdf reader: `pypdf` not installed. Please install it via `pip install pypdf`.
INFO No documents to insert
INFO Found 0 documents
┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ How do I make Pad Thai? ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Tool Calls ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ • search_knowledge_base(query=Pad Thai recipe ingredients steps) ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Response (14.8s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ Pad Thai (classic shrimp/tofu version) ┃
┃ ┃
┃ Ingredients (2 servings) ┃
┃ ┃
┃ • 150 g dried rice noodles (thin/medium), soaked per package ┃
┃ • 2–3 tbsp neutral oil ┃
┃ • 2 cloves garlic, minced ┃
┃ • 150–200 g shrimp or firm tofu (cubed) ┃
┃ • 2 eggs ┃
┃ • 1–2 cups bean sprouts ┃
┃ • 2–3 stalks garlic chives (or scallions), cut into 5 cm pieces ┃
┃ • 2–3 tbsp crushed roasted peanuts ┃
┃ • Lime wedges ┃
┃ ┃
┃ Pad Thai sauce ┃
┃ ┃
┃ • 2–3 tbsp tamarind paste/concentrate (to taste) ┃
┃ • 2 tbsp fish sauce (or soy sauce for vegetarian) ┃
┃ • 1–2 tbsp palm sugar or brown sugar ┃
┃ • 1–2 tsp chili flakes (optional) ┃
┃ ┃
┃ Steps ┃
┃ ┃
┃ 1 Make sauce: Warm tamarind + fish sauce + sugar (and chili) until sugar dissolves. Taste for sweet–sour–salty balance. ┃
┃ 2 Prep noodles: Soak until pliable (not mushy). Drain. ┃
┃ 3 Stir-fry protein: Heat wok/pan on high. Add oil, garlic, then shrimp/tofu; cook until done. Push to side. ┃
┃ 4 Scramble eggs: Add a little oil if needed, crack eggs in, scramble briefly. ┃
┃ 5 Noodles + sauce: Add drained noodles and sauce. Toss and fry, adding small splashes of water if dry, until noodles are glossy and tender. ┃
┃ 6 Finish: Add bean sprouts and chives; toss 20–30 seconds (keep sprouts crisp). ┃
┃ 7 Serve: Top with peanuts; squeeze lime over. ┃
┃ ┃
┃ Notes ┃
┃ ┃
┃ • If using thick tamarind concentrate, start smaller and adjust. ┃
┃ • For extra authenticity: add 1–2 tbsp chopped salted radish (hua chai po) during the garlic step. ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
INFO Found 0 documents
┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ What ingredients do I need for green curry? ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Tool Calls ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ • search_knowledge_base(query=green curry ingredients) ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Response (8.5s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ I couldn’t find a “green curry” entry in the knowledge base. Here’s a standard Thai green curry (แกงเขียวหวาน) ingredient list: ┃
┃ ┃
┃ Ingredients ┃
┃ ┃
┃ Green curry paste (or use store-bought) ┃
┃ ┃
┃ • Green chilies ┃
┃ • Garlic ┃
┃ • Shallots ┃
┃ • Lemongrass ┃
┃ • Galangal (or ginger) ┃
┃ • Kaffir lime zest (or lime zest) ┃
┃ • Cilantro roots/stems ┃
┃ • Shrimp paste (optional but traditional) ┃
┃ • Cumin seed, coriander seed ┃
┃ • White pepper ┃
┃ • Salt ┃
┃ ┃
┃ Curry ┃
┃ ┃
┃ • Coconut milk ┃
┃ • Protein: chicken (common), tofu, shrimp, or beef ┃
┃ • Thai eggplants (small round) or regular eggplant ┃
┃ • Bamboo shoots (optional) ┃
┃ • Thai basil ┃
┃ • Kaffir lime leaves (optional) ┃
┃ • Fish sauce ┃
┃ • Palm sugar (or brown sugar) ┃
┃ • Optional heat: extra green chilies ┃
┃ ┃
┃ Serving ┃
┃ ┃
┃ • Jasmine rice ┃
┃ ┃
┃ If you tell me what protein you’re using (chicken/tofu/shrimp) and what vegetables you can find, I can tailor the list. ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
以上