You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Thought: Internal Reasoning and the ReAct Approach
2
3
3
4
<Tip>
@@ -6,68 +7,10 @@ In this section, we dive into the inner workings of an AI agent—its ability to
6
7
7
8
Thoughts represent the **Agent's internal reasoning and planning processes** to solve the task.
8
9
9
-
This utilises the agent's Large Language Model (LLM) capacity **to analyze information when presented in its prompt**.
10
-
11
-
Think of it as the agent's internal dialogue, where it considers the task at hand and strategizes its approach.
12
-
13
-
The Agent's thoughts are responsible for assessing current observations and decide what the next action(s) should be.
14
-
15
-
Through this process, the agent can **break down complex problems into smaller, more manageable steps**, reflect on past experiences, and continuously adjust its plans based on new information.
16
-
17
-
Here are some examples of common thoughts:
18
-
19
-
| Type of Thought | Example |
20
-
|----------------|---------|
21
-
| Planning | "I need to break this task into three steps: 1) gather data, 2) analyze trends, 3) generate report" |
22
-
| Analysis | "Based on the error message, the issue appears to be with the database connection parameters" |
23
-
| Decision Making | "Given the user's budget constraints, I should recommend the mid-tier option" |
24
-
| Problem Solving | "To optimize this code, I should first profile it to identify bottlenecks" |
25
-
| Memory Integration | "The user mentioned their preference for Python earlier, so I'll provide examples in Python" |
26
-
| Self-Reflection | "My last approach didn't work well, I should try a different strategy" |
27
-
| Goal Setting | "To complete this task, I need to first establish the acceptance criteria" |
28
-
| Prioritization | "The security vulnerability should be addressed before adding new features" |
29
-
30
-
> **Note:** In the case of LLMs fine-tuned for function-calling, the thought process is optional.
31
-
> *In case you're not familiar with function-calling, there will be more details in the Actions section.*
32
-
33
-
## The ReAct Approach
10
+
This utilises the agent's Large Language Model (LLM) capacity **to analyze information when presented in its prompt** — essentially, its inner monologue as it works through a problem.
34
11
35
-
A key method is the **ReAct approach**, which is the concatenation of "Reasoning" (Think) with "Acting" (Act).
12
+
The Agent's thoughts help it assess current observations and decide what the next action(s) should be. Through this process, the agent can **break down complex problems into smaller, more manageable steps**, reflect on past experiences, and continuously adjust its plans based on new information.
36
13
37
-
ReAct is a simple prompting technique that appends "Let's think step by step" before letting the LLM decode the next tokens.
38
-
39
-
Indeed, prompting the model to think "step by step" encourages the decoding process toward next tokens **that generate a plan**, rather than a final solution, since the model is encouraged to **decompose** the problem into *sub-tasks*.
40
-
41
-
This allows the model to consider sub-steps in more detail, which in general leads to less errors than trying to generate the final solution directly.
<figcaption>The (d) is an example of ReAct approach where we prompt "Let's think step by step"
46
-
</figcaption>
47
-
</figure>
48
-
49
-
<Tip>
50
-
We have recently seen a lot of interest for reasoning strategies. This is what's behind models like Deepseek R1 or OpenAI's o1, which have been fine-tuned to "think before answering".
51
-
52
-
These models have been trained to always include specific _thinking_ sections (enclosed between `<think>` and `</think>` special tokens). This is not just a prompting technique like ReAct, but a training method where the model learns to generate these sections after analyzing thousands of examples that show what we expect it to do.
53
-
</Tip>
54
-
55
-
---
56
-
Now that we better understand the Thought process, let's go deeper on the second part of the process: Act.
57
-
58
-
# Thought: Internal Reasoning, Chain-of-Thought (CoT), and the ReAct Approach
59
-
60
-
<Tip>
61
-
In this section, we dive into the inner workings of an AI agent—its ability to reason and plan. We’ll explore how the agent leverages internal dialogue to analyze information, break down complex problems into manageable steps, and decide what action to take next. We also clarify the distinction between two powerful prompting techniques: **Chain-of-Thought (CoT)** and **ReAct**.
62
-
</Tip>
63
-
64
-
Thoughts represent the **Agent's internal reasoning and planning processes** to solve a task.
65
-
66
-
This leverages the agent's Large Language Model (LLM) capacity **to analyze information presented in its prompt** — essentially, its inner monologue as it works through a problem.
67
-
68
-
The Agent's thoughts help it assess current observations and decide what the next action(s) should be. This process allows the agent to **break down complex problems into manageable sub-tasks**, reflect on past experience, and adapt plans based on new information.
69
-
70
-
---
71
14
72
15
## 🧠 Examples of Common Thought Types
73
16
@@ -82,10 +25,8 @@ The Agent's thoughts help it assess current observations and decide what the nex
82
25
| Goal Setting | "To complete this task, I need to first establish the acceptance criteria" |
83
26
| Prioritization | "The security vulnerability should be addressed before adding new features" |
84
27
85
-
> **Note:** In the case of LLMs fine-tuned for function-calling, the thought process is optional.
86
-
> If you're not familiar with function-calling yet, more details will come in the Actions section.
28
+
> **Note:** In the case of LLMs fine-tuned for function-calling, the thought process is optional. More details will be covered in the Actions section.
87
29
88
-
---
89
30
90
31
## 🔗 Chain-of-Thought (CoT)
91
32
@@ -97,21 +38,25 @@ It typically starts with:
97
38
This approach helps the model **reason internally**, especially for logical or mathematical tasks, **without interacting with external tools**.
98
39
99
40
### ✅ Example (CoT)
100
-
101
41
```
102
42
Question: What is 15% of 200?
103
43
Thought: Let's think step by step. 10% of 200 is 20, and 5% of 200 is 10, so 15% is 30.
104
44
Answer: 30
105
45
```
106
46
107
-
---
108
47
109
48
## ⚙️ ReAct: Reasoning + Acting
110
49
111
-
**ReAct** stands for **Reasoning and Acting**. It extends CoT by introducing **external actions** between thoughts. This includes using tools (e.g., calculator, search engine) to gather information, followed by observations that feed into the next reasoning step.
50
+
A key method is the **ReAct approach**, which combines "Reasoning" (Think) with "Acting" (Act).
112
51
113
-
### 🔄 Example (ReAct)
52
+
ReAct is a prompting technique that encourages the model to think step-by-step and interleave actions (like using tools) between reasoning steps.
114
53
54
+
This enables the agent to solve complex multi-step tasks by alternating between:
55
+
- Thought: internal reasoning
56
+
- Action: tool usage
57
+
- Observation: receiving tool output
58
+
59
+
### 🔄 Example (ReAct)
115
60
```
116
61
Thought: I need to find the latest weather in Paris.
117
62
Action: Search["weather in Paris"]
@@ -127,22 +72,17 @@ Action: Finish["It's 18°C and cloudy in Paris."]
| Best suited for | Logic, math, internal tasks |Info-seeking, dynamic multi-step tasks|
139
83
140
84
<Tip>
141
-
Recent models like Deepseek R1 or OpenAI’s o1 were fine-tuned to think before answering. They often use structured tokens like `<think>` and `</think>` to explicitly separate the reasoning phase from the final answer.
85
+
Recent models like **Deepseek R1** or **OpenAI’s o1** were fine-tuned to *think before answering*. They use structured tokens like `<think>` and `</think>` to explicitly separate the reasoning phase from the final answer.
142
86
143
87
Unlike ReAct or CoT — which are prompting strategies — this is a **training-level technique**, where the model learns to think via examples.
144
88
</Tip>
145
-
146
-
---
147
-
148
-
Now that we understand internal reasoning and the ReAct method, let’s move on to the second part of the loop: **Act**.
0 commit comments