From the course: Build with AI: Agentic Applications with LlamaIndex and MCP

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Creating custom event-driven decision steps

Creating custom event-driven decision steps

Now that we've seen how to create a simple tool calling agent, let's have a look at a new abstraction that will allow us to have a bit more control over the flow. We're going to be using Llama Index's agent workflows, which consists of two main abstractions called steps and events. In short, steps are class methods that can expect events and they can also emit events. And when an event is emitted that a step is expecting, it means that step is triggered. Let's start by creating a very similar agent to the one that we built before. But instead of simply answering e-commerce questions, let's design a specific decision step as to whether the user is asking something about e-commerce or not. And if they are asking a question about something completely different, let's get our agent to act in a different way as well. Let's have it not answer anything other than e-commerce questions. All right, so one thing to know before we start building our custom events and workflow, is that there are…

Contents