github cloudflare/agents @cloudflare/ai-chat@0.4.5

Patch Changes

  • #1332 7cb8acf Thanks @threepointone! - Expose createdAt on fiber and chat recovery contexts so apps can suppress continuations for stale, interrupted turns.

    • FiberRecoveryContext (from agents) gains createdAt: number — epoch milliseconds when runFiber started, read from the cf_agents_runs row that was already tracked internally.
    • ChatRecoveryContext (from @cloudflare/ai-chat and @cloudflare/think) gains the same createdAt field, threaded through from the underlying fiber.

    With this, the stale-recovery guard pattern described in #1324 is a short override:

    override async onChatRecovery(ctx: ChatRecoveryContext): Promise<ChatRecoveryOptions> {
      if (Date.now() - ctx.createdAt > 2 * 60 * 1000) return { continue: false };
      return {};
    }

    No behavior change for existing callers. See docs/chat-agents.md (new "Guarding against stale recoveries" section) for the full recipe, including a loop-protection pattern using onChatResponse.

Don't miss a new agents release

NewReleases is sending notifications on new releases.