🧠 Multi-step Reasoning

Agents that
think step-by-step

Built-in plan → reason → act → reflect → respond cognitive loop. Create AI agents that break down complex problems systematically.

The Five-Step Cognitive Loop

Cogency agents follow a structured reasoning process inspired by human cognitive patterns. Each step builds on the previous, creating intelligent, deliberate responses.

1

Plan

Break down the problem into actionable steps

2

Reason

Analyze information and consider approaches

3

Act

Execute tools and gather information

4

Reflect

Evaluate results and adjust approach

5

Respond

Synthesize findings into final answer

Multi-step Reasoning in Action

Watch an agent systematically solve a complex problem

complex_analysis.py
 from cogency.agent import Agent from cogency.llm import GeminiLLM from cogency.tools import WebSearchTool, CalculatorTool # Create an agent with reasoning capabilities agent = Agent( name="Research Analyst", llm=GeminiLLM(api_key="your-key"), tools=[WebSearchTool(), CalculatorTool()] ) # Complex query requiring multi-step reasoning result = await agent.run( "Compare the market cap of Tesla vs Toyota, then calculate " "what percentage Tesla would need to grow to match Toyota" ) 

How the Agent Thinks

1

Plan Phase

"I need to: 1) Find Tesla's current market cap, 2) Find Toyota's market cap, 3) Calculate the difference, 4) Determine growth percentage needed"

2

Reason Phase

"Market caps change frequently, so I need current data. Web search will give me the most recent figures for both companies."

3

Act Phase

🔍 Searching web for "Tesla market cap 2024"...
🔍 Searching web for "Toyota market cap 2024"...
🧮 Calculating percentage difference...

4

Reflect Phase

"I found Tesla at $800B and Toyota at $250B. Wait, that seems wrong - let me double-check Toyota's figure as Tesla is typically smaller..."

5

Respond Phase

"Based on current data: Tesla ($800B) vs Toyota ($250B). Tesla would need to grow by 31.25% to match Toyota's market cap."

Why Multi-step Reasoning Matters

Systematic Problem Solving

Break complex queries into manageable steps, ensuring thorough analysis and comprehensive solutions.

Self-Correction

Built-in reflection allows agents to catch errors, verify results, and adjust their approach mid-execution.

Transparent Reasoning

Every step is visible and traceable, making agent behavior predictable and debuggable in production.

Ready for Intelligent Reasoning?

Build AI agents that think step-by-step with Cogency's built-in cognitive loop