Minor Changes
-
#1264
95b4d6aThanks @threepointone! - RenamedurableStreamingtounstable_chatRecovery. Fix abort controller leak whenonChatMessagethrows. Wrap all 4 chat turn paths (WS, auto-continuation, programmatic, continueLastTurn) inrunFiberwhen enabled. Guard_chatRecoveryContinueagainst stale continuations viatargetAssistantIdin schedule payload. -
#1256
dfab937Thanks @threepointone! - Add durable fiber execution to the Agent base class.runFiber(name, fn)registers work in SQLite, holds akeepAliveref, and enables recovery viaonFiberRecoveredafter DO eviction.ctx.stash()andthis.stash()checkpoint progress that survives eviction.AIChatAgentgainsunstable_chatRecovery— when enabled, each chat turn is wrapped in a fiber.onChatRecoveryprovides provider-specific recovery (Workers AI continuation, OpenAI response retrieval, Anthropic synthetic message).continueLastTurn()appends to the interrupted assistant message seamlessly.Thinknow extendsAgentdirectly (no mixin). Fiber support is inherited from the base class.Breaking (experimental APIs only):
- Removed
withFibersmixin (agents/experimental/forever) - Removed
withDurableChatmixin (@cloudflare/ai-chat/experimental/forever) - Removed
./experimental/foreverexport from both packages - Think no longer has a
fibersflag — recovery is automatic via alarm housekeeping
- Removed
Patch Changes
-
#1270
87b4512Thanks @threepointone! - Wire Session into Think as the storage layer, achieving full feature parity with AIChatAgent plus Session-backed advantages.Think (
@cloudflare/think):- Session integration:
this.messagesbacked bysession.getHistory(), tree-structured messages, context blocks, compaction, FTS5 search configureSession()override for context blocks, compaction, search, skills (sync or async)assembleContext()returns{ system, messages }with context block compositiononChatResponse()lifecycle hook fires from all turn paths- Non-destructive regeneration via
trigger: "regenerate-message"with Session branching saveMessages()for programmatic turn entry (scheduled responses, webhooks, proactive agents)continueLastTurn()for extending the last assistant response- Custom body persistence across hibernation
sanitizeMessageForPersistence()hook for PII redactionmessageConcurrencystrategies (queue/latest/merge/drop/debounce)resetTurnState()extracted as protected methodunstable_chatRecoverywithrunFiberwrapping on all 4 turn pathsonChatRecovery()hook withChatRecoveryContexthasPendingInteraction()/waitUntilStable()for quiescence detection- Re-export
Sessionfrom@cloudflare/think - Constructor wraps
onStart— subclasses never needsuper.onStart()
agents (
agents/chat):- Extract
AbortRegistry,applyToolUpdate+ builders,parseProtocolMessageinto sharedagents/chatlayer - Add
applyChunkToPartsexport for fiber recovery
AIChatAgent (
@cloudflare/ai-chat):- Refactor to use shared
AbortRegistryfromagents/chat - Add
continuationflag toOnChatMessageOptions - Export
getAgentMessages()and tool part helpers - Add
getHttpUrl()touseAgentreturn value
- Session integration: