Basic Reasoning

Add chain-of-thought reasoning capabilities to agents.

Basic Reasoning.

1"""
2Basic Reasoning
3=============================
4
5Basic Reasoning.
6"""
7
8from kern.agent import Agent
9from kern.models.openai import OpenAIResponses
10
11# ---------------------------------------------------------------------------
12# Create Agent
13# ---------------------------------------------------------------------------
14reasoning_agent = Agent(
15 name="Reasoning Agent",
16 model=OpenAIResponses(id="gpt-5.2"),
17 reasoning=True,
18 reasoning_min_steps=2,
19 reasoning_max_steps=6,
20)
21
22# ---------------------------------------------------------------------------
23# Run Agent
24# ---------------------------------------------------------------------------
25if __name__ == "__main__":
26 reasoning_agent.print_response(
27 "A bat and ball cost $1.10 total. The bat costs $1.00 more than the ball."
28 " How much does the ball cost?",
29 stream=True,
30 show_full_reasoning=True,
31 )

Run the Example

1# Clone and setup repo
2git clone https://github.com/kern-ai/kern.git
3cd kern/cookbook/02_agents/13_reasoning
4
5# Create and activate virtual environment
6./scripts/demo_setup.sh
7source .venvs/demo/bin/activate
8
9python basic_reasoning.py