Dry Run with Craig Dennis
Presented by: Sunil Pai, Craig Dennis
Originally aired on April 14 @ 1:00 AM - 2:00 AM EDT
Welcome to Dry Run. A live open mic for featured devs where we dive into what they are thinking about and what they're cooking.
Today's guest: Sunil Pai, Principal Systems Engineer, Emerging Tech & Incubation Hosted by: Craig Dennis, Developer Educator
Follow Cloudflare Developers on socials at:
- X - @CloudflareDev
- Bluesky - @Cloudflare-Dev.Bsky.Social
Learn how to Build with Cloudflare at: developers.cloudflare.com
English
CloudflareWorkers
Developers
Transcript (Beta)
Well, hello there everybody. Welcome to our first episode of Dry Run here on Cloudflare Developers YouTube, Cloudflare TV, and Twitter, wherever you're coming in from.
We're going to take some time here right now. I'm with the wonderful Sunil Pai, who is the master of squirrels, as I've heard.
Lord of the squirrels. Lord of the squirrels.
I'm so sorry. Lord of the squirrels. I'm a little demotioned. We have got some great stuff going on right now.
Sunil, let's share. Let's try to share this out.
Let's get as many people here as we possibly can, because I need to make sure that this is going.
This is our first time going. I see that Cloudflare Dev says that it's live, if you go to that page.
We've got some people there already.
I'm going to go ahead and try to figure out if I can retweet this as well.
And we should have some people in YouTube too, are going live over on YouTube.
I'm going to write hello everybody to YouTube. We'll get chatter from YouTube on the Cloudflare Devs channel, which you should like and subscribe over there if you haven't, because lots of good content.
This is the thing that Sunil and I have been talking about doing for years.
And we are so excited to bring this to you, because it is an exciting day that we're having today.
In fact, one of the most exciting that I think, I don't think I've seen the LFG tag as many times as I have in chat this week.
And Sunil, what happened this morning?
I was really looking forward to today because I finally got a copy of the Clerc soundtrack on CD.
And I got to listen to that. That's been the highlight of my day, man.
I'm joking, of course. Anything else? Something else. Great, great. Wait, what's on that soundtrack?
Before we start. Sunil, what's on that soundtrack? Huh? What's on that soundtrack?
I don't even remember. No, so it's basically like 90s alt rock stuff, like Alice in Chains, Chewbacca.
Like there's just so much. Like the USQ universe, Kevin Smith has made some great movies, Dogma, Clercs, all of that.
But the choice of music for all the movies has been amazing. And Clercs was his first movie.
And Jay and Silent Bob, all of that. And I've decided to start a project that I only listened to media before the year 2000 now, and on CD.
And even watching movies before the year 2000.
So I got Clercs. Today was Clercs. I mean, it's a good disc.
Was there a scratch on the CD? That's a new thing to reintroduce in your life.
Some scratches. And that's just it. There's a part of it where this media will deteriorate.
And I think that's also special about it. I don't actually mind it.
I'm deteriorating. Like my back hurts, bro. I act like a child, but I'm 41.
And it's because I have great skin that people can't tell. But all the whites are coming in, everything.
What I'm waiting for is to get the beard whites like you do.
That makes it look a lot sexier. Like that works. Oh, thanks. Oh, I think that was a compliment of some sort.
It was a compliment. You saw what I did there.
Thank you. Thank you. So everybody, welcome. Welcome to Dry Run. We're talking with Siniel today because something else happened other than the Clercs soundtrack.
Siniel, what happened this morning?
Today, we announced our first step officially into the AI agent world.
Cloudflare now has a library called Agents SDK that takes the very unique primitives that Cloudflare has of the platform and lets you build AI agents with it.
We'll dive into the detail there, but I think it's a fairly unique take that separates it from anything else out there for like a number of reasons.
Some of the reasons are because it's cutting edge tech.
Some of the reasons are because it's based on tech that's like 50 years old.
And I'm quite excited about it because just honestly, in the last few weeks, I've been building small apps with it.
I've been able to build things I never thought possible, not just because of AI models, but because of like marrying it to these primitives.
And we'll go into that in a bit.
But as of today, we have the NPM library out. The docs page on developers .Cloudflare.com.agents has been heavily updated, rewritten from scratch.
Thanks, Matt and Rita.
And we have a blog post that went out there that goes into detail. Along with agents, we also made the workers AI platform a lot more powerful.
So we fixed a bug where the context windows weren't as big as they were for making requests, but that's fixed now so you can make really big queries on workers AI.
And the workers AI provider, which is, you know, like there's the AI SDK. Basically, I'm a big fan of it.
It's the jQuery of building AI apps is what I call it.
The adapter for making that work with workers AI just got upgraded. Thanks, Andy.
He worked on it. So that it supports like function calling, tool calling, more models, structured outputs, lots of fun stuff.
So it's a big day, but it's also feels like day one of like a very big journey ahead of us.
That's why I'm like so excited.
I'm like, yeah, this is absolutely. Yeah. And then you've been thinking about this stuff for so long.
I love following you on Twitter. Everybody should follow you on R, I'm sorry, on X, 3 .1 or blue sky.
What's your blue sky? 3.1. 3.1.
So 3.1, all spelled out. 3.1. Let me do that because I, so my name is Sunil Pai and that's the value of I, but it's the stupidest name to have as an account ID, because the way you need to tell it to other people is it's 3.1, all words, no numbers, no periods.
And they're like, what did you just say? I'm like, no, it's E-H-R-E-E-P-O-I-N-T-O-N-E.
That's just the worst thing to give your handle, but I'm like stuck with it for the rest of my life.
I never, I never even saw it. I thought it was a Windows 3.1 joke.
I have used that reference also old enough to know what that means.
I've used it. It was good, good tech. So on your presence, you've been thinking about this space for a long time.
So this must feel good to get out.
And you've been thinking about it in a, in a sort of a deeper way than I, I appreciate following you because I'm like, Oh, he's right.
I haven't thought about that.
Can you, there's, there's, there's, there's people in here in the audience who are like, what is all this agent stuff?
You know, they're seeing commercials. Matthew McConaughey is talking about agents, right?
Like we're talking about agents a lot.
Yeah. Yeah. There's a Salesforce commercial where he's talking about agents and the importance of agents and the audience.
Is doing Salesforce commercials.
Yes, sir. Yes, sir. Movie stars, man. Come on. Like, I wouldn't mind like hanging out with.
Dude, I don't even know what movie stars that are on. I only watch movies from before the year 2000.
I don't know. Steve Martin, man. Let's get Steve Martin to do it.
I would love to get Steve Martin to do an agent talk. All right.
So let's, let's talk about where are we at before we get, before we look at this stuff, before we look at let's get a talk about where we're at and where, where we're headed.
Like what, what are, what are agents? Let's, let's get, let's get simple.
Let's get simple there. Where's your head at there? Okay. I think of it in terms of like levels of agency or agentic nature.
At the very base, right. Is a single, single call that you can make to these large language modules, these God computer things.
You can make it a, you can ask it a question in natural language and it replies to you.
Okay. That's, you call this a function call, a query, prompt, whatever it is.
You go one step above that and you can do multiple LLM calls either in a row or like as a routing.
And you can do chains of those calls.
These are things that a lot of people called workflows. So this is in the, the nature of saying something like you want to do analysis.
So, Hey, first go to Google, find the first 20 results for particular search thing, go into those pages, pull all that data out.
So then the second step is the scraping part. The third part is, Hey, take all the data from it and convert it into like structured data, like maybe tables of data, all of that.
Then another is run some other function call on it that compresses it, generates a graph.
And your final step is, okay, fine.
Put this into a report. Now that needs, this has been software that people have been writing for decades.
The neat thing is that LLM can figure it out instead of you having to write precise code.
It's very good at converting data from unstructured to structured between different formats.
And then back to like a report where it's like, Hey, we analyze the data and this is what we think, right?
But this is what we call it.
Yeah. Right. Like you can do a bunch. Yeah. Yeah. Yeah. Then there's something called the decision loop.
This is where it starts getting interesting.
This is somewhere in between what I consider a workflow and an actual agent where instead of you writing out which steps it should do, you tell figure out the steps and I'm giving you, you figure it out.
I'm giving you capabilities. Here's an API to go to a browser.
Here is a, here is an API that does math. Yeah. Here's an API into which you can put in code and it'll run the code for you and return the result.
So you just give it capability.
You just say, Hey, here are some features. Right. And for those, that's like tool calling, right?
Yeah. But it's more about like agency.
At this point, you're starting to give your computer agency, right? Where you say, you figure until you get the goal of a report that answers this question, don't come back to me.
That's different from a workflow where you write code, where you say, Hey, first do this, do this, do this.
And then that's what I call an agent.
And that's what we just announced today, which is the entity that contains state that you can actually ask questions to that can hibernate, that can reach out back to a human if it needs, like it was like, okay, fine.
I'm booking your flight tickets.
Give me your credit card numbers. Quick, quick, quick. Just by the way, super dangerous, but that's the journey we are on, on making it safe.
So that's the part where you have effectively a hundred percent agency to do what you want, and it can be proactive.
And what does proactive mean? If you keep giving it a stream of data, at some point, let's say you've said, Hey, like I want you to look after my health.
Like, Hey, you already had about 2,400 calories today and it's just 6 p.m.
Maybe you're done for the day. You know, agency is about like emergent behavior from these interesting systems.
That's what I think of as an agent. And then there's a higher level where we talk about agent farms or swarms or orchestration amongst many, many agents that are doing different things, not just top-down, but like amongst themselves.
Some people call these orchestration, but again, there's orchestration at a workflow level where you write the code to do it.
And then there's fully agentic goal-driven orchestration.
You say, run my business. Kind of scary, right?
And these are the levels of, I think about it in terms of agency.
How much agency are you giving your Silicon to take decisions like on this thing?
You start from almost nothing all the way until fully automated. Is that a good answer?
I don't know. I liked it a lot. And so the going to build these things, this is a concept that everybody's after, right?
Like everybody, literally, like we've seen commercials, right?
I went to log into Workday today and Workday had our new agent.
So it's everywhere, right? People are thinking about this. This is important.
You're going to be asked to build this. As a dev, you're going to be asked to build that.
And I have looked and played around in some different packages, and I am so glad.
I started playing just a little bit with this thing. I am so glad. It's so great.
Let's talk about what we announced today to enable people to do that.
What's the best way to do that? Should we do a blog post? What do you feel?
Let me just give you a little bit of a brain dump first. Just quickly before we get into it.
Okay. For sure. Let's do it. I mean, so I talked about, oh, like do the thing.
I want to be a little more specific about why I think it's interesting. Like why are agents a big deal?
Let's just talk about that like for a quick second. Let's do that.
Yeah. Why is it happening? That's great. That's an excellent. Why are agents such a big deal?
Like everyone told me crypto is a big deal and I didn't believe them then, but I think agents are a big deal.
Why? Okay. So this is, and I'm going to use the most boring explanation that I can use to do it.
Okay. So the idea is what is a business?
What is a business? So business is basically a Rube Goldberg machine that you set up that is made of people and software and maybe factories.
And what you can do is you can put in $1 on one side and it spits out $2 from the other.
Okay. And then your job is to manipulate that Rube Goldberg machine so that it spits out $3 or that it uses less electricity and resources.
You want to build a very, and you keep like operating on it.
And why does it require software and people?
It's because the inputs to this Rube Goldberg machine other than the $1 is unstructured data from the world, opinions, people who want to buy things.
Inside the Rube Goldberg machine, you're converting data of like from one team to another team, to another person, to another person, maybe generating reports.
And then effectively you're like generating reports and analysis and taking decisions on them.
Right? So this is why people have, this is why non-tech companies have software teams because they build software that runs the business.
Like why does Nike have a massive software engineering team?
Because all this system of sweatshops in Asia and sneakers, people who buy sneakers all across the world.
I'm just saying that's the business that they've constructed.
It's kind of profitable is what I hear.
I don't recommend it. It would kill me, but it's what they do.
Okay. What are LLMs good at that we just discussed? They're very good at converting unstructured data into structured data, converting data from one format to another, and converting structured data back into unstructured data.
And you give them a little agency and they can run all that. That is why agents are a big deal.
Automation systems, which the planet runs on, it's how industrialization happened, it's how the information age happened, is on the verge of effectively just being powered by silicon and electricity.
You can just throw it at it, which leaves the human condition something else to aspire towards.
Don't get me wrong, there are billionaires who are trying to capture that value, but I don't approve of that behavior.
Okay. So what did Cloudflare just do?
Cloudflare is a very unique software platform in the sense that they do it a little differently from everyone else.
And you and I know this, but for the sake of everyone else, instead of the idea of regions and data centers and all that, you ought to think about the Cloudflare network as a planetary compute.
It's almost like it's one computer that just covers the planet.
Sunil, wait one second. Are you trying to say, what are you trying to say there?
What's the quote that you're trying to say might be a registered trademark?
The network is- The network is the computer, exactly.
There you go. For those who are listening and who might not be as old as we are, there was originally something coined by Sun Microsystems and we actually bought it from Sun and it gladly, we didn't hostile take over it, the Rosling, et cetera, like a big fan.
The network is the computer.
It's basically one planetary computer that you take and this computer has many interesting capabilities.
Of course you can write serverless functions, which is like a JavaScript function that takes a request and a response, but you can spin up a browser and automatically you can make it browse the Internet for you on the platform, which is very cool.
It runs on the edge of this browser.
We have crazy storage systems for saving giant files or key value stores, databases, all of that.
But my favorite one is something called durable objects.
Fun fact, I heard about durable objects when I was out drinking with a buddy.
I used to work in a bank that I was not happy at about five years ago.
It was basically, I want to say August, 2020. And that's when Cloudflare announced the beta of durable objects publicly.
Until then, I hadn't heard of this company, bro.
I was like, oh, they do DNS and stuff. And I was like, wait, what the hell is this?
I've never seen anyone else do this. And I'll talk about what durable objects are.
So immediately I got on Twitter and started pestering people. And I know Rita Koslov, she responded, she's like, fine, I'll give you access to it.
And I was like, oh, wait, wait, let me make an account before you give me access to it.
So I had to do that. I'm like four drinks long at this point. I'm like, yeah, I'm looking at the phone.
I'm like, oh, this. I tried it out and I hated the developer experience so much that I started complaining about it.
And a couple of months later, they were like, stop complaining.
You want a job to come fix it.
So I basically came and helped build out Triangular, the developer CLI. Back to durable objects.
So serverless functions are these things where if you make a request for an HTML page or something, it spins up a little thing, takes your request, generates the HTML, sends it to you, and it dies.
This is how serverless, most serverless providers do it.
The way we do it is unique because we have zero startup time, blah, blah, blah.
I mean, this is the Cloudflare podcast, so I can't be accused of shilling too much.
No, you're not supposed to. Anyway, durable objects are interesting in that instead of a function, you basically define a class.
And for a request for a given ID, which can be like a chat room name or it can be an agent ID or anything like that, it spins up this computer and it stays.
It's basically like a tiny mini computer that has state that you can make multiple requests to, that multiple people can connect to, and that's why it's really good for building multiplayer systems.
Shout out to TLRAW. I think they were my first big team that I helped ship their multiplayer onto durable objects.
Right. And TLRAW is the multiple people come on, they draw.
A lot of people are building on that and sharing stuff out there.
It's super cool. Yeah, and that's powered fully by durable objects.
Every shared room is one durable object that all these web sockets, et cetera, connect to, all of that.
So it's like a little computer- And it's an instance, right, of that class.
It's an instance of that class. Exactly. For every given ID, it basically does in the background, we do new class of that and we stick it and it spins up closest to you.
So if everyone's in the same time zone, you'll see like 20, 30 millisecond latency, sometimes lower.
It's crazy. So you can build these crazy real-time syncing.
And the programming model is not really distributed programming.
It's running on one thread. So for example, all the web sockets are in an array.
If you want to broadcast a message to all the web sockets, it's a for loop.
It's crazy. It's ridiculous. It made a front-end dummy like me really powerful to be able to build really interesting things in JavaScript.
And you know what they do say?
They say that you are an influencer, a durable object influencer.
That's the word on the screen. See, the big problem with being a durable object influencer and already working in the company is that I can't get them to give me free shit.
Like all the shit is free already. Like otherwise, influencers get like flight tickets and free cosmetics and all of that.
You have the clothes and swag you're wearing that I haven't got.
Like, how do I get that fucking thing?
I'll get it for you. I'll get it for you. I want to get you a shirt that says the network is the computer.
That is my goal. To get you a shirt that says the network is the computer.
That would be dope. I would like that very much.
Okay. So durable objects. So we have this technology that for a given thing can spin it up.
And the nice thing about it is you can keep it running. Even if no one's connected to it and no requests coming to it, you can spin it up on an alarm.
Like you can set up a thing that says, Hey, wake up in like 30 minutes or 40 days, which is not a set time out.
It's literally a thing that can spin up. And when there's no IO happening, it can shut down.
So it doesn't live. It's not expensive.
There are no billions of it just running with dead air. No. If there's no work happening on it, then it goes back to sleep, which is incredible.
So it feels like a container, but you don't pay for it like a container.
Bro, forget about just paying it like a container.
You don't have to write YAML. You know what I mean? It's just a JavaScript class that spins up.
No, no YAML, no nothing. And each of these durable objects has its own little SQLite database inside it that persists to disk.
It has the alarms.
Yeah. And that local is important, right? It's like literally local.
Oh yeah. Literally local. 20 milliseconds away from you. Like where that instance spins up, that's where the database is.
And this is spread across the planetary compute, the computer network.
It's kind of crazy as a concept. Okay. So Cloudflare had this.
Cloudflare shipped this four years ago. A big question with durable objects has been, well, what is it good for?
Should I serve my website from it?
And you're like, well, no, serverless is probably a better pattern for that. There's nothing stateful in that.
The first time I quit from Cloudflare, I basically quit and started my startup called PartyKit, which basically took durable objects and said, okay, you all are building multiplayer systems.
Things like TL draw, game sessions, editing, collaborative editors, et cetera, et cetera.
And there was a good fit for that. And then I came back to Cloudflare and the timing was interesting.
Actually, I feel like we are a little late to it. I was like, wait, how did you come back to Cloudflare?
I just walked back in and nobody, they were like, oh, are you back?
I was like, I'm on the left. I was just having lunch.
That's how I came back. They're like, okay. And I was like, oh, my email isn't working.
And they're like, oh, it's disabled. We'll just re-enable it for you.
And I'm like, yeah, I just went back in. I walk into HR and I'm like, oh, I didn't get my pay slip this month.
They're like, oh, big mistake on our part. We'll fix it for you.
That's how I came back. No, I got acquired back last year in April.
Congratulations. Thank you. Congratulations. And it's been weird. I just said, because I built the startup, of course, on Cloudflare and I was in direct contact with everyone in Cloudflare.
So I came back and they were like, cool, man. We already talk twice a week.
What's changed? I guess. Anyway, so I've been puttering around and doing, I was puttering around doing a bunch of things.
And then I realized the thing that we have at Durable Objects. So Durable Objects, even though they seem very cool and innovative, they're based on very old tech.
Something called the Actor Model. By the way, I want to get Durable Objects flag that says Actor on the front and Model in the back.
I think that would be good.
Oh, all right. All right. I'm making notes. I don't know, like something.
We need to get some Durable Objects flag. Because Durable Objects itself is not a very good name, but it's fine.
Maybe because it's a bad name, everyone kind of knows what it is.
I don't know. Yeah. You have to learn it. We answer it a little bit.
Okay. So the idea of something that spins up, that has its own persistence and can run its own code in the back starts to sound suspiciously similar to what we were talking about, what agents can do.
You can have agency, they connect to a model and they have intelligence, they have persistence, and you can give them goals and targets.
And the moment that struck me, and I was like, wait, this is how we do automation systems.
Look, automation systems out there, very much revolve around the idea of a workflow right now.
Fairly explicit things. And there are a lot of players in the market, some very big ones, some smaller ones.
And those are useful.
And I think a lot of people confuse it. They conflate the two terms right now, agent and workflow.
Yeah. Let's undo that again real quick. Real quick. Undo agent workflow real quick.
So like we said, a workflow is what you would consider a fairly deterministic sequence of actions that has a start and an end.
But you go higher up the chain, higher up the agency level.
It's not deterministic. Inputs are flowing in all the time.
You might give it like some goals, but there might not be any explicit code that defines how to get to a target.
You just give it capabilities, right?
You say, hey, here's access to the database. Here's access to this.
You can do this and figure it out. And you want a container to run this code.
And ideally, that container is not Kubernetes or Docker or whatever it is.
You want these lightweight things that you can spin up that could potentially. And that's the other thing.
The moment you're talking about an agency for agents, these are things that could be able, could last forever, bro.
Like imagine having a personal agent for your life.
Are you telling me it runs for three days? No, dude, I want it to run until like my deathbed.
I want to bequeath my agents to my children when I pass away.
You know what? Like with all this context that I've gained, the wisdom that I've gained.
For sure. For sure, man, because they're going to get better too, right?
Like all that input is going to make it better. It's going to be great, especially by the time that time comes.
Exactly. Somebody in chat on Twitter just said, serverless classes?
Question mark exclamation point. Question mark exclamation.
I know, right? That's what I saw four years ago. Like what's happening here?
Yeah. Yeah. It's state serverless. That's where you stick the state.
Right. And it, I mean, I'm going to say, I'll say it. I'll say it. You're talking like this thing is going to live forever.
There's, it's just going to be there.
The state's going to be there. I can talk to it. It can come to life. It's there.
Yes, it's there forever. So what? All right. I think we're ready to look. Can we, can you pull the blog up?
Can you walk the blog? Is it time to walk the blog?
Sure. Let's do that. Let's share my screen. Wait, let me open up the blog post first.
blog.clutter.com. I'm also going to keep getting pinged.
I don't know if you can hear my pings and I'm just going to like say, do not.
It's not coming through here. Okay. Just got to do that.
Cool. Now let's share my screen. Okay.
I assume you can see my screen now. Yep. So make that a little bit bigger. Pump that.
Give that two pumps. There we go. Phrasing, dude, phrasing. I'm making Cloudflare the best platform for building AI agents.
Let's, let's literally just walk through the blog post.
How does that? Let's do it. So we talk about how as engineers we are obsessed with efficiency and automating.
And honestly, that's been the thing.
Software was invented for automation and its goal is automation.
Like that's, we want to make our little robots do things for us.
And today we are announcing Agent SDK, which is the JavaScript framework. That word framework, it's an interesting word.
Of course, you and I, we have been calling it Agent Framework because it becomes AF.
So that's cool. Right. Agents AF.
The problem with that subdomain is that it's been taken over by the Taliban. So you can't really buy domains anymore.
We got to shut up to personal agents, which I know is something that you've been, you think about that a lot.
Exactly. So I call it, there are two types of AI.
There's personal AI and there's professional AI.
They're both called PAI. That's what I think. Yeah. And whose last name is that?
I don't know, man. I don't know. It sounds like a dumb name. All right.
So we announced our little JavaScript framework. We made updates to workers AI and the workers AI provider is here.
And if we actually go into defining what agents are, we can say, hey, agents are non-linear, non-deterministic.
Workflows are linear, deterministic, and co-pilots are this idea of something that works alongside humans.
We go into an example where in a traditional automation system for booking a vacation, et cetera, there are multiple steps that you go through.
If there was a co-pilot, every step, you would go through this. The word co-pilot, of course, took off when VS Code introduced its LLM powered autocomplete, I want to say two, three years ago.
But then an agent is something that has agency. You just give it input.
It has access to tools and keeps doing things until it reaches like a goal.
If you want to get started with agent SDK, of course, there's the package that you can NPM install.
But the real one liner to get started is NPM create Cloudflare latest agent start with a template at Cloudflare agent starter.
It will give you a full project with Vite and React and Tailwind and the chat agent already ready to go.
In fact, do you want to see what it looks like? Do it, man. Run it.
Do it live. This show, by the way, is called Dry Run, and we are just going to go for it.
We're going to YOLO here. I've told you this before. I'll and I've always wanted to be a tech bro with a podcast.
**JASON LENGSTORF** You've done it.
You've made it. Now all you need is a shirt. Maybe I don't need a shirt.
**SUNDAR PICHAIKAI** I need this bag. Okay. So, the default starter kit is basically a chatbot.
And chat is interesting because some people might think it's too simple, but it's actually quite powerful.
It's a very interesting way of interacting with LLMs because you can speak to it, et cetera.
I'll go into why the starter kit is interesting, but let's actually walk through it right now.
What are some of the features that you have?
Of course, it responds like an LLM would.
So, let me put up the font size here, too. How can I assist you today? And you can talk to it like it's a human, like you're a dummy.
Are you doing well? I am just a virtual assistant.
Sure. What else? **SUNDAR PICHAIKAI** A couple of things that it does is it comes inbuilt with some functionality for doing what we call human in the loop.
And what that means is it'll ask you for intervention before it does a thing, like as a confirmation step.
And we have a very simple one. **JASON LENGSTORF** Which is important.
Let's talk about that real quick. Why is that important?
**SUNDAR PICHAIKAI** Well, there are some actions that you don't want an LLM to take until it validates with you whether it's the right thing to do.
Using your credit card to buy tickets.
Or maybe it's just, yeah, usually it has to do with something that you're spending actual money on.
But it could have to do with login.
Like, hey, it comes across a browser page and it means you to put in a username, password before it can proceed.
It's called human in the loop. In the decision loop that the agent takes, it comes across something that needs a human, and it reaches out to you, you jump in, and you go forward with that.
So this example, we have adapted from an example from the Vercel AI SDK, human in the loop example.
But if you ask it, what's the weather in London? At which point it stops.
And it asks for your approval whether to make a call to the get weather information function with the parameter city London.
I love LLM so much. The nice thing about this is, and I want to demonstrate this to you, is first of all, if I refresh my page, it's all persisted.
And this persisted on the server. So much so that if I go here and actually, let's say, kill the server, right?
Like it's dead.
And let's say I start it up again. Right? And I come back here, you'll see it's still back at the human.
So what that means is that when it's waiting for human intervention, remember, we spoke about how durable objects can go to sleep when nothing is happening.
It can go to sleep for minutes, hours, days, until you get to it and click the approve button, and it carries on.
It's got its stored in state. Exactly.
That's its state. Persisted into that SQL database that we have, right? It's all set up.
That comes out of the box with the starter kit. All of this just works.
Also, another thing that's nice is we have synchronization. So what I'm going to do is open up Safari.
And if I type something here, I say, tell me more about London.
Sure. You'll see that it actually synchronizes across chats.
Here it actually waits for the whole answer. Go on.
Maybe we should do per token syncing. It would be nice if we had that. But you'll see that it actually synchronizes both.
I'm going to say, thank you. And again, like it just synchronizes nicely across.
So multiplayer is nice. You can build multiplayer AI chat, but the immediate thing is multi-device.
Like if you're on your phone and your laptop, it shows the same thing, which is super nice.
You need that at all times, right?
Yeah. You need to be able to talk to your agent wherever you are.
That's cool. And right here, you see that it pops up a little box, but there's nothing stopping you from making it a push notification, or there's nothing stopping you from sending.
Because you control the code that runs in this agent, and this is something you can't do with a workflow, right?
That's what I mentioned.
Like this has a whole server that is serving this thing. You can send an email, bro.
Like if no one is connected, if it detects no WebSocket connections, like, okay, I'm going to send an email asking for confirmation, and you should be able to reply to that email saying, yeah, go ahead.
Tell me what the weather in London is.
And then it goes. Yeah. And of course, you know, email's safe on that side because it's you.
You've got access to it. Wow. That's cool, man. That should be the next demo I think we do here for the starter kit.
Like we should just add email responses onto this.
I think that would be dope. Okay. So as an old Twilio head, I think we should get text in there too, as an old Twilio head.
Screw that.
I'm 41. We should get phone calls in here. Like your agent should be able to make a phone call.
Right? Love it. I love it. Okay. So we have human in the loop, and potentially you can do asynchronous stuff like with email.
The other thing that we have is what I'm calling scheduling, which is you should be able to schedule things that happen in the future.
And when I say future, it can be, you should be able to specify it in terms of time.
You should be able to specify it in terms of a date, or you should be able to specify it in terms of a pattern.
So for example, you should be able to say, hey, every Friday evening, remind me to call my mother.
I actually speak to her way more often than that. It's because I love her.
Yeah. But yeah, it actually sets it up. And we're going to do, of course, it's not Friday evening right now.
This is Tuesday evening. Right. But I'm going through it to show you, to get to a thing which is much nicer to see.
But this is now scheduled a task that will actually trigger every Friday evening, and it'll actually pop up.
And you want to see what will pop up. Sorry? You parsed, how'd you do that?
Oh, did I do that? What's the, yeah. So we have set it up and you, you know what, I can just show you the code, bro.
I keep forgetting that I have the code to show you.
I'm going to need to increase the font size. Yeah, bro. Thank you.
So there's a file here.
Before we start, can you, can you try to, you said, I was having a hard time understanding earlier, you were saying squirrel and I didn't hear you.
When you say, you said schedule, could you say it in the American accent? Because you have an American accent.
Dude, it depends on the time of day and week. Sometimes I say schedule.
Sometimes I say schedule. I wanted a thicker American accent on it.
Is it schedule or schedule in American? Schedule. It's like a hard schedule.
The other one, and you all missed this, that I was talking is I mentioned that my official title at a previous company was, I call myself Lord of the squirrels.
And this dude doesn't recognize it. He's like, what'd you say? What is it?
So I need to roll my R's when I say squirrel. Squirrel, squirrel.
Squirrel, Lord of the squirrel. Those are really good. Okay, cool.
So once you get the starter kit, if you can just leave the UI as it is and you move immediately into the tools file and you start giving it capabilities.
So you can implement, get local time.
Here it always returns 10 AM. You know what? We can fix that right now and say new date to local time string.
I'll return to you this thing.
Of course it does it for where the server is running. So you probably want to do some time zone math here, which is famously very easy to do.
You can do stuff that requires the way that we're, and again, I copied this from the AI SDK, the way that you can build a function that requires human in the loop.
So here is get local time.
It gives the description parameters as a schema with this library called Zod and an execute function for, Hey, like once it gets that, how does it do it?
But if you want to do something that has human in the loop, you do description and parameters, but you don't give it an execute function.
You go down here to this little executions object we have and you put it there.
And we have set up the code such that it recognizes this pattern.
And anytime it bumps into something that doesn't have execute, it asks for confirmation.
And once you do confirmation, it calls the function with the same name and execution.
So simple. So you can chuck like a hundred functions into this to make your AI agent have a hundred capabilities.
Now for the scheduling, it's very simple. Again, like you give it a description, say schedule a task to be this thing.
And there are three types you can do scheduled, which is in after a particular, at a particular date, date and time.
You can say, Hey, it's delayed in terms of seconds, or you can give it a cron pattern, which is a way of describing repeating patterns in time.
And our magic LLM takes this and figures it out.
And the agent has a schedule function.
This is the thing that we shipped where you're able to set based on either a delay or a date or a cron pattern.
You're able to schedule a function that has to be run on the, uh, on the agent itself.
And on the instance of the agent, sorry, on the instance of the agent.
So now let's look at what the instance looks like.
So we have a little AI chat agent and we have set up execute task to basically take that description that we had given and put it back into the chat at which point the AI takes over.
So let me show you a demo of how that works. So here we did every Friday evening, but instead I'm going to say, uh, send me a haiku about cloud computing in 10 seconds.
Okay. So once I press 10 seconds, uh, press enter, it's going to tell me that it's scheduled it.
And then we come for 10 seconds and then it should, you'll see, send me a haiku about, uh, it'll come back and the styling is a little different and then you'll see it send you a haiku.
You could also make it to further tasks.
You could make it a chain by the way. That's the fun thing.
Okay. So I'm going to press enter. All right. Okay. One, two. Okay. So it's, uh, it did the thing.
So one, two, three, four, five, six, seven, eight, nine, 10.
There it is. Here's your haiku, my guy. Nice. That's so cool. Yeah. And again, this thing can keep running in the background.
You don't need to keep your browser open.
You can access it from another device. It's all happening in the AI agent instance in our server, inside this durable object.
That's what makes it so cool.
That's so cool. And can, can you talk from the beginning about like orchestrators and so agents can talk to agents?
Correct. So what we shipped today is a way of writing these agents and we have little APIs for instantiating these agents and you can, you know how you expose these functions on the class.
You can expose anything, right?
Which is, um, send email. Sure. And let's say you have a, a little thing here.
Yeah, dude. Like cursor is like, okay, fine. Then you just console log, right?
What's interesting is that this is now available on the chat agent, which means from either any other agent or because it's a Cloudflare workers, regular project, by the way, that's the fun thing here.
Like this works in existing Cloudflare Workers project.
It's not a new thing. It's just a library. You will be able to const chat agent equals env.chat get agent by name.
Uh, let's say and you import that.
So that would be your instance. It would create a new one or give you one, right?
Exactly. It basically like spins up one and then you can say chat, not send email.
Like you're able to call functions on an agent from the outside and you can do this from another agent or you can do this from anywhere else.
Like that's the fun thing. These are just regular Javascript classes that you can call functions on.
And that's making use of the RPC that's available in the durable object.
Exactly. That's exactly right. Javascript RPC, a thing with durable objects and the whole workers ecosystem.
Feel free to find the docs for it, but that's what it is.
So that's what the library and the starter kit let you do right now.
And when you're ready, all you say is NPM run deploy. By the way, this entire app is like I mentioned, it's a wheat app with like react you can use.
We're going to bring support for our new wheat plugin out to every framework, Swellkit, Solid Start, all of that over the next few weeks.
I don't know. As soon as we can, it takes a little work to get there.
Uh, but right now you can build a simple single page app, deploy it onto the Cloudflare network, everything you love about Cloudflare, which means that all your other resources, right?
Like your D1 database, KV.
Yeah, yeah, yeah. Go a little slower on that. Go a little slower on that.
You've got a joint database that they could all, each one of them has their own database, but you also have a scalable D1 database that everybody can get to.
That's right.
Cloudflare comes with a little edge database. We have KV, KV too, that you could also share across really quick.
And that's replicated. It's a little KV store.
Sorry, share what? Oh, no, I was just saying, I would say, well, let's just talk about what the stack is really quick too, because you get more things.
We talk about the features. Okay. Like all the products on the Cloudflare workers platform.
Let's see what all I can remember. So D1 is a SQL database, which is different from the database that you see inside a durable object.
Right. There's KV.
So it's shared. It's shared. Exactly. Like anything. There's KV, which is a key value store where the values can be 25 MB big, sure.
But that is replicated across the planet.
There's our object store, which is R2, which is usually for very big files, but you can put small files in it as well.
There's a vectorized, which is our vector database.
And we should have a whole session on just vector databases and RAG systems sometime.
Would work great with Cloudflare agents. There's caches.
There's Cloudflare images. There's durable objects, of course. The real-time stuff.
There's real-time calls. What real -time calls? Oh, calls. Real-time. Audio, video.
We have a WebRTC with Cloudflare calls, of course. And that's a demo that we should get to.
Imagine building audio, video Cloudflare agents. I can't wait. There's so much to build, bro.
There's so much input stuff coming in. And we have all the models hosted, too.
We have the workers.ai models hosted, too. We have workers.ai.
As of today, you can write good function calls and structured output, et cetera, with it.
I'm so excited for that. We finally got that to work. Dude, the developer platform is massive, dude.
It'll take a lot of time to get into it. And the cool thing is you can bring all that other stuff in.
You could bring other APIs in and other things like that.
You could bring in your own hyperdrive. We call it a cloud for a reason.
You want to connect to open AI models. You want to connect to something on AWS.
You want to connect to a little box that you put underneath your table that you host a server on because you're a big-ass nerd.
Go for it, bro.
That's what the workers platform is for. And that's what it's meant for.
Awesome. Awesome. So let's start wrapping this up. And I would like to say that we're We love watching you build and cook stuff with this.
We would love to see you share with us what you end up building with this and make it loud and come out and share with us.
Do a dry run.
We would love to have you go and install this. And if you could go ahead and...
Oh, we have a question, actually. Let's just share this really quick. Sure. Curious why we're using open AI instead of one of the workers AI models in the agent starter, which is a great question.
Two reasons. One is people... I wanted to show that you can connect to any model, like any external model.
It's basically bring your own model, right?
Right. The other one, and this is the thing that we actually need to fix, is workers AI right now doesn't work well with the wheat plugin, which I like using for building front end apps.
And we're just so close to fixing it.
We'll fix it. And I suspect when that happens, I'm going to replace open AI, I think, with the workers AI in the starter kit.
Because then it's nice and all self-contained, right?
No API key, no nothing. One other thing that I realized that we forgot there is the AI gateway, right?
So the AI gateway, maybe we should run that, at least run that through AI gateway so you can see what's happening, you can see the tokens that are coming, see what avowals are happening.
You can make sure that the agent is working well there, right?
The AI gateway is...
I always call it the sleeper hit of the Cloudflare platform. And by the way, the AI gateway is not just for workers AI.
It's for using external AI models, open AI, anthropic, all of that.
And it takes about less than five minutes to set up. I say five minutes, but it's less than five minutes.
And you forget about it. And you get caching for free, observability.
You can do prompt balance. There's just so much fun stuff there.
That is the sleeper hit, just you watch. That is going to be a - For sure.
And it's growing. Oh, you can do that now? Yeah, exactly. I tried it because I was bored one evening and the way my eyes popped out, like previously.
Awesome.
So, oh, let's get the repo up really quick too. Because I would love everybody to give it a star and everybody go build something, go get this thing, push it out.
You will enjoy this. It's GitHub Cloudflare Agents. GitHub.com. Oh, well, that was easy to remember.
I'm going to drop that out there. Yeah. Oh, I love this.
This image, by the way, of course, I got an LLM to generate it for me. I like how it's a network.
Oh, your screen is set up. Oh, my screen is not shared right now. I'm going to share it again because I do want to show.
Sorry, I was, of course, I keep forgetting this.
This is the repository, GitHub.com. You can start it. You can watch it.
If you watch it, you should know that I commit a lot and often and you might get annoyed, but definitely start it.
I feel good when that happens. And an LLM generated this image for me.
It got the colors right, the orange from color.
It did this diagram, which is clearly of like a network of things, but also it's in the shape of a brain in the middle.
I just love this. Dude, like LLMs are being sold.
Yeah, it's so nice. Dude, I think that's your shirt. I think that's your shirt.
Oh, I should make a shirt with this. This is the swag. Yeah, this is the agents.
Yeah, sure. You can go here. So we are going to build out high quality guides.
So there's the anthropic five patterns of routing example here implemented with agents.
In fact, I need to, dude, there's so many features of agents we didn't even go through.
We have state sync. So instead of writing your own raw WebSocket messages, you just do like set state in the agent and it'll synchronize with the React front end.
It's like so easy. And you can edit it from the front end and it'll synchronize on the back end.
Anyway, so there are guides. There are guides for the human in the loop example.
There's the anthropic patterns. I have a little playground that I'm using to build other stuff in here.
So right now there are examples for the state sync and how the scheduler works.
So you can copy some code from here.
And there are two packages. The first one, of course, is the agents SDK that we just announced today.
And another one, which I managed to do today because it's so nice to do, is an official middleware for the HonoJS framework.
So nice. Shout out to my guy. I love this. Right? It's a little middleware that you can use to add AI agents to your HonoJS app.
So good. So cool. So this is the repository.
Then, of course, there are the docs, which Matt and Rita and like a bunch of people have been working on nonstop.
We'll be updating this furiously as we keep adding features and stuff.
So you should definitely keep an eye on that. And by the way, you should follow this dude.
He's very handsome and smart. 3.1 on Twitter.
Talks about AI all the time. So you should absolutely follow this guy too. Absolutely.
I love following that. And I love keeping your thoughts coming, man. And they're about like where this is headed.
Because I feel like you're talking about stuff that people are talking about.
And I love it. I would love to bring that. I would love to keep on bringing this Dream Tech Bro podcast for you.
Let's do this.
So there's one question on Twitter. Someone asked me and saying, Craig won't ask me questions.
Can you create an agent per customer similar to durable object stub from ID?
So one agent can be spun out to millions of instances, each with their own state.
Yes. In fact, as I mentioned, Cloudflare agents are durable objects, just like with superpowers.
Honestly, I just copied a bunch of stuff from PartyKit and stuffed it into Cloudflare agents.
But yes, the idea, absolutely. You can spin up millions of these things and work like really well.
You shouldn't do that. And pricing.
So pricing is if you're using the nice Cloudflare Workers, the CPU pricing, which is they charge you only for CPU instead of data.
Durable objects right now does charge you for wall clock.
But the trade off here is that, of course, inside one durable object, you can be doing many things concurrently.
So it kind of like amortizes.
There are different phrases for basically like concurrent programming inside a durable object.
That being said, I have to tell you, I don't really like that style of pricing for durable objects.
And we may or may not fix that very soon. We might have some better.
Okay. All right. That sounds good. No spoilers. Everybody, thank you.
Sunil, thank you so much for coming. Thank you for building this amazing framework.
Craig, amazing. We still have to go through the demo that you've built, but we can do that in the next session if you'd like.
Let's do that in the next show.
I'll get it further. I will do a dry run of that. We're coming up on time here.
Time expands, right? Before we get on time, I want to let the crowd know this was an hour long, but me and Craig are going to do this way more often for shorter periods of time.
I will not let someone else be the only person on a podcast named Dry Run.
I have to be on it. Thank you, everybody, for attending the first episode and watching this later.
And thank you, Sunil, for being here.
Go build. Go have fun with this. This is really awesome.
This is an incredible tool. We are in a wild time, and you should be a part of it.
And we hope that you're able to do so. So thank you, everybody.
We'll see you soon. Thanks, everyone. See you.