A workflow where a reasoning agent breaks down complex problems into steps, followed by a smaller agent that processes these steps to provide concise answers.

Prerequisites

1

Install Package

Install required packages:

pip install "praisonaiagents[llm]"

praisonaiagents[llm] includes all necessary dependencies for reasoning agents

2

Set API Key

Configure your API key:

export OPENAI_API_KEY=your_api_key_here
3

Create File

Create a new file called app.py and add the following code:

4

Run Application

Execute the script:

python app.py

Code

from praisonaiagents import Agent, Task, PraisonAIAgents

reasoning_agent = Agent(
    role="Helpful Assistant", 
    reasoning_steps=True, 
    llm="deepseek/deepseek-reasoner"
)

small_agent = Agent(
    role="Helpful Assistant", 
    llm="gpt-3.5-turbo"
)

reasoning_task = Task(
    description="How many r's in the word 'Strawberry'?", 
    agent=reasoning_agent
)

small_task = Task(
    description="With the provided reasoning tell me how many r's in the word 'Strawberry'?", 
    agent=small_agent
)

agents = PraisonAIAgents(
    agents=[reasoning_agent, small_agent],
    tasks=[reasoning_task, small_task]
)

agents.start()

Features

Step-by-Step Reasoning

Break down complex problems into logical steps.

Multi-Agent Collaboration

Combine reasoning and processing agents.

Flexible Models

Use different models for reasoning and processing.

Task Chaining

Connect reasoning output to processing tasks.

Understanding Reasoning Agents

What are Reasoning Agents?

Reasoning agents enable:

  • Detailed step-by-step analysis
  • Logical problem decomposition
  • Clear reasoning paths
  • Enhanced decision making

Troubleshooting

Reasoning Issues

If reasoning steps aren’t clear:

  • Check reasoning_steps parameter
  • Verify model compatibility
  • Review task descriptions

Agent Communication

If agents aren’t coordinating:

  • Ensure task order is correct
  • Check task dependencies
  • Verify agent configurations

The reasoning agent uses a specialized model (deepseek-reasoner) optimized for step-by-step analysis, while the small agent can use a more general-purpose model for processing the reasoning output.

Was this page helpful?