> ## Documentation Index
> Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Reasoning Agents

> Learn how to create AI agents with advanced reasoning capabilities for complex problem-solving.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
flowchart LR
    In[In] --> Agent[AI Agent]
    Agent --> Think[Think]
    Think --> Decide[Decide]
    Decide --> Act[Act]
    Act --> Out[Out]
    
    style In fill:#8B0000,color:#fff
    style Agent fill:#2E8B57,color:#fff
    style Think fill:#2E8B57,color:#fff
    style Decide fill:#2E8B57,color:#fff
    style Act fill:#2E8B57,color:#fff
    style Out fill:#8B0000,color:#fff
```

Learn how to create AI agents with advanced reasoning capabilities for complex problem-solving.

## Quick Start

<Tabs>
  <Tab title="Code">
    <Steps>
      <Step title="Install Package">
        First, install the PraisonAI Agents package:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        pip install praisonaiagents
        ```
      </Step>

      <Step title="Set API Key">
        Set your OpenAI API key as an environment variable in your terminal:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        export OPENAI_API_KEY=your_api_key_here
        ```
      </Step>

      <Step title="Create a file">
        Create a new file `app.py` with the basic setup:

        ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        from praisonaiagents import Agent, Task, AgentTeam, Tools

        # Create reasoning agent
        reasoner = Agent(
            role="Problem Solver",
            goal="Solve complex problems using logical reasoning",
            backstory="Expert in logical analysis and problem-solving",
            tools=[Tools.internet_search],
            
        )

        # Create task
        task = Task(
            description="Analyze and solve a complex business problem",
            expected_output="Detailed solution with reasoning steps",
            agent=reasoner
        )

        # Create and start the agents
        agents = AgentTeam(
            agents=[reasoner],
            tasks=[task],
            process="sequential",
            verbose=2
        )

        # Start execution
        result = agents.start()
        print(result)
        ```
      </Step>

      <Step title="Start Agents">
        Type this in your terminal to run your agents:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        python app.py
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="No Code">
    <Steps>
      <Step title="Install Package">
        Install the PraisonAI package:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        pip install praisonai
        ```
      </Step>

      <Step title="Set API Key">
        Set your OpenAI API key as an environment variable in your terminal:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        export OPENAI_API_KEY=your_api_key_here
        ```
      </Step>

      <Step title="Create a file">
        Create a new file `agents.yaml` with the basic setup:

        ```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        framework: praisonai
        process: sequential
        topic: solve complex business problem
        agents:  # Canonical: use 'agents' instead of 'roles'
          reasoner:
            instructions:  # Canonical: use 'instructions' instead of 'backstory' Expert in logical analysis and problem-solving.
            goal: Solve complex problems using logical reasoning
            role: Problem Solver
            tools:
              - internet_search
            tasks:
              analysis_task:
                description: Analyze and solve a complex business problem.
                expected_output: Detailed solution with reasoning steps.
        ```
      </Step>

      <Step title="Start Agents">
        Type this in your terminal to run your agents:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        praisonai agents.yaml
        ```
      </Step>
    </Steps>
  </Tab>
</Tabs>

<Note>
  **Requirements**

  * Python 3.10 or higher
  * OpenAI API key. Generate OpenAI API key [here](https://platform.openai.com/api-keys). Use Other models using [this guide](/models).
  * Basic understanding of Python
</Note>

<div className="relative w-full aspect-video">
  <iframe className="absolute top-0 left-0 w-full h-full" src="https://www.youtube.com/embed/KNDVWGN3TpM" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />
</div>

## Understanding Reasoning

<Card title="What is Reasoning?" icon="question">
  Reasoning agents are designed to:

  * Break down complex problems into manageable steps
  * Apply logical analysis to find solutions
  * Explain their thought process and decisions
  * Handle uncertainty and incomplete information
</Card>

## Features

<CardGroup cols={2}>
  <Card title="Problem Decomposition" icon="puzzle-piece">
    Break complex problems into smaller, manageable parts.
  </Card>

  <Card title="Logical Analysis" icon="brain">
    Apply structured thinking to solve problems.
  </Card>

  <Card title="Error Recovery" icon="shield-check">
    Handle edge cases and recover from errors.
  </Card>

  <Card title="Explanation" icon="comment">
    Provide detailed reasoning for decisions.
  </Card>
</CardGroup>

## Multi-Agent Reasoning

<Tabs>
  <Tab title="Code">
    <Steps>
      <Step title="Install Package">
        First, install the PraisonAI Agents package:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        pip install praisonaiagents
        ```
      </Step>

      <Step title="Set API Key">
        Set your OpenAI API key as an environment variable in your terminal:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        export OPENAI_API_KEY=your_api_key_here
        ```
      </Step>

      <Step title="Create a file">
        Create a new file `app.py` with the basic setup:

        ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        from praisonaiagents import Agent, Task, AgentTeam, Tools

        # Create first agent for analysis
        analyst = Agent(
            role="Business Analyst",
            goal="Analyze business problems and identify key issues",
            backstory="Expert in business analysis and problem identification",
            tools=[Tools.internet_search],
            
        )

        # Create second agent for solution development
        solver = Agent(
            role="Solution Architect",
            goal="Develop comprehensive solutions to business problems",
            backstory="Expert in solution design and implementation",
            
        )

        # Create first task
        analysis_task = Task(
            description="Analyze the current market challenges",
            expected_output="Detailed analysis of key issues",
            agent=analyst
        )

        # Create second task
        solution_task = Task(
            description="Develop solutions for identified challenges",
            expected_output="Comprehensive solution strategy",
            agent=solver
        )

        # Create and start the agents
        agents = AgentTeam(
            agents=[analyst, solver],
            tasks=[analysis_task, solution_task],
            process="sequential"
        )

        # Start execution
        result = agents.start()
        ```
      </Step>

      <Step title="Start Agents">
        Type this in your terminal to run your agents:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        python app.py
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="No Code">
    <Steps>
      <Step title="Install Package">
        Install the PraisonAI package:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        pip install praisonai
        ```
      </Step>

      <Step title="Set API Key">
        Set your OpenAI API key as an environment variable in your terminal:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        export OPENAI_API_KEY=your_api_key_here
        ```
      </Step>

      <Step title="Create a file">
        Create a new file `agents.yaml` with the basic setup:

        ```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        framework: praisonai
        process: sequential
        topic: solve market challenges
        agents:  # Canonical: use 'agents' instead of 'roles'
          analyst:
            instructions:  # Canonical: use 'instructions' instead of 'backstory' Expert in business analysis and problem identification.
            goal: Analyze business problems and identify key issues
            role: Business Analyst
            tools:
              - internet_search
            tasks:
              analysis_task:
                description: Analyze the current market challenges.
                expected_output: Detailed analysis of key issues.

          solver:
            instructions:  # Canonical: use 'instructions' instead of 'backstory' Expert in solution design and implementation.
            goal: Develop comprehensive solutions to business problems
            role: Solution Architect
            tasks:
              solution_task:
                description: Develop solutions for identified challenges.
                expected_output: Comprehensive solution strategy.
        ```
      </Step>

      <Step title="Start Agents">
        Type this in your terminal to run your agents:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        praisonai agents.yaml
        ```
      </Step>
    </Steps>
  </Tab>
</Tabs>

### Configuration Options

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Create an agent with reasoning configuration
agent = Agent(
    role="Problem Solver",
    goal="Solve complex problems",
    backstory="Expert in problem-solving",
    tools=[Tools.internet_search],
      # Enable detailed logging
    llm="gpt-4o"  # Language model to use
)

# Task with reasoning requirements
task = Task(
    description="Solve complex problem",
    expected_output="Detailed solution",
    agent=agent
)
```

## Troubleshooting

<CardGroup cols={2}>
  <Card title="Reasoning Errors" icon="triangle-exclamation">
    If reasoning seems incorrect:

    * Check problem description clarity
    * Enable verbose mode for debugging
    * Review agent configuration
  </Card>

  <Card title="Process Flow" icon="code">
    If process flow is unclear:

    * Verify task dependencies
    * Check agent roles and goals
    * Review task descriptions
  </Card>
</CardGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="AutoAgents" icon="robot" href="./autoagents">
    Learn about automatically created and managed AI agents
  </Card>

  <Card title="Mini Agents" icon="microchip" href="./mini">
    Explore lightweight, focused AI agents
  </Card>
</CardGroup>

<Note>
  For optimal results, ensure your problem descriptions are clear and provide sufficient context for the reasoning agents.
</Note>
