AI Engineer World's Fair 2025
Building Agents (the hard parts!)
Read the talk
Building agents that remember, wait and resume
A useful agent needs more than a model: it needs tools, persistent state and a workflow that can pause for approval without losing its place or repeating an action.
From a talk by Rita Kozlov
Before you start: Familiarity with APIs, basic TypeScript and the idea of an LLM calling tools will help; no prior Cloudflare experience is required.
From a first user to an automated workflow
What does it take to bring an application from its first line of code to its first user, and then to millions more? Rita Kozlov introduces that problem from her role leading product for Cloudflare’s developer platform, including Workers and Durable Objects. She reports that about 20% of internet traffic passes through Cloudflare, using Uber and food ordering as everyday examples. Alongside CDN, DNS and DDoS services, the platform supplies developer functions, storage, compute and AI inference—the infrastructure between an idea and a running product.
AI adds another application-building shift to the sequence of cloud, mobile and social. The pace matters because developers are moving from experimenting with model responses to building applications around them.
Kozlov recalls a year-earlier developer adoption figure of roughly 44% and an attributed Gartner forecast that half of knowledge workers would use AI by 2030. She contrasts those with talk-time claims of more than 76% of developers and over 75% of knowledge workers using AI. The matching research needs a narrower reading: the 2024 Stack Overflow survey counted 76% using or planning to use AI tools, with 62% currently using them versus 44% the previous year; it did not measure daily coding frequency. The Microsoft and LinkedIn Work Trend Index reported 75% usage among surveyed knowledge workers, based on February–March 2024 fieldwork. Those figures establish substantial adoption, but do not establish that the attributed Gartner forecast was surpassed on a comparable measure.
Kozlov suspects adoption has grown further since those reports. She also describes a change in the work developers are discussing: from training toward inference. OpenAI o1 illustrates her emphasis on post-training and inference; DeepSeek’s training optimizations illustrate her expectation that more effort will move toward inference. These are her framing of the workload shift, rather than measured allocations of industry compute or energy.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
An email draft becomes a campaign
Asking ChatGPT to draft an email is assistance. Asking an agent to run conference follow-up creates a process:
- Collect the customers you spoke with that week.
- Draft the campaign email.
- Send the draft to you for approval before it goes to customers.
- Notify you when customers respond.
The agent must coordinate actions across time, including a point where it cannot proceed without a human. The draft is only one intermediate result.
Kozlov reports some businesses seeing 20% revenue increases from sales automation agents, 90% faster support response times with AI agents, and roughly 50–75% time savings from agent use. The talk does not identify the studies, baselines or populations behind these figures, and the time-saving claim has no specified task. They motivate the opportunity; they are not capacity-planning assumptions for this campaign workflow.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Follow the request through four components
The campaign agent separates into four components. Keeping their responsibilities distinct makes it easier to see what a model call does—and what remains to be built around it.
| Component | Responsibility |
|---|---|
| Client | Let a human interact with the agent |
| AI | Reason about the request and choose what to do next |
| Workflows | Execute and coordinate the chosen actions |
| Tools | Provide access to external capabilities |
Workflows are the reasoning system’s executive branch: choosing an action does not itself execute it, and execution requires access to a tool.
For the CRM example, a voice request first travels over WebRTC, then through speech-to-text. A text interaction instead starts in a hosted chat UI. A gateway can provide caching and evaluations, helping track whether iterations improve the overall process, before the request reaches the LLM that produces the plan.
The workflow then records which actions have completed and which should happen next. Its tools might be a browser, an API, an internal service or a vector database containing additional knowledge. Selected actions also require human verification. The complete request path therefore includes both machine execution and the possibility of handing control back to a person.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Expose tools through MCP
Working backward from tools, Model Context Protocol (MCP) gives applications a common way to expose capabilities to LLM clients. Kozlov dates Anthropic’s introduction to the preceding November, but highlights another enabling change: models have become much better at tool calling. A standardized interface becomes more useful when the model can reliably choose and invoke the operations behind it. MCP preserves a client-server architecture, allowing conversations between a server and multiple clients.
The protocol separates several kinds of interaction:
- Resources: File contents, database records and other context the server can expose.
- Prompts: Reusable instructions that encode knowledge of how to interact with the system, including nuances its author understands best.
- Tools: Executable capabilities that connect a request to an action.
- Sampling: A server’s request for model generation through a supporting client.
Kozlov describes sampling informally as letting the LLM complete some thinking from shorthand, and says she had not seen it used in a production MCP server while preparing the talk. More precisely, the sampling specification defines sampling/createMessage: the client supplies model access and retains control over permissions.
The difficult implementation work remains transport, OAuth and memory. Kozlov mentions SSE and WebSockets together, but application WebSockets should be distinguished from standard MCP transport. The March 2025 transport specification defines stdio and Streamable HTTP, with optional SSE; Streamable HTTP replaced the earlier HTTP+SSE transport. WebSockets can support the surrounding real-time application without being one of those standard MCP transports.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Attach state to the agent
Cloudflare’s Agents SDK packages much of that infrastructure. It is distinct from OpenAI’s identically named SDK; Kozlov says the two can work together. The walkthrough uses Cloudflare’s McpAgent class for remote MCP hosting. In the historical integration, McpAgent handles transport, while workers-oauth-provider supplies authorization support: extending the class alone does not configure OAuth.
The stateful foundation is Durable Objects, which Kozlov describes as serverless functions with state attached directly to them. Code can retain information without requiring the application developer to separately provision and connect a database. Around that foundation, the SDK provides real-time WebSocket communication, React integration hooks and basic AI chat capabilities. Those pieces connect persistent server behavior to a live client interface.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Remember book preferences across interactions
The first walkthrough is a Goodreads-like recommendation server. Its class extends McpAgent and starts with empty state. An addGenre tool records a preference: Kozlov likes Patricia Highsmith, so her example adds thrillers. The important result is a persistent preference that later interactions can use.
A separate getRecommendations tool and a personalized MCP prompt can then use both preferred genres and previously read books. The following TypeScript captures that state transformation and prompt construction. Adding thrillers changes the preference list while preserving the read-book list:
typescript
type ReadingState = {
genres: string[];
readBooks: string[];
};
function addGenre(state: ReadingState, genre: string): ReadingState {
return {
...state,
genres: [...new Set([...state.genres, genre])],
};
}
function recommendationPrompt(state: ReadingState): string {
return [
`Recommend books for someone who likes: ${state.genres.join(", ") || "any genre"}.`,
`Previously read books: ${state.readBooks.join(", ") || "none recorded"}.`,
"Avoid recommending books already read.",
].join("\n");
}
const initialState: ReadingState = { genres: [], readBooks: [] };
const updatedState = addGenre(initialState, "thrillers");
const prompt = recommendationPrompt(updatedState);
The server must persist updatedState; returning a new JavaScript object alone does not make it durable. The prompt requests recommendations but does not itself execute a model call.
Add a genre without changing reading history
Constructed example: The TypeScript field names, empty-array representation, deduplication behavior and exact prompt wording are teaching details. Thrillers, initially empty state, persisted preferences and use of reading history come from the talk.
thrillers
Operation: Add thrillers to the genre list, preserve readBooks, and construct the recommendation prompt from the resulting state.
genres
[]
["thrillers"]
readBooks
[]
[]
prompt
Not present
Recommend books for someone who likes: thrillers. Previously read books: none recorded. Avoid recommending books already read.
As preferences and reading history accumulate, Kozlov expects recommendations to become more personalized. Because memory lives in the standalone MCP server, changing clients need not erase it. That depends on clients reaching the same stored identity; persistence alone does not define how identities are shared across clients.
The infrastructure comparison is between separately assembling storage and using state attached to the agent:
| Separate storage setup | State through McpAgent |
|---|---|
| Provision a database | Use built-in persistent state |
| Manage database connections | Access state through the agent |
| Coordinate compute and storage scaling | Rely on the platform’s scaling |
Kozlov also presents reduced infrastructure management, avoiding added database access latency, and execution close to the AI agent as benefits. The walkthrough supplies no latency measurement or placement guarantee.
For deployment, Kozlov points to a blog with a Deploy to Cloudflare button. The remote MCP deployment announcement provides a related historical entry point. Kozlov says an initial MCP server can be running in less than a minute and names Atlassian, Asana, Stripe and Intercom as companies building servers this way. That timing is her reported onboarding estimate.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Pause card issuance for human approval
Remembering a genre solves state within a tool interaction. A workflow must preserve state across an entire chain of interactions. A reasoning model may take several minutes; a human may respond after minutes, hours, days or months. The application needs to resume when the delayed task completes, while also handling persistent state, retries, WebSocket connections and horizontal scaling.
The customer example comes from Knock’s approval workflow. A user requests a new credit card, and their boss must approve it through email, Slack or an in-app notification. The chat request starts the process; it is not authorization to issue the card.
The setup proceeds in three steps:
- Connect the chat. Import
useAgentfrom the Agents React library to connect the client to an agent instance. - Gate the action. Wrap
issueCardwithrequireHumanInput, supplied by Knock Agent Toolkit in this historical example. Every invocation of the issuance tool must require human input. - Request approval and defer execution. Knock sends the approval notifications while the card-provisioning tool call remains paused.
The approval gate belongs on the executable tool. The workflow retains a pending call instead of issuing a card and asking a person afterward.
When the approval webhook returns, it must reach the same agent that owns the pending call. The walkthrough extracts the calling user’s ID from the tool call, looks up the agent by name using that ID, and routes the webhook to the existing agent’s Durable Object. Once an approved status arrives, the agent resumes the deferred tool execution, issues the card and tells the user it was approved.
The final part is duplicate prevention. Out-of-sync events must not approve or provision the same card twice. The agent records whether a request has already been processed and updates its approval status, so a later webhook can recognize completed work rather than repeat it. This persisted status is the walkthrough’s duplicate-handling mechanism; it does not by itself establish exactly-once behavior across an external card provider and every possible failure between issuance and recording the result.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Put the agent where users already work
With tools and workflows in place, the remaining choices are the reasoning model and the client. Kozlov leaves model selection and evaluations to other conference sessions, mentioning Logan’s talk about Gemini. This walkthrough therefore supplies the execution architecture, not a model-selection recipe.
MCP also creates a distribution option: build the server once and let users reach it through an existing client. Kozlov describes Cursor for developer users, followed by Claude and ChatGPT, as supporting remote MCP at the time of the talk. The architectural benefit is that an agent can become available inside a user’s existing workspace without first requiring a separately built UI; specific availability depends on the client’s support and access conditions.
A custom application remains useful when the workflow needs more control over both client and server. It need not be limited to text: Kozlov describes Cloudflare tooling that bridges WebRTC to WebSocket for voice interaction with an MCP client. Voice changes the input path, while the same server-side tools and coordination still carry out the work.
The finished system brings together a client, AI reasoning, workflows and tools. Kozlov recommends the Agents SDK as a starting point and says developers can get up and running in a few minutes. The campaign and card examples show what those pieces must accomplish together: accept a request, preserve its context, wait when approval is required, and resume the correct action when the response arrives.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Resources
Further reading
Rita Kozlov and colleagues introduce stateful agents, React connections, embedded storage and agent routing.
Historical introduction to Cloudflare’s remote MCP hosting and its transport and authorization components.
A virtual-card walkthrough that defers issuance for human approval using Knock notifications and a stateful Cloudflare agent.
Survey results distinguish current AI tool use from planned adoption in development workflows.
Research on workplace AI adoption, including the reported 75% usage rate among knowledge workers.
- MCP transports: March 2025 specificationDocumentation
Historical specification for stdio, Streamable HTTP, SSE streaming and connection handling.
- MCP sampling: March 2025 specificationDocumentation
Explains how servers request model generation through clients while clients retain control over model access and permissions.
Read the complete timestamped transcript
- 0:00
[on hold music] Hello, everyone.
- 0:16
Uh, I'm Rita. I'm the VP of Product for, um, Cloudflare's developer platform, so Workers and Durable Objects. Thank you for the shout-outs. Um, I always like to start by talking a little bit about, um, Cloudflare's mission, and especially our mission for developers.
- 0:33
And I saw a couple hands here in terms of number of people that used Cloudflare Workers before. Um, but actually, if you're sitting in this room, whether you've signed up for Cloudflare directly or not, um, you've a hundred percent used Cloudflare before because about twenty percent of internet traffic flows through Cloudflare.
- 0:53
Um, so if you've ordered an Uber recently, um, or, uh, or maybe even ordered some food, um, you've absolutely used Cloudflare. Um, but aside from Cloudflare's CDN, DNS, DDoS services, we do also offer, um, services to developers, including functions that you're able to run, storage, compute, AI inference, um, spanning many, many things.
- 1:15
And our, uh, our vision for developers is to make it as easy as possible for someone to bring their idea to life from the moment that they write their first line of code to deploying it to production, to making it live for the first user, to the millions that come after that.
- 1:33
Um, so that, that's what I do. It makes my job really exciting to wake up in the morning and see what developers are going to build.
- 1:42
Um, now, if, if you're in this room, I, I don't need to tell you that AI is as big a technological paradigm shift as, um, uh, as cloud, mobile, or social before it.
- 1:54
Um, I think everyone here is already convinced of that. But it is interesting to see just how quickly things are moving because I think that it's a good reflection of how quickly things are about to move next.
- 2:06
So, um, I realize that I gave a talk about a year ago, um, where I was pulling up some s- some stats and looking at where we were at.
- 2:14
And so a year ago, um, about forty-four percent of developers were using AI as a part of their day-to-day, um, to, to help them write code. Uh, and, um, Gartner was predicting that about, uh, by, by twenty-thirty, about fifty percent of knowledge workers would be using AI to augment their work.
- 2:34
Um, and the, these numbers seem ex- really, really low now, right? Like, um, today, um, over seventy-five percent of knowledge workers use AI to augment their work. Um, so this is already surpassing the twenty-thirty estimates that were given, and more than seventy-six percent of developers use AI as a part of their development process.
- 2:55
And, um, I, I, uh, I think that honestly, from the time that this report was pulled to now, that number has grown even more. Um, the other interesting thing was that about a year ago, when we were talking about, um, when we were talking about workloads, we were primarily talking about workloads in AI that involved training.
- 3:15
Um, and we predicted then that workloads were going to shift towards inference, and again, we've been seeing that unfold. So we, we saw that with OpenAI's o1 model, which is shifting more and more from training to post-training and inference.
- 3:32
We saw a similar thing actually with DeepSeek, who optimized training so much that more and more energy is spent on the inference part of it. But let's talk about what's next.
- 3:42
So, um, after training and inference comes, I think, actual automation, and, uh, I know there's been a lot of talk about agents the past couple days, but this is the reason that this is so exciting, is that we have the opportunity to not just, uh, to not just augment people's work, right?
- 4:00
You've been able for some time now to go somewhere like ChatGPT and ask it like, "Hey, help me draft up an email." But what's really, really powerful is to be able to go and say, "Hey, I have a campaign I want to run.
- 4:13
Grab me a full list of the customers that I talked to this week at the conference. Uh, then draft me up the email. Then actually, I do wanna review it before it goes to a customer, so do send it to me for approval, and then ping me when the customer responds."
- 4:28
Um, and, and so these are exactly the types of agentic workflows that I think we're going to see more and more that are really going to unlock that next level of productivity.
- 4:39
And we're already starting to see these agents out in the wild and really meaningfully impacting businesses. Um, so some businesses are seeing, uh, twenty percent revenue increases already as a part of starting to adopt agents as a part of sales automation.
- 4:55
Um, some businesses are seeing ninety percent faster response times to support when using AI agents. Um, and in general, uh, people are seeing about fifty to seventy-five percent time savings when using agents.
- 5:06
So agents are going to be even more meaningful, but are already reshaping the way that we work.
- 5:14
Um, okay, but, uh, you want to build an agent. Where do you start? What, what all goes into building an, an agent?
- 5:22
The way that I like to think about agents really comes down to these four components. So first, you have the client. You have the interface that the agent is going to be interacted through with a human, right?
- 5:34
Um, then you have the AI, the reasoning piece, the, the thinking part that's going to come up with the logic of, what are we about to execute? What are we gonna do next?
- 5:44
Now, the thinking part needs now its executive branch, right? It needs a way to go and execute on the actions that it decided that it was going to take.
- 5:54
And then, so that's the workflows, and then workflows also need access to tools. So it's not just enough to be like, "Okay, I'm gonna go and do this." They need access to the tools to actually take the actions.
- 6:06
So let's run through a quick example of what would it look like, that CRM agent that I was just showing, if I were to go and build something that helps me contact people that I talk to, what would that look like?
- 6:19
So the first part is if I wanted to have something that works over voice where I can be like, "Hey, do this for me," um, you need something that connects over WebRTC.
- 6:27
Um, you then need a speech-to-text model to translate what you said, um, back,
- 6:34
um, back into text. Um, alternatively, we're all familiar with chat UIs, right? So you need somewhere to host that. Um, then ideally, uh, you're using, um, some sort of gateway to do caching and to run your evals to make sure that as you're iterating on the overall process, that things are getting better and better.
- 6:52
Um, and then you need to send that response to an LLM that's going to do the thinking part and come up with the rest of the plan.
- 7:00
From there, you need a workflow agent. Um, so that's what's going to keep track of what actions have been executed and what actions need to take place next. And then, again, you need to connect to, uh, your tools.
- 7:13
It can be a web browser, it can be an API, it can be an internal service that you need to connect to, or it can be a vector database if you need to grab additional knowledge that, that, uh, that, that, um, agent needs, uh, access to.
- 7:27
Sometimes you're also going to need a human in the loop to verify some of these actions that you're taking.
- 7:35
So how do you build an agent? I'm actually going to go backwards here and start with the tools part. Um, and most recently, uh, there's been a lot of talk about MCP.
- 7:47
So the, the amazing thing is that Anthropic introduced this new standard back in November, and I think the, the really interesting thing about it is that it really got people thinking about, okay, how do we expose, uh, how do we expose APIs to LLMs in a way that allows us humans to talk to LLMs over natural language?
- 8:09
Um, but, but I think that the, uh, the real missed headlines of MCPs was actually that LLMs became really, really good at tool calling. This, this wasn't so much the case a few years ago if you tried to play around with tool calling, but, but now they are.
- 8:24
And so we have this new standard for how you can actually write out your code in a way that's going to be, um, incredibly easy to consume by any, uh, by any MCP client.
- 8:37
And so the, again, really cool thing about MCP is that it does respect a traditional client-server architecture where you're able to have that conversation back and forth, and importantly, have more than one client that connects to the MCP server.
- 8:51
Um, so these are some of the core concepts that go into MCP. MCP servers generally have, uh, resources, prompts, tooling, and sampling. Um, resources can be anything from file contents and database records.
- 9:04
Um, prompts actually help you define how you want someone else to interact with your agent, because you can actually prompt your agent probably better than anyone else can. If there are any nuances, um, a- about how your system works, you want to build that into it as much as possible.
- 9:22
Um, then you wanna give it access to the actual tooling, right, and connect those queries with the tools. Um, and then last but not least, sampling. Um, I actually think it...
- 9:31
I, I haven't seen anyone using sampling in production yet in an MCP server, was the interesting conclusion that I came to as I was preparing this talk. But, but the idea is to actually allow you to kind of use shorthand with your, uh, with your LLM and allow it to, um, kind of complete some of the thinking
- 9:48
behind it. Um, so, but, but building MCP does come with some tricky parts, and I, I think the trickiest parts of that is, first of all, the, the transport protocol, um, over SSC and WebSockets, the OAuth part, and the memory part.
- 10:04
Um, but I'm gonna share a cheat code with everyone here, um, so, um, get ready. Uh, I'm gonna, like, flash it real quick. Oh, you missed it. [laughs]
- 10:14
Um, uh, no, I'm just kidding. Uh, so Cloudflare has, uh, Cloudflare has, uh, an SDK called Agents that you can install that will actually give you a lot of this functionality out of the box.
- 10:26
Um, so we released Agents SDK a few months ago, and yes, it has the same name as the one that OpenAI, OpenAI just released a few days ago as well.
- 10:35
Um, but, uh, and the two actually work, uh, play with each other really, really well. But, um, I'll tell you a little bit about what it does, and, and you can, um...
- 10:43
So you can use, uh, Agents SDK, first of all, to ru- run MCP servers, and it comes with a class built in called McpAgent that allows you to host your remote MCP servers with OAuth, with, uh, transport, with HTTP streaming all built in.
- 11:00
Um, so if, uh, if you're one of those people that never wants to touch OAuth again, um, this allows you to do that. Um, the really cool thing is that it has state management built into it because Cloudflare has this primitive called Durable Objects.
- 11:15
And so, uh, Durable Objects, the idea is basically, it's kind of like a serverless function, but with state attached directly to it. So if you've ever wanted to, um, write some code, but then save the state of it without ever having to set up a database or anything like that, this is a really, really great way to
- 11:32
do it and makes it really easy to build these MCP servers. Um, it comes with real-time WebSocket communication, so that makes the whole chat interface thing really, really easy.
- 11:42
React integration hooks, so you can build, uh, you can integrate it into your front end really easily, and basic chat capabilities. So let's walk through what it would actually look like to deploy an MCP server on Cloudflare.
- 11:57
Um, so first, I can define my MCP class that extends McpAgent, which I was just talking about, and this MCP server is going to be kind of like a Goodreads, uh, server that's going to recommend different books to us.
- 12:13
So, uh, uh, we're going to set an initial state that's empty, but then I can add different... Uh, I can give it a tool, uh, that's called addGenre, so I can start to specify my preferences.
- 12:26
I'm a big Patricia Highsmith fan, so I can say, you know, I really like, uh, thrillers, and it's going to, it's going to save it and persist it for future interactions.
- 12:37
And so when I then ask it, um, for... I, I can then have a separate tool called getRecommendations that's going to get book recommendations, and, uh, you can have, uh, so we were talking about, uh, MCP prompts before.
- 12:52
You can have a personalized promp- prompt for recommending books to someone who likes the genres, right? Um, and has read the books that you've previously specified that you read.
- 13:03
And so it's a really good way to get these personalized recommendations, and every time that you inter- interact with this tool, it's going to persist the memory over every single time, so the recommendation are going to ke- keep getting better and better.
- 13:16
And because this MCP server is standalone and can be interacted with through various, uh, through various clients, the memory is actually going to persist regardless of the tool that you're using to call into it.
- 13:30
Um, now, why is this great? Um, it's amazing because traditionally you would have to separately set up a database, manage connections, handle scaling. There would be added latency in the setup, um, versus with McpAgent, because the memory part is built into it, um, you don't have to do any of that, and it's going to scale automatically.
- 13:49
It's going to run close to your AI agent, and you don't really need to think about infrastructure at all. You just get all of that out of the box.
- 13:57
Um, you can actually... So we have a blog post up. You can go and deploy your first MCP server today. It's really, really easy. There is literally a Deploy to Cloudflare button.
- 14:07
Takes, um, less than a minute to get your initial MCP server up and running. Uh, and what's been really cool is working with some of the brands that we respect so, so much and seeing companies like Atlassian, Asana, Stripe, Intercom building their own MCP servers in this exact way, so you're actually going down a really, really well-trodden
- 14:27
path here. Okay, so that was the tools part. Um, so let's, uh, keep working backwards from, from there. So we're, we're giving our agents access to tools, but now we need a coordination component, right?
- 14:40
Um, a workflow that's going to maintain a state not through just that one tool interaction but through the entire chain with perhaps a human in the loop.
- 14:52
Um, so human-in-the-loop workflows require long, uh, re- require you to have really, uh, long-running tasks that sometimes need to talk to an LLM. It might be a reasoning LLM that takes several minutes to come up with a response, um, and similarly, if you're talking to a human in the loop, a human could take minutes, hours, days, months
- 15:13
to respond, uh, and so you need something that's going to be able to come back and resume its flow after that task is completed. Um, you also still need to consider things like WebSocket servers, stay persistent, retries, horizontal scaling.
- 15:26
These things can get quite tr- quite tricky. So again, let's walk through a real use case that, uh, we built out with a customer. Um, there's a company called Knock.
- 15:35
They do notification management, and they needed to provision, uh, an, an agent that would do, um, approval when, uh, you, you could request a new credit card, right? And then, you know, your boss needs to go and approve it through, you know, it can be, um, an email, Slack, um, in-app, uh, notification.
- 15:56
So what do we need to do in order to do that? Um, first we need to allow users to request a new card through a chat interface. Uh, so you can see that here we're importing useAgent from, um, the, from the Agents React library, and then we're gonna have, uh, we're, we're going to create a new instance
- 16:16
of chat that's going to have all of these things instantiated on our behalf, and this is all part of Agents SDK. Um, then we need to give it an ability to issue cards through this, um, issueCard action, um, but we need to wrap it in the requireHumanInput tool in order to delegate that piece to Knock.
- 16:36
So, um, we want to make sure that the issueCard tool is always, always requires the human input.
- 16:44
Um, then we need to invite Knock to send our approval notifications and defer the tool call to issue the card until there's approval, right? Um, so we have a tool call to get a new card provision, but we want to stall that on the actual approval.
- 17:02
Um, so you can see that in here, um, where we're going to route the messages to approve something.
- 17:11
Um, now, once, once something is approved, we need to then route it back to the appropriate agent, and this is going to automatically be handled by the Durable Object and in- instantly routed to the correct agent back.
- 17:24
Um, so you can see in here, um, that I'm going to find the user ID from the tool called for the calling user, um, and then I'm gonna be able to look it up, so I can get the agent by name by the user ID in here, and so then if it's an existing agent, we're gonna route
- 17:42
it to the correct Durable Object and make sure that we're handling it, um, with a correct, uh, webhook.
- 17:49
We then need to resom- resume the paused tool call, issue the card, and let the user know that the card was approved, right? Um, so in here, if we received an approved status, then we can move on with the deferred, uh, tool execution, uh, that, that we, uh, that we defined earlier.
- 18:07
And then last but not least, we need to make sure the duplicate actions don't occur, right? So if two things happen out of sync, we can't approve the card twice, uh, or we can't provision the card twice.
- 18:19
Um, and so this is where, again, that state management becomes really, really important. Um, and we're able to store all of this directly in the state here, um, so you can see if, um, you know, the, if the card has been request- requested or processed already, and then if it's been approved, we're gonna set the status, so
- 18:39
when a new webhook comes in, we can't reapprove the same exact one. Um, so we talked about, uh, we talked about tools, we talked about workflows. Um, next you need the, uh, the reasoning piece of this, and need to choose the dif- the right model to run this.
- 18:56
Um, I'm actually going to skip this part because there's an entire conference that's dedicated to this today, um, of people that are going to cover this way better than I will.
- 19:06
Um, actually, Logan's talk this morning about everything that's happening with Gemini was really, really good. There's a bunch of people talking about evals. Um, but then, uh, but then you need, you still need a client in order to connect to your server, right?
- 19:19
And, and again, this is the really beautiful thing about MCP, is that once you've built out your MCP server once, uh, you can have, uh, you can truly meet your users where they are.
- 19:31
Um, and realistically, the nice thing is you actually, you don't have to build a UI yourself at all. Um, if your, if your users are developers, most likely they're already using Cursor.
- 19:43
Uh, and so now that Cursor supports remote MCP servers, you just import your MCP server and have your clients be able to interact with it. Similarly, Claude and ChatGPT, they both support remote MCPs, so your users, again, can start using your agents instantly directly through there.
- 20:03
But you can also build your own app and your own MCP client, and I think this is where you can build really, really interesting agentic workflows when you do have more control over both the client and the server, uh, a- and connecting these two pieces together.
- 20:19
And not only that, but your app doesn't actually have to be limited to just being a user interface. It can also talk to your MCP a- uh, your MCP client over voice, um, especially with, um, some of the Cloudflare tools that we have built out, uh, that help translate WebRTC to WebSocket in a way that really, uh,
- 20:39
makes it easy to build out these applications, because the MCP client can easily understand those connections.
- 20:47
So yeah, how do you build an agent? Um, these are the four different pieces you need, your client, your AI, your workflows, your tools. Um, and if you wanna get started and don't know where to start, I really, really highly recommend the Agents SDK.
- 21:01
You'll be able to get up and running in just a few minutes. Um, yeah, so thank you. [outro music]