1 00:00:00,06 --> 00:00:02,02 - [Instructor] Before we start building our agent, 2 00:00:02,02 --> 00:00:05,04 let's quickly discuss what is an agent anyway. 3 00:00:05,04 --> 00:00:07,09 The term agent gets used everywhere lately 4 00:00:07,09 --> 00:00:10,07 and so much that it can be confusing. 5 00:00:10,07 --> 00:00:13,03 Let's first look at what's not an agent. 6 00:00:13,03 --> 00:00:16,01 What you see here is an automated workflow. 7 00:00:16,01 --> 00:00:19,02 It runs a fixed sequence of predefined steps, 8 00:00:19,02 --> 00:00:22,05 triggered by maybe a webhook or a file change, 9 00:00:22,05 --> 00:00:24,06 and then produces an output. 10 00:00:24,06 --> 00:00:26,06 Everything is fully deterministic. 11 00:00:26,06 --> 00:00:28,00 No AI involved. 12 00:00:28,00 --> 00:00:30,01 It just follows the script. 13 00:00:30,01 --> 00:00:33,08 Next up is an automated AI workflow. 14 00:00:33,08 --> 00:00:36,04 This one still has a clear input and output, 15 00:00:36,04 --> 00:00:40,08 but now we use AI inside the workflow to perform a task, 16 00:00:40,08 --> 00:00:43,00 for example, classifying a new email 17 00:00:43,00 --> 00:00:45,02 or summarizing a meeting transcript. 18 00:00:45,02 --> 00:00:48,06 Here, a large language model helps with part of the job, 19 00:00:48,06 --> 00:00:51,05 but the overall process is still predictable: 20 00:00:51,05 --> 00:00:54,00 clear input, clear output. 21 00:00:54,00 --> 00:00:56,07 Now, let's look at an agent workflow, 22 00:00:56,07 --> 00:00:58,08 and this is where things change. 23 00:00:58,08 --> 00:01:01,01 We still have a goal and an output in mind, 24 00:01:01,01 --> 00:01:04,02 but we don't define how to reach it exactly. 25 00:01:04,02 --> 00:01:06,06 Instead, we give the agent instructions, 26 00:01:06,06 --> 00:01:07,08 a few tools it can use, 27 00:01:07,08 --> 00:01:10,07 and let it decide the steps on its own. 28 00:01:10,07 --> 00:01:12,04 It reasons through the process, 29 00:01:12,04 --> 00:01:14,08 choosing which action to take next. 30 00:01:14,08 --> 00:01:17,00 The result isn't deterministic anymore. 31 00:01:17,00 --> 00:01:18,03 It's more probabilistic, 32 00:01:18,03 --> 00:01:22,01 driven by the agent's reasoning rather than static rules. 33 00:01:22,01 --> 00:01:25,00 So, when should you use an AI agent? 34 00:01:25,00 --> 00:01:28,07 Agents are most effective when the goal is clearly defined, 35 00:01:28,07 --> 00:01:32,05 but there are multiple flexible paths to reach it. 36 00:01:32,05 --> 00:01:34,06 There's a limited number of actions available 37 00:01:34,06 --> 00:01:36,05 and the order doesn't really matter, 38 00:01:36,05 --> 00:01:39,02 and ideally, actions can be corrected, 39 00:01:39,02 --> 00:01:41,05 meaning the agent can go back and forth 40 00:01:41,05 --> 00:01:43,06 until the goal is achieved. 41 00:01:43,06 --> 00:01:47,00 Let's take our pre-sales agent as an example. 42 00:01:47,00 --> 00:01:48,09 Its goal is to generate a quote 43 00:01:48,09 --> 00:01:50,09 that meets all required fields. 44 00:01:50,09 --> 00:01:53,05 The tools it has is collecting customer info 45 00:01:53,05 --> 00:01:54,03 through the chat, 46 00:01:54,03 --> 00:01:56,06 collecting prices, generating the quote, 47 00:01:56,06 --> 00:01:58,09 and then finally drafting an email. 48 00:01:58,09 --> 00:02:01,02 It doesn't matter which of these happens first, 49 00:02:01,02 --> 00:02:03,09 as long as the final quote is valid, 50 00:02:03,09 --> 00:02:06,04 and if something's missing, like customer info, 51 00:02:06,04 --> 00:02:09,02 the agent can simply ask again. 52 00:02:09,02 --> 00:02:12,04 Now, when shouldn't we use an AI agent? 53 00:02:12,04 --> 00:02:13,09 If the goal is unclear 54 00:02:13,09 --> 00:02:16,08 or there are either too few or too many steps 55 00:02:16,08 --> 00:02:17,09 to reach that goal, 56 00:02:17,09 --> 00:02:20,04 agents aren't really a good fit. 57 00:02:20,04 --> 00:02:21,08 When there are just a few steps, 58 00:02:21,08 --> 00:02:24,02 a classical automation or AI workflow 59 00:02:24,02 --> 00:02:26,03 is usually the better path. 60 00:02:26,03 --> 00:02:29,05 On the other hand, if the agent has too many tools, 61 00:02:29,05 --> 00:02:33,06 the process quickly becomes unreliable and unmanageable. 62 00:02:33,06 --> 00:02:37,03 Right now, there's no hard rule for what too many means, 63 00:02:37,03 --> 00:02:42,00 but personally, I try to keep it under 10 tools per agent. 64 00:02:42,00 --> 00:02:44,09 Agents also struggle when the order of steps is strict 65 00:02:44,09 --> 00:02:47,01 or when mistakes can't be corrected, 66 00:02:47,01 --> 00:02:50,07 such as in high-stakes or irreversible scenarios. 67 00:02:50,07 --> 00:02:52,09 In those cases, a traditional workflow 68 00:02:52,09 --> 00:02:56,01 is almost always the better choice. 69 00:02:56,01 --> 00:02:57,03 So, to sum it up, 70 00:02:57,03 --> 00:03:00,04 an AI agent combines three essential components, 71 00:03:00,04 --> 00:03:02,07 an AI model with instructions, 72 00:03:02,07 --> 00:03:06,01 memory to keep track of the short-term context, 73 00:03:06,01 --> 00:03:07,09 and a defined set of tools 74 00:03:07,09 --> 00:03:10,08 that allow it to interact with other systems. 75 00:03:10,08 --> 00:03:12,06 Together, these give the agent 76 00:03:12,06 --> 00:03:14,09 the autonomy to act towards a goal: 77 00:03:14,09 --> 00:03:18,08 reasoning, choosing, and executing steps on its own, 78 00:03:18,08 --> 00:03:21,01 which brings me to one of my favorite definitions 79 00:03:21,01 --> 00:03:22,03 of an AI agent, 80 00:03:22,03 --> 00:03:24,02 by Simon Willison. 81 00:03:24,02 --> 00:03:28,01 He says, "An agent is an LLM that runs tools in a loop 82 00:03:28,01 --> 00:03:29,04 to achieve a goal," 83 00:03:29,04 --> 00:03:32,00 and that's the definition we'll use going forward. 84 00:03:32,00 --> 00:03:35,01 Simple, practical, and exactly what we'll be building 85 00:03:35,01 --> 00:03:37,00 throughout this course.