The Thought-Action-Observation Cycle
1. The Thought-Action-Observation Cycle
Welcome back! In the last chapter, we explored what AI agents are, their key components, and when to use them. In this chapter, we’ll examine every component in more depth, and unpack real-world design patterns and architectures for AI agents.2. The Agentic Trinity: Model, Tools, and Orchestration
First, let’s refresh our memories. An AI agent is made of three components: The Model—it understands language, reasons through a given problem, and outlines steps to solve it.3. The Agentic Trinity: Model, Tools, and Orchestration
Tools—they connect the agent to the outside world, accessing data, performing actions, and making things happen.4. The Agentic Trinity: Model, Tools, and Orchestration
And finally, the Orchestration layer—it coordinates everything, keeping the agent moving forward towards its goal. Let’s zoom in on orchestration. We defined the orchestration layer as a continuous loop that controls how an agent processes information, remembers information, and makes decisions. But how exactly does it do that?5. Maintaining Memory, State, Reasoning, and Planning
The orchestration layer maintains memory, state, reasoning, and planning.6. The Thought-Action-Observation Cycle
While there are different architectures by which this happens, a useful framework for understanding orchestration is the Thought-Action-Observation cycle.7. The Thought-Action-Observation Cycle
Diving deeper, we can expand this cycle into the following. Thought, where the model decides the next step based on the user prompt.8. The Thought-Action-Observation Cycle
Action, where the agent takes an action, by calling the tools at their disposal.9. The Thought-Action-Observation Cycle
Observation, where the model reflects on the response from the tool, feeding into the next set of thoughts and actions.10. A Customer Support Agent Example
Let’s ground this with an example. Imagine a customer support agent that receives this message: "I forgot to cancel my subscription and was accidentally billed. Help me get a refund."11. The Thought-Action-Observation Cycle
Here's how the Thought-Action-Observation cycle unfolds:12. The Thought-Action-Observation Cycle
In the first cycle, the agent thinks that it needs to understand the customer's details, and determines which tool is needed to access that information. The agent's action is accessing the customer database. Finally, it makes observations based off of what it finds. In this case, it observes that the customer's premium plan was renewed 3 days ago.13. The Thought-Action-Observation Cycle
In the second cycle, the agent reacts to the observation, and thinks that given the renewal was recent, to check the company's refund policies. So the next action is to query the company policy. Based off of the company policy, the agent makes an observation, which is that the policy allows for full refunds within 7 days of renewal.14. The Thought-Action-Observation Cycle
In the third cycle, the system determines that the customer qualifies for a refund, initiates the refund transaction, and observes whether it was successfully processed or not.15. The Thought-Action-Observation Cycle
The agent then thinks it should update the customer, it acts by sending a confirmation email with the cancellation and updating the subscription status, and observes that it can close the ticket now.16. The Thought-Action-Observation Cycle
Finally, it closes the ticket. And the Thought-Action-Observation cycle is closed.17. Let's Practice!
The orchestration layer manages this loop in by storing thoughts, observations, and dictating tool use. Now, let’s practice.Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.