github cloudflare/agents @cloudflare/think@0.2.0

latest releases: @cloudflare/ai-chat@0.4.0, @cloudflare/voice@0.0.5
8 hours ago

Minor Changes

  • #1270 87b4512 Thanks @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.messages backed by session.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 composition
    • onChatResponse() 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 redaction
    • messageConcurrency strategies (queue/latest/merge/drop/debounce)
    • resetTurnState() extracted as protected method
    • unstable_chatRecovery with runFiber wrapping on all 4 turn paths
    • onChatRecovery() hook with ChatRecoveryContext
    • hasPendingInteraction() / waitUntilStable() for quiescence detection
    • Re-export Session from @cloudflare/think
    • Constructor wraps onStart — subclasses never need super.onStart()

    agents (agents/chat):

    • Extract AbortRegistry, applyToolUpdate + builders, parseProtocolMessage into shared agents/chat layer
    • Add applyChunkToParts export for fiber recovery

    AIChatAgent (@cloudflare/ai-chat):

    • Refactor to use shared AbortRegistry from agents/chat
    • Add continuation flag to OnChatMessageOptions
    • Export getAgentMessages() and tool part helpers
    • Add getHttpUrl() to useAgent return value
  • #1256 dfab937 Thanks @threepointone! - Add durable fiber execution to the Agent base class.

    runFiber(name, fn) registers work in SQLite, holds a keepAlive ref, and enables recovery via onFiberRecovered after DO eviction. ctx.stash() and this.stash() checkpoint progress that survives eviction.

    AIChatAgent gains unstable_chatRecovery — when enabled, each chat turn is wrapped in a fiber. onChatRecovery provides provider-specific recovery (Workers AI continuation, OpenAI response retrieval, Anthropic synthetic message). continueLastTurn() appends to the interrupted assistant message seamlessly.

    Think now extends Agent directly (no mixin). Fiber support is inherited from the base class.

    Breaking (experimental APIs only):

    • Removed withFibers mixin (agents/experimental/forever)
    • Removed withDurableChat mixin (@cloudflare/ai-chat/experimental/forever)
    • Removed ./experimental/forever export from both packages
    • Think no longer has a fibers flag — recovery is automatic via alarm housekeeping

Don't miss a new agents release

NewReleases is sending notifications on new releases.