<p>AI agents are programs capable of not only providing answers but also making decisions, performing tasks, and interacting with their environment. For a long time, AI could think aloud (chain-of-thought), gradually reasoning through a task, but were limited to the knowledge they already had. Other approaches allowed agents to act actively (for example, searching the internet), but without deep planning and understanding of the task as a whole.</p>
<p>With the emergence of the ReAct (__Reasoning + Acting__) approach, an important revolution occurred. ReAct allowed the AI agent to do two things simultaneously: reason and immediately take actions in the external environment.</p>
<p>Example of ReAct in action:<br>Imagine you asked the agent, “What interesting places to visit in Paris?” The agent first reasons: “I need to find up-to-date information.” Then it takes action — searches the internet for a list of attractions. After getting the search results, the agent reasons again: “Here are a few places, now I will choose the most popular ones,” and gives you the final answer. If the information obtained is insufficient, the agent performs actions and reasoning again until it reaches the desired result.</p>
<p>However, when tasks become lengthy or particularly complex, ReAct may encounter difficulties: the agent starts to get lost, repeat unsuccessful steps, or forget the overall plan of action.</p>
<p>This is exactly the situation for which the new approach — CodeAct — was created.</p>
<p>CodeAct uses a more powerful idea: each subsequent step of the AI agent is determined not just by reasoning, but by generating program code. The agent literally writes code that is executed to understand what to do next.</p>
<p>Example of CodeAct in action:<br>Imagine the agent needs to calculate the sum of numbers from 1 to 100. Instead of mentally performing actions step by step, the agent writes code:</p>
<pre><code>sum(range(1, 101))</code></pre>
<p>Then the agent runs this code, instantly getting the result.</p>
<p>CodeAct allows the agent to “write instructions to itself,” which are then executed. This significantly increases accuracy and allows for complex multi-step tasks, such as planning a trip (booking hotels and flights, reserving restaurants and meetings) or shopping across different sites simultaneously.</p>
<p>Both approaches (ReAct and CodeAct) operate on the principle of a cycle: the agent thinks, acts, evaluates the result, and repeats these steps until the task is completed. But the key difference with CodeAct is that here the agent does not just think, but directly generates code for each action, greatly expanding its capabilities and accuracy.</p>
<p>CodeAct is an important step forward because it allows agents to handle more complex scenarios than was previously possible. It’s like the difference between a person solving a problem in their mind and a person writing down intermediate steps on paper. The second approach is much more reliable and efficient, especially if the task is not simple.</p>
<p>Therefore, it is important to keep an eye on the development of approaches like CodeAct — they can significantly expand the capabilities of AI in the future.</p>
· Essay · 2 min
CodeAct: A New Era of AI Agents After ReAct
CodeAct uses a more powerful idea: each subsequent step of the AI agent is determined by generating program code.
