Reasoning With Model
Use a separate reasoning model with configurable step limits.
1"""2Reasoning With Model3=============================45Use a separate reasoning model with configurable step limits.6"""78from kern.agent import Agent9from kern.models.openai import OpenAIResponses1011# ---------------------------------------------------------------------------12# Create Agent13# ---------------------------------------------------------------------------14agent = Agent(15 model=OpenAIResponses(id="gpt-5.2"),16 # Use a separate model for the reasoning/thinking step17 reasoning_model=OpenAIResponses(id="gpt-5-mini"),18 reasoning=True,19 reasoning_min_steps=2,20 reasoning_max_steps=5,21 markdown=True,22)2324# ---------------------------------------------------------------------------25# Run Agent26# ---------------------------------------------------------------------------27if __name__ == "__main__":28 agent.print_response(29 "A farmer has 17 sheep. All but 9 die. How many sheep are left?",30 stream=True,31 show_full_reasoning=True,32 )Run the Example
1# Clone and setup repo2git clone https://github.com/kern-ai/kern.git3cd kern/cookbook/02_agents/13_reasoning45# Create and activate virtual environment6./scripts/demo_setup.sh7source .venvs/demo/bin/activate89python reasoning_with_model.py