ТРАНСКРИПЦИЯ 🔗
WEBVTT
00:00:00.040 --> 00:00:06.519
How can we delegate more of our ongoing work to coding agents?
00:00:03.259 --> 00:00:21.579
Imagine agents that respond to new GitHub issues and recover unfinished work after a crash. So today we're looking at two building blocks for making these persistent agent workflows more reliable. Pi Durable and Cloudflare Durable Objects.
00:00:22.140 --> 00:00:42.079
We'll explain what each does, how they fit together, and how you can use them in your own coding workflows. So, Brandon, before we get into the individual tools, can you give us a concrete example of a workflow you could delegate to an agent built this way with these two tools?
00:00:42.420 --> 00:00:44.299
What would that look like in practice?
00:00:44.640 --> 00:01:10.519
Imagine an autonomous coding agent that wakes up when a GitHub issue comes in, it builds the PR for you in the cloud, and even if it crashes randomly, the agent knows exactly where to resume without needing to redo unnecessary work. You or your friends and teammates can pick up the same conversation from GitHub, Slack, your phone or your terminal to make any other changes that you need.
00:01:07.879 --> 00:01:11.359
This is something that you can do with these tools.
00:01:11.980 --> 00:01:22.299
That sounds really useful. But I wonder, couldn't we already build something like this with Claude Code or Codex and some webhooks and a remote machine?
00:01:20.180 --> 00:01:22.299
What's different?
00:01:22.579 --> 00:01:28.125
You can, but it takes a lot of code and there's a lot of nuance to getting it right.
00:01:28.840 --> 00:01:31.799
And it's very hard to test and squash all the bugs.
00:01:32.420 --> 00:01:54.659
And so by having all these tools that are laser-focused on solving these problems and having lots of eyeballs on them and having these like nice open-source projects, we can use these as building blocks to enable us to be more ambitious and build more interesting tools with high confidence.
00:01:55.140 --> 00:02:10.300
I see. So it sounds like instead of building everything ourselves, we can now just take off-the-shelf products like the new Pi Durable the Cloudflare Durable Objects. Is that right?
00:02:10.300 --> 00:02:19.699
Exactly. Yes, yeah. So we can take these things that have a lot of energy and focus on them, or at least they're starting to.
00:02:16.539 --> 00:02:22.780
Some of them are new as well and we can use these to build amazing things.
00:02:23.259 --> 00:02:30.680
So yeah, let's dive into each of these tools and let's start with Pi Durable. So, what is Pi Durable?
00:02:32.060 --> 00:02:34.800
So Pi Durable is a durable agent harness.
00:02:35.159 --> 00:02:36.617
And what does that durability mean?
00:02:36.719 --> 00:02:44.219
Well, basically it means that you can have a really long-running agent even if the machine that it's running on dies in the middle.
00:02:45.020 --> 00:02:46.580
It still is the same session.
00:02:47.159 --> 00:02:52.139
OK. So what does Pi Durable do when a machine crashes?
00:02:53.639 --> 00:03:10.400
So Pi Durable prepares at every moment to be ready for a crash so that it could recover if a crash happens. Right? Cuz it doesn't know when it would happen. So the way that this works is the creators describe it as an effect sandwich.
00:03:10.939 --> 00:03:31.360
So at first you record an intent to perform an effect so anything that you know is happening in the real world then the effect actually happens, or you try to make it happen, and then once you get confirmation that it's done, you record I finished it.
00:03:32.520 --> 00:03:41.788
And that way, Pi Durable knows if it sees only one half of these things when it starts up that something went wrong and a crash happened in the middle there.
00:03:42.139 --> 00:03:47.979
So it keeps a log of the things that it plans to do and the status of whether it's done or not.
00:03:50.120 --> 00:03:54.460
Yeah, it's a little different it's a kind of log, yeah.
00:03:54.860 --> 00:04:19.519
A lot of durable agents use what's called like event sourcing to do their durability which is literally writing things down in a log and then playing them back. And this kind of effect sandwich approach is a kind of log but it's different from like the typical log that other durable agent libraries have tried.
00:04:19.579 --> 00:04:33.779
And because it keeps track of these effects and the status that makes the workflow recoverable because it will know exactly when a machine crashes, where it was and which steps were already done and which were not. Is that right?
00:04:34.480 --> 00:04:35.259
Yes.
00:04:35.259 --> 00:04:39.480
OK. That's helpful.
00:04:35.259 --> 00:04:50.040
And what could you build with Pi Durable that would be inconvenient with a regular coding agent but would be much more easy or suitable or helpful to do with Pi Durable?
00:04:50.060 --> 00:04:59.779
Any time you have an agent session or you can imagine an agent session that is not started by a person.
00:05:01.810 --> 00:05:06.399
Or even if it is started by a person, it needs to last for a long time.
00:05:06.819 --> 00:05:13.160
Any of those situations are very suitable for Pi Durable. I can give a handful right now. Shall I?
00:05:13.920 --> 00:05:14.740
Yeah.
00:05:14.839 --> 00:05:39.339
OK. OK you wanna set something up so that anytime you add a tag that says improve the performance of this thing, then an agent automatically gets spawned, it does its work, it hill climbs the performance for that particular task that you've specified.
00:05:40.160 --> 00:06:08.319
And then when it's done, it writes the result back as a comment on the issue or opens up pull requests with the actual change so you know this kind of workflow is good if there's folks on your team that are uncomfortable using command line or if you're lazy and you don't wanna open your Codex app and you know you're already in GitHub. So it's just like easier.
00:06:08.600 --> 00:06:11.060
Right?
Load full transcript
Claude Code has this remote control.
00:06:11.339 --> 00:06:22.052
Codex also has this ability to kind of remote in and control your agent. But the agent has to be running somewhere. It has to be running on your laptop or on a machine in the cloud somewhere.
00:06:22.360 --> 00:07:05.740
And if that agent dies, then you can no longer connect to your work. Right and moreover, it's very hard to share that with other people. But with Pi Durable, it's very easy. It's sort of given to you for free that sessions can be shared or forked between people and you can switch between machines without having to worry that there's some kind of god machine that stays online all the time that is kind of hosting this system that would be if you have Pi Durable running in the cloud somewhere, for example, in a Cloudflare Durable Object.
00:07:06.279 --> 00:07:58.939
I could also imagine since Pi Durable is storing like these, I don't know, checkpoints of where the process is, you could also use it in situations where you have like high-stake checkpoints for example, maybe you know you want to make sure that even if your workflow crashes, when it restarts it doesn't resend the same email to your client, your customer. Or if it's like, I don't know, sending a newsletter or posting an announcement that it doesn't do it again. So I would think that maybe for these high-stake situations Pi Durable might be more reliable than your regular coding agent.
00:07:59.160 --> 00:08:09.040
Yeah, exactly like if you're refunding one of your customers with your agent, you don't want to accidentally refund them twice and have your business lose money.
00:08:09.800 --> 00:08:11.420
Yeah, that's a really good example.
00:08:11.420 --> 00:08:18.439
You don't want to like pay your customer twice so let's take that as a specific example.
00:08:18.439 --> 00:08:27.459
Let's say an agent is somewhere halfway through that tool call to pay back the customer and then the process just dies.
00:08:31.199 --> 00:08:33.919
What does Pi Durable know at that moment?
00:08:34.419 --> 00:08:37.360
And how does it like continue after a restart?
00:08:37.940 --> 00:09:00.159
In order for us to go through this example, I wanna talk a little bit about just how Pi Durable works at a really high level. So Pi Durable completely decouples all of its state from its execution in a way where there's a specific definition for literally every part of the state of the agent.
00:09:01.340 --> 00:09:05.519
And that can be serialized and then recovered at any point.
00:09:05.879 --> 00:09:12.860
And so one of those pieces of state is this effect sandwich that we talked about.
00:09:14.799 --> 00:09:28.220
So basically as Pi Durable is running, it's writing things to that state, like, hey, I'm asking the model for something, the model comes back, I want to make this tool call.
00:09:28.840 --> 00:09:30.139
OK, the tool call came back.
00:09:30.379 --> 00:09:52.179
And so imagine the state at the point that the first
refund is sent, The state already contains everything up to that point, including the first part of the effect sandwich that says, I intend on sending a refund and I'm about to.
00:09:55.679 --> 00:10:04.240
And then it crashes. So the next time that it wakes up after a crash, we call it rehydrating the state.
00:10:05.360 --> 00:10:09.820
If we turn some raw state and we make it alive again, we rehydrate it.
00:10:11.299 --> 00:10:14.879
Then Pi Durable will realize, oh the second half of my effect sandwich didn't come.
00:10:16.039 --> 00:10:22.460
So this call it's in no man's land.
00:10:22.700 --> 00:10:23.600
Like, what happened?
00:10:25.179 --> 00:10:26.320
And then it can say, oh OK.
00:10:27.779 --> 00:10:50.679
Well, even though, for example, my session history doesn't include anything about sending the payment or having you know any information about it I need to go and check and say OK like you know I should look up and I should be careful because I'm in the middle of this situation.
00:10:50.879 --> 00:11:07.179
And I guess the difference with resuming a session in Claude Code or Codex is Claude and Codex would read the session history and then reason about where it thinks the process died and pick things up.
00:11:04.860 --> 00:11:19.019
But I guess the difference is you are very reliant on hoping that the reasoning or thinking is correct and it doesn't accidentally redo something that it might have already done.
00:11:19.019 --> 00:11:22.600
Yeah, Claude doesn't even know where crashes happen.
00:11:23.100 --> 00:11:31.460
There's no mechanism for like marking that in the same way that there is in Pi Durable. You can resume a session.
00:11:32.500 --> 00:11:37.879
But resuming a session is kind of similar to just continuing it.
00:11:35.240 --> 00:11:38.679
Continuing one that has always been running.
00:11:39.879 --> 00:11:45.720
How does it exactly look for Claude Code and how does it look for Pi Durable if we put it next to one another?
00:11:45.820 --> 00:12:00.559
So if we're lucky and the reasoning trace that's saved in the session history contains I'm about to send the refund and I should be careful to make sure I don't do this twice, then when you resume, like you said, it probably won't do it twice.
00:12:00.919 --> 00:12:20.120
But if you're unlucky and that's just missing from the reasoning trace, then when Claude resumes, it has no notion of whether or not that refund went through or not. It might not even be in the logs or in the session history, right?
00:12:17.220 --> 00:12:20.120
Basically there's danger.
00:12:21.080 --> 00:12:24.700
There's danger when you're doing these things and
00:12:24.700 --> 00:12:32.919
Much more ambiguity because it wasn't purposely built for resuming a session like how Pi Durable is.
00:12:33.980 --> 00:13:15.820
Exactly. And so if you actually were using this in a workflow and you wanted to make it robust, you needed to write a lot of code to work around the fact that this is designed
differently but the Pi Durable is kind of built from its foundations because of the way that state is decoupled from execution, where this kind of thing just comes really easily and so I mean the whole Pi Durable in its initial launch is like twelve thousand lines of code which is really small but because it's designed really carefully it enables this kind of safety which is nice.
00:13:17.179 --> 00:13:18.340
And how do people use it?
00:13:18.340 --> 00:13:26.480
You just install Pi Durable and it just works out of the box? It starts checkpointing right away while you work?
00:13:27.419 --> 00:13:31.559
So Pi Durable is not a tool.
00:13:32.259 --> 00:13:36.139
It's a library. It's a framework so, or a library.
00:13:36.139 --> 00:14:15.100
I don't know so basically it has all of the knowledge of how to run a harness, but it's a function that someone has to call. So out of the box once you download it, you can tell your agent build me a simple interface on top of Pi Durable so that I can start using it in the command line or in my browser or somewhere and Pi Durable doesn't make any decisions for you about where the state is stored and where it's running.
00:14:15.379 --> 00:14:35.519
That's something that it provides a few different like plugins where, you know, Claude can find those and choose one for you or you can choose it you can build your own plugins but out of the box it's not something you can run in the same way that's like standard Pi, Claude Code or Codex.
00:14:36.360 --> 00:14:37.235
Does that make sense?
00:14:40.600 --> 00:14:42.379
So what is a good way of using it?
00:14:42.379 --> 00:14:46.340
Should we ask Claude Code and Codex to use Pi Durable?
00:14:47.179 --> 00:15:06.200
Yeah. Basically for a specific workflow, you know, like I'll flesh out that refund example you have a system in a mobile app where a user can shake and then give a nasty message to support and say like, I need a refund.
00:15:08.039 --> 00:15:09.919
And you get too many of those.
00:15:10.120 --> 00:15:17.519
So you wanna just have an agent that's running in the background and handling them for you.
00:15:14.299 --> 00:15:27.500
Instead of setting up your workflow in such a way that sending that support message, you know, triggers some machine that you have always running that has a Claude session open on it.
00:15:29.879 --> 00:15:42.500
You have that session rehydrate the Pi Durable state of this support agent that's handling these refunds and then it can perform that work. And that's, yeah.
00:15:42.500 --> 00:15:50.830
And so when you're building that, you just tell Claude for this workflow I'm building, use Pi Durable.
00:15:52.240 --> 00:15:53.620
That's cool.
00:15:53.840 --> 00:15:55.215
Then you're basically done. Yeah.
00:15:55.840 --> 00:15:56.639
Oh wow.
00:15:56.639 --> 00:16:01.399
You know, make sure you build this the same way you build everything, right?
00:16:01.399 --> 00:16:27.679
Like, if it's something really simple, just vibe-code it. And if it's something important, like it's handling money, maybe you should have long grill sessions, really understand what's happening, make design decisions and then build it out but yeah, like treat it like a library or a framework in the same way that you tell Claude, like, I wanna use React for my front-end.
00:16:29.080 --> 00:16:29.879
You know?
00:16:31.039 --> 00:16:36.519
It sounds like the place where those checkpoints are saved is probably quite important.
00:16:37.559 --> 00:16:40.419
You need it to recover the progress.
00:16:40.659 --> 00:16:46.039
So where is that stored exactly?
00:16:46.440 --> 00:16:57.759
Yeah. Yeah. So out of the box, Pi Durable provides back-ends for storage to like, JSON files or to SQLite objects.
00:16:58.179 --> 00:16:59.638
And it's really easy to build more.
00:16:59.820 --> 00:17:00.820
And I think there's a few more.
00:17:00.820 --> 00:17:05.200
But so it depends on your workflow.
00:17:09.460 --> 00:17:10.460
Let me take a step back.
00:17:11.400 --> 00:17:22.407
Our refund agent, I think it would be nice for this agent to know about all the refunds that are happening.
00:17:23.460 --> 00:17:33.105
And we just want one session and you know, maybe it's happening often enough that it's annoying to you, but it's not so often that like you need to handle a hundred at the same time.
00:17:34.619 --> 00:18:11.839
So let's just have one agent somewhere that anyone in the world who's shaking their phones and sending that nasty support ticket is triaging those requests. And so in that case, you definitely want that state living in the cloud somewhere. And that's a good place for Cloudflare Durable Object which we can talk more about but just to give a like another sort of different choice that you might make in a different situation something that's happening to me that's so annoying all the time now when I'm building is my computer just kind of like grinds to a halt.
00:18:12.420 --> 00:18:32.660
Like it starts freezing and it's slow and it's usually it's like a runaway process like that's leaked, you know, there's too many Chrome tabs, I'm running out of RAM, I'm like doing too many FFmpeg renders or something.
00:18:29.460 --> 00:18:43.759
It's actually a lot of different things that's causing it. At the end of the day, it's really annoying. And this is something I just had an idea about, like today.
00:18:40.880 --> 00:18:43.759
So I haven't built this yet.
00:18:43.960 --> 00:18:54.097
But what I normally do is I go and I open Claude Code and I'm like, hey, like can you investigate and figure out what the hell's going on and like help me fix this? And it takes like ten or fifteen minutes.
00:18:54.839 --> 00:18:56.548
And in the meantime my computer's frozen.
00:18:57.279 --> 00:19:22.859
But what I actually want is an agent that's living on my computer next to me as I'm working always and if my computer runs out of batteries, if it crashes, I don't care. I still want it to be there and
I want it to be ready. And I want that state to be on my computer because I use my computer even when I'm not connected to the internet. So I don't want that in the cloud. Right?
00:19:20.160 --> 00:19:24.940
And I don't need to access it from my phone. Like, this is for my computer.
00:19:24.940 --> 00:19:27.000
This is about managing the resources on my computer.
00:19:27.000 --> 00:19:35.460
I want this agent to just always be there and keeping track of if my computer's getting slow or keeping track of all these bad things that are happening and handle them for me.
00:19:36.240 --> 00:19:46.678
So that kind of situation I want the state locally and in our refund example we want the state in the cloud somewhere.
00:19:46.940 --> 00:20:05.119
So you mentioned Cloudflare Durable Objects and I've actually also seen a lot of people building something with Pi Durable in combination with Cloudflare Durable Objects. I'm curious, like, what is Cloudflare Durable Objects and why do people like to use it together with Pi Durable? Do you know?
00:20:05.980 --> 00:20:13.119
Yeah. I think one reason is it's another thing that has durable in the name, so people just like tie them together in their brains.
00:20:13.799 --> 00:20:15.680
But there's also real reasons too.
00:20:16.180 --> 00:20:29.779
So a Cloudflare Durable Object is a primitive that works in a similar way to Pi Durable where state is decoupled from execution.
00:20:31.700 --> 00:20:56.400
And so it's a nice fit for Pi Durable so you can think of it as this magic thing that lives in the cloud, in this magical cloud which stores information and you can run code on that information to update it.
00:20:58.259 --> 00:21:00.980
And anyone, anything in the world can trigger it.
00:21:01.940 --> 00:21:18.880
And this Durable Object is smart enough to handle all requests from all around the world, serialize them so there's just sort of one at a time. And then, you know, do that work and apply it to the state.
00:21:19.779 --> 00:21:31.259
And these things can live for you know for months and months and you only pay when you are actually doing the work.
00:21:32.259 --> 00:21:41.200
So when the state is just sitting there it's free or like very, very, very cheap.
00:21:41.539 --> 00:21:58.971
OK? So why does that fit well? Right well if you remember, Pi Durable, its kind of whole identity lives in its state and the state is very well defined.
00:21:59.599 --> 00:22:07.099
And for example, you can serialize it to SQL.
00:22:02.940 --> 00:22:35.079
And there's a nice SQL adapter with Durable Objects. And so what we can do is we can put Pi Durable state in the Durable Object and then allow from anywhere in the world some system to, you know, wake up the Pi Durable agent, it gets rehydrated from its state, it does its work, whatever that is, and then it goes back to sleep.
00:22:35.740 --> 00:22:43.200
So, effectively it's a nice cloud primitive that you can put the Pi Durable agent in.
00:22:46.759 --> 00:22:48.579
It's not a whole operating system.
00:22:49.039 --> 00:22:50.339
It's not a whole big computer.
00:22:51.759 --> 00:23:05.842
It's just enough to basically run JavaScript which is what the Pi agent is written in and so you know it's just enough for what you need for the agent to kind of do its work.
00:23:07.259 --> 00:23:15.920
And if your agent needs to use a computer then it can spin up a computer to do what it needs to do as well you know with Cloudflare with another sandbox provider whatever.
00:23:15.980 --> 00:23:26.680
So people who use Cloudflare Durable Objects in combination with Pi Durable. They tend to store the state on Cloudflare.
00:23:26.880 --> 00:23:41.759
Yeah, so a Durable Object is some state and a way to run JavaScript on that state that, like, lots of people all around the world can talk to without the system breaking.
00:23:43.259 --> 00:23:46.660
The state plus a way to run JavaScript.
00:23:47.779 --> 00:23:48.890
Do you have an example?
00:23:50.579 --> 00:23:52.372
Like the payment example that you just had.
00:23:52.960 --> 00:23:54.001
How would that look like?
00:23:54.619 --> 00:24:01.440
Yeah. So that's a good example where this makes sense.
00:23:58.019 --> 00:24:06.039
The state of the agent like it's deployed to a Cloudflare Durable Object.
00:24:08.559 --> 00:24:10.299
And what is that state in that example?
00:24:10.299 --> 00:24:12.759
Is that the amounts, the price?
00:24:14.160 --> 00:24:15.720
Oh no. It's the agent's.
00:24:17.619 --> 00:24:29.140
I'm assuming you have some system for handling, you know, that all the money stuff or you're using a third party or whatever. But what's actually stored is all the state of the agents.
00:24:29.380 --> 00:24:33.579
So it's the Pi Durable state.
00:24:33.579 --> 00:24:47.500
So it's the session history, it's the configuration of the models, it's exactly you know if it was in the middle of a tool call when it went to sleep, all of that is stored and sort of remembered in the Durable Object.
00:24:47.539 --> 00:25:01.960
And so if you're just deploying it maybe you have a system prompt and you've configured some way to wake it up with a network request.
00:24:59.539 --> 00:25:02.759
And so you can imagine, like, when does it wake up?
00:25:02.759 --> 00:25:23.339
Well, when you shake the phone and the user puts in their support request to demand for a refund, and they push the button, that support ticket gets stored somewhere, and as a side effect of it storing, it sends a request to your Durable Object that has the Pi agent state and says, wake up! We have to handle this support ticket and figure out if we wanna do a refund or not, and then do it.
00:25:23.819 --> 00:25:30.019
And then that agent figures it out. If it crashes in the middle, it's OK.
00:25:30.440 --> 00:25:38.359
You can also configure it to check on a heartbeat once in a while to see if it needs to, you know, finish any work. Something like that.
00:25:39.160 --> 00:25:52.380
Right.
So do people like to use both Pi Durable and Cloudflare Durable Objects, they tend to store the agent's state on Cloudflare plus some instructions or way to tell the agent, OK, wake up and do this.
00:25:52.579 --> 00:25:57.880
Yes. That's like part of configuring the Durable Object is configuring how to talk to it.
00:25:59.200 --> 00:26:07.019
Gotcha. Cool. And why is it better to use Cloudflare than other cloud providers?
00:26:07.200 --> 00:26:09.819
Well, specifically this like Durable Object primitive.
00:26:10.019 --> 00:26:44.900
It's unique to Cloudflare. I think Amazon has some version of it as well at this point. But this is nice because it's smaller than a computer basically or some kind of like more heavy sandbox that's running at least parts of an operating system in it. A Durable Object is literally just a JavaScript engine so behind the scenes Cloudflare, they're able to schedule lots of these Durable Objects on one machine or even within a virtual machine.
00:26:45.039 --> 00:26:50.200
I don't know exactly how they're scheduled, but what that means as a user is you pay less money
00:26:52.359 --> 00:26:58.420
OK. Because the needs are very lightweight, so it doesn't make sense to go for the heavier options.
00:26:58.420 --> 00:27:00.119
This is just a lightweight option.
00:27:00.279 --> 00:27:04.519
It's also everything you need in these situations and you also pay less for it.
00:27:04.920 --> 00:27:12.853
Yeah. Yeah. And I guess it's faster as well. It's sort of cheaper in terms of time, money, efficiency, all the nice things.
00:27:13.559 --> 00:27:15.900
Alright. So. So, let me show you an example.
00:27:16.380 --> 00:27:43.380
OK. This is from Daniel Griesser? I don't know how to pronounce his name so Daniel has a very long tweet he's describing building a self-extensible agent harness that can hot-swap and hot-reload even the server run time while continuing to build itself.
00:27:44.339 --> 00:27:57.039
OK? In other words, the agent can make a change, kill itself and crash, and then recover without anything bad happening with its new changes in place.
00:27:57.700 --> 00:27:59.720
This is like what hot reloading is.
00:28:00.200 --> 00:28:12.853
Right? And then he goes on to say like the whole thing is only three thousand lines of code in the core and then you know thirty thousand in extensions. And Pi makes it really easy to have extensions and all these things.
00:28:13.140 --> 00:28:28.779
But I think like what this example illustrates that's really cool is it's leveraging the fact that Pi Durable can recover from crashes easily, to make that a feature of like, let me just crash it all the time whenever I want so that I can change itself.
00:28:30.259 --> 00:28:31.700
Just for my understanding.
00:28:34.160 --> 00:28:39.500
So he built a self-extensible harness that can crash all the time.
00:28:39.880 --> 00:28:40.920
Why does he do that?
00:28:40.920 --> 00:28:45.880
Just taking a step back, is he crashing it on purpose?
00:28:45.880 --> 00:28:48.130
Does he have a device that crashes all the time, like?
00:28:49.500 --> 00:28:56.160
It's taking this concept of malleability, malleable software, to like a further extreme.
00:28:57.859 --> 00:29:20.140
So this Pi, like the original release of Pi, introduced this concept of malleability which is the software you're using has the ability to change itself and upgrade itself. And Pi expressed this by being able to create plugins and load in the plugins while it's running.
00:29:21.220 --> 00:29:31.480
But this takes that concept to like an extreme where you can change even like the core of the thing.
00:29:31.799 --> 00:29:34.460
And why is malleability cool?
00:29:34.539 --> 00:29:54.259
It means that you can give users like the seed of the thing or as a user, especially as a builder, I want to have like my tool be shaped in exactly the right way as I need it for my task within my project.
00:29:55.099 --> 00:29:59.460
And I don't want it in some generic way that's good for everyone. I want it my way.
00:29:59.740 --> 00:30:01.559
It does everything I need and nothing else.
00:30:01.960 --> 00:30:16.740
An interesting approach to achieving that is to deliver the seed of a thing with a way to grow that seed, to grow that plant, to make the tree that I need or that any user needs for a specific thing. Does that make sense?
00:30:17.720 --> 00:30:42.180
I see. So because this agent is improving itself the whole time, there's just a very high likelihood that it might crash, things might break. And that's why it makes sense to use Pi Durable here because it's the best way to set up the agent in such a way that it can restart itself and resume.
00:30:43.000 --> 00:30:43.680
Is that right?
00:30:43.680 --> 00:31:02.539
That's a nice bonus, but the main thing is you can't change software while it's running because it's already running I mean, there are ways to do that by like having a plug-in system but then the main software that's loading the plugins, that can't change.
00:31:02.859 --> 00:31:36.940
Ultimately, you have to stop running something for it to change and so if you have a system that's not robust in the face of, like, being killed randomly, then imagine as you're kind of iterating and working on it and wanting to change it, you have to like safely shut it down and then reload and then like you know, replay everything that happened. I mean, you're basically implementing like some kind of durable system at that point.
00:31:37.559 --> 00:31:46.119
So like as you're iterating and changing this seed, you don't have to start from scratch.
00:31:46.460 --> 00:31:57.119
You don't have to, like, reset the state every time because it's durable, like, we're causing crashes on purpose to reload it.
00:31:57.119 --> 00:32:00.059
Yeah. There's not a high likelihood of crashes.
00:32:00.059 --> 00:32:02.240
It's just a necessity in the process.
00:32:02.980 --> 00:32:09.779
And that's why it makes sense to use Pi
Durable because there will be a lot of restarts or hot reloads.
00:32:11.880 --> 00:32:13.759
Yeah. That's the idea with this experiment.
00:32:13.759 --> 00:32:15.039
But I think it's really cool.
00:32:15.039 --> 00:32:19.339
Cool. Yeah. It makes sense to use Pi Durable here.
00:32:19.339 --> 00:32:20.380
That's a cool use case.
00:32:20.880 --> 00:32:23.019
OK, I'm gonna show another example.
00:32:23.279 --> 00:32:57.799
So Earendil, the company that makes Pi wrote a blog post just a few days ago that is a tutorial for building a Pi Durable agent in a Durable Object, something that we talked about before. But it's specifically telling you how to build a chat agent with multiple participants connected to the same chat session.
00:32:58.220 --> 00:33:09.660
So this is something that's really cool that's hard to do otherwise, but Pi Durable makes it really easy, which is multiplayer. There.
00:33:06.279 --> 00:33:09.660
That's the thing.
00:33:13.960 --> 00:33:50.079
So the Pi Durable like we said, it's just some state, and you can rehydrate that state and do something and then go back to sleep. So if you put that state in a Cloudflare Durable Object, remember we said it's living in the cloud somewhere and it can handle requests from all around the world concurrently and the Durable Object primitive from Cloudflare knows how to sequence these things so that, you know, it all works and like things that are happening all around the world can all act on the Durable Object one at a time.
00:33:50.599 --> 00:34:10.980
And so if you go kind of backwards, well that means that you can have one person in Australia on their phone and one person in the United States on a laptop and you can connect to the same Durable Object that's hosting your Pi Durable state that's running your agent and talk to it.
00:34:11.920 --> 00:34:23.179
And you know whoever goes first goes first and then you know the messages go in. You could even steer the agent mid-conversation. Does that make sense?
00:34:23.179 --> 00:34:42.420
Oh, that's super cool. So Pi Durable, you know, it's not only like really nice when you need the robustness of recovering from a crash and resume a workflow, but it's also really helpful to do multiplayer vibe coding I guess.
00:34:43.659 --> 00:34:59.239
Well, multiplayer anything. Yeah. Yeah, I guess this would be a multiplayer ChatGPT clone but you could also build a multiplayer vibe coding system or anything else that you'd use with agents. So.
00:35:00.019 --> 00:35:00.880
That's very cool.
00:35:01.639 --> 00:35:12.179
Yeah. And then one other thing so this is a post from Mario Zechner, the original creator of Pi.
00:35:12.219 --> 00:35:13.619
He now works at Earendil.
00:35:13.940 --> 00:35:27.360
In his tweet he describes that he's replacing Claude for Android with a little Pi Durable thing, that's his words, that runs fully on his phone except for the actual model call, right?
00:35:27.699 --> 00:35:28.619
So this is cool, right?
00:35:28.619
--> 00:35:48.440
I think we maybe didn't say this exactly, but remember, since Pi Durable is just like some state, it's like the state is very well defined and then there just needs to be a little bit of logic that can kind of run to drive that state, to you know, do the next step of your agent and that runs in JavaScript.
00:35:49.119 --> 00:35:54.440
And so if you have a way to store the state and you have a way to run JavaScript, then you can run it.
00:35:55.860 --> 00:36:23.980
So what Mario did is he put that state on his phone and he runs that JavaScript in an app on his phone and then there it is and this would be hard to do otherwise to take an off-the-shelf harness even if it's written in JavaScript and get it working in a native app, for example but Pi Durable, you know, makes that easy.
00:36:24.920 --> 00:36:29.599
Because, you know, if you wanted to work in a native app, what would you need to do instead?
00:36:29.940 --> 00:36:32.480
You have to build an agent, basically.
00:36:34.000 --> 00:37:11.920
And apps they are suspended a lot and they're evicted and shut down all the time by the operating system or the person runs out of batteries on their phone or whatever. So if the agent that you're using on that device is not durable then you're gonna have a hard time with it and then yeah like we said like without Pi Durable if you wanna build a durable agent if you take like an existing normal agent as a starting point, you have to write a lot of logic to make it safe or you can kind of re-architect the thing from scratch and then you end up with something like Pi Durable.
00:37:12.880 --> 00:37:26.539
Gotcha. So you know if Mario would have used OpenClaw here, it wouldn't be durable. And if you wanted to make his OpenClaw durable then he would have needed to write a lot of code.
00:37:27.119 --> 00:37:32.440
But basically with Pi Durable you could just have it working right away on your phone in a very easy way.
00:37:33.760 --> 00:37:34.900
Yep. Exactly.
00:37:35.219 --> 00:37:37.519
I love these examples that you showed.
00:37:37.519 --> 00:37:44.780
They all use Pi Durable in a different way I wonder have you built something with Pi Durable as well?
00:37:45.079 --> 00:37:49.340
Yeah, so I was trying to do an experiment.
00:37:49.900 --> 00:37:56.920
OK? So I used Pi Durable, I put it into a Durable Object.
00:37:58.199 --> 00:38:30.380
And what I'm curious about that I haven't seen anyone play with is the fact that the Pi Durable state is very well defined. And I mean it has to be because, you know, the way that you store it is configurable and the whole point is that it can rehydrate itself from that state to run. And so what I thought was like, is there something that we can do with that state without actually waking up the agent to do something and move the state forward?
00:38:31.179 --> 00:38:41.900
So could we somehow digest that information and visualize it to a human or to an agent so you know what's in that state right?
00:38:41.900 --> 00:38:48.000
It's like yeah there's a conversation history but you can get that from any harness.
00:38:48.320 --> 00:39:23.019
The things that are interesting inside of Pi durable's state is we know all of the tasks that ran and which ones were aborted, which ones did, like, a crash happen? And so obviously, like, this is a function of what your agent's doing, but you're able to easily, you know, one could imagine for our refund agent that you could visualize well how often refunds are happening but also like how often you're trying to do them and something's going wrong, like the payment provider or something like that.
00:39:23.019 --> 00:39:38.980
Yeah. How efficient your agents performed or you know did this. Maybe you know maybe you know that it worked, the payments went through correctly, but you don't know during the process how many times the agent might have tried it.
00:39:38.980 --> 00:40:10.719
You don't have to reverse engineer that from like the different surfaces that you're touching you know, you can get that all from the information of the agent or like multiplayer, like if we have multiplayer, how do we keep track of what's going on and you know, can we visualize who's doing what and when and how? And that might be important you know if you're building a chat bot that has the ability to do something you know, it's something you might wanna keep track of.
00:40:10.719 --> 00:40:21.920
Yeah because previously you know we never had such detailed information about every task but because Pi Durable just inherently already logs or keeps track of every checkpoint.
00:40:21.920 --> 00:40:27.380
You suddenly have a new pile of data that you could use to build new things on top of it.
00:40:29.679 --> 00:40:43.079
And I think it's a good point with multiplayer as well what you said because when it's multiplayer you might want to have the data to analyze like OK, which agent from which person in this team, you know, performed well?
00:40:44.360 --> 00:40:47.300
What configurations did they use and what made it perform better?
00:40:48.179 --> 00:40:55.239
All of these things really, like you could add extra code to handle, but it's just nice that it's all there.
00:40:56.280 --> 00:41:01.960
It's all there already for you to mine and that's interesting.
00:41:02.639 --> 00:41:09.039
Yeah, that's a really good point. I love all these examples you've shown and also this idea.
00:41:09.039 --> 00:41:19.480
Feels like you could do actually many different things with Pi Durable. More than I imagined on a first impression.
00:41:17.400 --> 00:41:19.480
Thanks, Brandon.
00:41:19.599 --> 00:41:22.139
I think that's a really interesting shift here.
00:41:22.320 --> 00:41:30.139
So we're going from giving coding agents individual tasks to building workflows where agents can take on ongoing responsibilities.
00:41:31.099 --> 00:41:34.659
And Pi Durable gives us a new primitive for that.
00:41:35.619 --> 00:42:14.400
So there's recoverable execution that we can now build on without having to implement all that durability ourselves it enables multiplayer interactions with the agent since you can now make the persistent state accessible to different people through Cloudflare Durable Objects and also accessible to different applications and events. And it's also way more transparent to inspect tasks, tool calls, and any other state or actions that the agent has done and it's easy to run it on your computer, phone, web browser, anywhere.
00:42:09.610 --> 00:42:24.500
Alright, hopefully this episode gave you all some ideas for new durable agent workflows you could build so you can also confidently delegate more work to your agents.
00:42:25.739 --> 00:42:31.820
We'll be back next week with another emerging practice for building with coding agents and we hope to see you then.