# Adaptive reasoning agent
URL: https://docs.datarobot.com/en/docs/api/dev-learning/accelerators/llm-and-genai-apps/adaptive-agent.html

> Showcases an agent's ability to **adapt its reasoning behavior** based on conversation dynamics.

# Adaptive reasoning agent

[Access this AI accelerator on GitHub](https://github.com/datarobot-community/ai-accelerators/tree/main/generative_ai/adaptive-agent)

This accelerator showcases an agent's ability to adapt its reasoning behavior based on conversation dynamics. The agent acts as a customer support representative for the "DataInsight Pro" analytics platform.

In this example, the agent uses:

- GPT-4o for complex reasoning when corrections are detected.
- GPT-4o-mini for fast responses during smooth conversation flow.
- GPT-4o-mini as a reflection model to analyze the last three conversation turns and detect user corrections.

Specifically, the agent dynamically switches between models based on conversation analysis:

| Scenario | Model used | Behavior |
| --- | --- | --- |
| Conversation flowing smoothly | GPT-4o-mini | Fast, direct responses |
| User corrects the agent | GPT-4o | More thorough reasoning |
| User rephrases question | GPT-4o | Agent recognizes confusion |
| Positive feedback received | GPT-4o-mini | Returns to efficient mode |

The following diagram provides an overview that illustrates the agent architecture.

```
┌─────────────────────────────────────────────────────────────┐
│                     Frontend (React)                        │
│  ┌─────────────┐  ┌──────────────────────────────────────┐  │
│  │ Model Mode  │  │      Reflection Log Panel            │  │
│  │  Indicator  │  │  (shows gpt-4o-mini reasoning)       │  │
│  └─────────────┘  └──────────────────────────────────────┘  │
└─────────────────────────────────────────────────────────────┘
                              │
┌─────────────────────────────────────────────────────────────┐
│                   Adaptive Agent                            │
│  1. Store conversation history (last 3 turns)               │
│  2. Call reflection model (gpt-4o-mini) before response     │
│  3. Switch model based on correction detection              │
│     - Corrections detected → GPT-4o (thorough)              │
│     - Smooth conversation → GPT-4o-mini (fast)              │
└─────────────────────────────────────────────────────────────┘
```

The following script, with model adaptation noted, is applied in the accelerator:

| Turn | User prompt | Expected behavior | Model |
| --- | --- | --- | --- |
| 1 | "What pricing plans do you offer?" | Lists 3 tiers (Starter, Pro, Enterprise) | GPT-4o-mini |
| 2 | "How do I export data?" | General export explanation | GPT-4o-mini |
| 3 | "No, I meant export to CSV specifically, not PDF" | Correction detected! Detailed CSV instructions | GPT-4o |
| 4 | "Can I schedule automated exports?" | Thorough answer with plan requirements | GPT-4o |
| 5 | "Thanks, that's helpful!" | Positive acknowledgment | GPT-4o-mini |

---
