Building Agents (the hard parts!)

Rita Kozlov, Cloudflare21:12 · Jul 2025 · 4,781 views
Thumbnail for Building Agents (the hard parts!) Watch on YouTube
TL;DR
  1. 1

    Agents combine a client, an AI reasoning model, workflows, and tools, with human approval where actions need review.

  2. 2

    MCP gives agents a standard way to access tools, resources, prompts, and sampling through a client-server architecture.

  3. 3

    Long-running workflows need persistent state so they can pause for human responses, resume later, and prevent duplicate actions.

Summary

Rita Kozlov explains the parts that make an agent useful in production. An agent needs a client such as chat or voice, an AI model that decides what to do, workflows that track progress, and tools that perform actions. She focuses on the tool and workflow layers, especially Model Context Protocol (MCP), which lets different clients connect to servers exposing resources, prompts, and tools. Cloudflare's Agents SDK provides MCP hosting, authentication, streaming transport, state management through Durable Objects, WebSockets, React hooks, and chat features. Kozlov then walks through a credit-card approval workflow built with Knock. The workflow pauses an action until a human approves it, routes the approval back to the right agent, resumes execution, and stores state to stop duplicate provisioning. She closes by showing how remote MCP servers can work through Cursor, Claude, ChatGPT, custom applications, and voice interfaces.

Key ideas
03:52

An agent turns AI assistance into a sequence of actions

Kozlov distinguishes ordinary AI augmentation from an agent that can carry out a complete task. Her campaign example starts with a request to find conference contacts, draft an email, send it for approval, and notify the user when a customer replies. The agent needs to coordinate each step rather than produce one answer. She says businesses are already reporting revenue increases from sales automation, faster support responses, and time savings from agents. The practical point is that an agent must manage work across several systems and wait for people when approval is required.

05:11

Every agent has a client, reasoning, workflows, and tools

Kozlov breaks an agent into four parts. The client is the interface, such as a voice connection or chat UI. The AI provides the reasoning that decides what should happen next. Workflows execute and track those decisions across multiple steps. Tools let the workflow act through a browser, API, internal service, or vector database. A voice agent may need WebRTC and speech-to-text, while a chat agent needs somewhere to host the conversation. Kozlov also includes gateways for caching and evaluation, plus a human-in-the-loop path for actions that need verification.

07:31

MCP makes tools easier for language models and multiple clients to use

Kozlov describes Model Context Protocol as a standard introduced by Anthropic for exposing APIs to language models. Its client-server design supports back-and-forth communication and allows multiple clients to connect to one MCP server. MCP servers can provide resources such as files and database records, prompts that explain how users should interact with an agent, tools for taking actions, and sampling to let the model complete part of the reasoning. Kozlov says the timing also reflects improved model tool calling, which makes these integrations more practical than they were a few years earlier.

09:59

Cloudflare's Agents SDK packages the difficult MCP infrastructure

Cloudflare's Agents SDK provides an MCP Agents class for hosting remote MCP servers with authentication, transport, and HTTP streaming. It also uses Durable Objects for state, which Kozlov describes as serverless functions with state attached. The SDK includes real-time WebSocket communication, React integration hooks, and basic chat capabilities. In her book-recommendation example, a server stores a user's preferred genres and previous books, then uses that state to produce more personalized recommendations across different clients. Kozlov contrasts this with separately setting up a database, managing connections, and handling scaling.

14:32

Long-running workflows must pause and resume around human decisions

Kozlov says workflows become difficult when an action may wait for an LLM or for a human response. A person might answer in minutes, hours, days, or months, so the workflow needs to preserve its state and resume after the response arrives. It also needs persistent WebSocket connections, retries, and horizontal scaling. Her example with Knock handles a request for a new credit card. The agent can collect the request in chat, then defer the card-issuing tool until a manager approves it through email, Slack, or an in-app notification.

17:09

State prevents an approval workflow from performing an action twice

After Knock sends an approval, the system finds the calling user's ID and routes the result back to the right agent and Durable Object. An approved request resumes the paused tool call, provisions the card, and informs the user. Kozlov stresses that the system must also handle events arriving out of order. Stored state records whether the card was requested, processed, or approved, so a repeated webhook cannot approve or provision the same card twice. The example makes state management an operational requirement rather than an optional storage detail.

19:12

Remote MCP servers let users choose existing clients or a custom app

Once an MCP server exists, users can access it through clients they already use. Kozlov names Cursor, Claude, and ChatGPT as clients that support remote MCP servers. A team can also build its own client and user interface when it needs more control over the connection between the client and server. She adds that the interface does not have to be visual. Voice applications can connect through WebRTC and WebSockets, allowing the same MCP client to work with spoken interaction.

"The really cool thing is that it has state management built into it because Cloudflare has this primitive called durable objects."11:08
Who should watch
  • You are building an agent that must call APIs, browse systems, or retrieve private data instead of only generating text.
  • Your workflow needs to stop for approval and continue later after a person responds.
  • You want one MCP server to work across Cursor, Claude, ChatGPT, voice interfaces, or a custom client.