Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/alchemy-cloudflare/src/ChatSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* The agent reads and changes the repos' files through fold's file tools, runs commands in the workspace's
* shell through {@link bashTool}, and loads skills from each repo's `.claude/skills` and `.agents/skills`.
*
* Every turn runs under a {@link Keepalive} lease so the object is not evicted mid-run. A turn can still
* be cut off - a crash, a deploy - leaving the root's user message with no finished run after it. When a
* A turn can be cut off - a crash, a deploy - leaving the root's user message with no finished run after it.
* Every turn runs under a {@link Keepalive} lease, whose alarm wakes an object cut off this way; when a
* written log activates in that state, the object nudges the root to continue.
* Fold fills any tool call the cut left without a result, and the model can resume a cut-off subagent
* by id itself. A turn that keeps getting cut off stops being nudged after {@link MAX_RESTART_NUDGES}.
Expand Down
10 changes: 6 additions & 4 deletions examples/alchemy-cloudflare/src/Keepalive.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/**
* Keeps a Durable Object from being evicted while work runs. A turn's model calls are outgoing fetches,
* which do not count as activity, so a turn that outlives its caller could be evicted mid-run. Like the
* Cloudflare Agents SDK's `keepAliveWhile`, each piece of work holds a lease, and while any lease is held
* the object's alarm fires every {@link HEARTBEAT_MILLIS} and re-arms itself.
* Wakes a Durable Object that lost a running turn. Pending work - model calls, calls to the Computer, timers -
* keeps the object in memory without a connected client (compatibility date 2026-10-01 and later), but a
* deploy or crash can still end it mid-turn, and nothing else would wake it before the next message. So
* each piece of work holds a lease, and while any lease is held the object's alarm fires every
* {@link HEARTBEAT_MILLIS} and re-arms itself. An alarm that finds the object restarted wakes it, and the
* object continues the cut-off turn as it starts (see ChatSession).
*/
import * as Cloudflare from 'alchemy/Cloudflare'
import { Clock, Context, Effect, Layer, Ref } from 'effect'
Expand Down
4 changes: 3 additions & 1 deletion examples/alchemy-cloudflare/src/Worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export default Cloudflare.Worker(
'ChatWorker',
{
main: import.meta.url,
compatibility: { flags: ['nodejs_compat'], date: '2026-08-31' },
// 2026-10-01: pending calls to other Durable Objects, containers and timers keep a Durable Object in
// memory with no client connected, so a turn whose client has gone runs on.
compatibility: { flags: ['nodejs_compat'], date: '2026-10-01' },
},
Effect.gen(function* () {
return { fetch: yield* HttpRouter.toHttpEffect(ChatRoutes) }
Expand Down
4 changes: 3 additions & 1 deletion examples/alchemy-cloudflare/src/computer/ComputerWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import { COMPUTER_WORKER_NAME } from './Contract'
export const ComputerWorker = Cloudflare.Worker('ComputerWorker', {
name: COMPUTER_WORKER_NAME,
main: './src/computer/Computer.ts',
compatibility: { flags: ['nodejs_compat'], date: '2026-08-31' },
// 2026-10-01: pending calls to other Durable Objects, containers and timers keep a Durable Object in
// memory with no client connected, so a command whose caller has gone runs on.
compatibility: { flags: ['nodejs_compat'], date: '2026-10-01' },
env: {
// The Computer Durable Object with its container. Named COMPUTER_BINDING: the shell and the container
// call back into the Computer through this binding.
Expand Down
Loading