Claude with Reasoning Tools

Add the following code to your Python file

1from kern.agent import Agent
2from kern.models.anthropic import Claude
3from kern.tools.hackernews import HackerNewsTools
4from kern.tools.reasoning import ReasoningTools
5
6reasoning_agent = Agent(
7 model=Claude(id="claude-sonnet-4-20250514"),
8 tools=[
9 ReasoningTools(add_instructions=True),
10 HackerNewsTools(),
11 ],
12 instructions="Use tables to display data.",
13 markdown=True,
14)
15
16# Semiconductor market analysis example
17reasoning_agent.print_response(
18 """\
19 Analyze the semiconductor market performance focusing on:
20 - NVIDIA (NVDA)
21 - AMD (AMD)
22 - Intel (INTC)
23 - Taiwan Semiconductor (TSM)
24 Compare their market positions, growth metrics, and future outlook.""",
25 stream=True,
26 show_full_reasoning=True,
27)

Set up your virtual environment

1uv venv --python 3.12
2source .venv/bin/activate
1uv venv --python 3.12
2.venv\Scripts\activate

Install dependencies

1uv pip install -U kern-ai anthropic ddgs

Export 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 claude_reasoning_tools.py