@cloudflare/ai-chat@0.4.5
cloudflare/agents@cloudflare/ai-chat@0.4.5Apr 18, 2026by github-actions[bot]
AI Summary
This patch release exposes the `createdAt` timestamp on both `FiberRecoveryContext` and `ChatRecoveryContext`, allowing applications to detect and suppress continuations for stale, interrupted conversation turns. The field contains epoch milliseconds when `runFiber` started, read from the existing `cf_agents_runs` tracking data.
Key Highlights
- Added `createdAt: number` field to `FiberRecoveryContext` (epoch milliseconds when runFiber started)
- Added `createdAt: number` field to `ChatRecoveryContext` in both `@cloudflare/ai-chat` and `@cloudflare/think`
- Enables stale-recovery guard pattern to prevent continuations on old interrupted turns
- Includes new documentation section 'Guarding against stale recoveries' in docs/chat-agents.md
- No breaking changes - existing callers experience no behavior change
New Features
- Exposed `createdAt` timestamp on `FiberRecoveryContext` from `agents` package
- Exposed `createdAt` timestamp on `ChatRecoveryContext` from `@cloudflare/ai-chat` and `@cloudflare/think` packages
- Enables stale-recovery guard pattern implementation (e.g., `if (Date.now() - ctx.createdAt > 2 * 60 * 1000) return { continue: false }`)
Full Release Notes
### Patch Changes
- [#1332](https://github.com/cloudflare/agents/pull/1332) [`7cb8acf`](https://github.com/cloudflare/agents/commit/7cb8acff8281a30bc17980e506ab5582f3cb1c72) Thanks [@threepointone](https://github.com/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](https://github.com/cloudflare/agents/issues/1324) is a short override:
```typescript
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`.