Agent with Tools
Give your agent tools to interact with external services.
Give an agent tools to interact with external services. The agent uses HackerNewsTools to fetch trending stories and user details.
Create a Python file
1from kern.agent import Agent2from kern.models.anthropic import Claude3from kern.tools.hackernews import HackerNewsTools45agent = Agent(6 model=Claude(id="claude-sonnet-4-5"),7 tools=[HackerNewsTools()],8 instructions="Write a report on the topic.",9 markdown=True,10)1112agent.print_response("Trending AI startups on Hacker News", stream=True)Set up your virtual environment
1uv venv --python 3.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateInstall dependencies
1uv pip install -U kern-ai anthropicExport your Anthropic API key
1export ANTHROPIC_API_KEY="your_anthropic_api_key_here"1$Env:ANTHROPIC_API_KEY="your_anthropic_api_key_here"Run Agent
1python tools.py