@cloudflare/ai-chat@0.4.6
cloudflare/agents@cloudflare/ai-chat@0.4.6Apr 18, 2026by github-actions[bot]
AI Summary
A patch fix that improves the reliability of `waitForIdle` and `waitUntilStable` helpers by ensuring they properly drain in-flight submits that have passed the concurrency decision but haven't yet entered the turn queue, fixing a race condition and resolving a long-standing flaky test.
Key Highlights
- Fixed `waitForIdle` and `waitUntilStable` to drain in-flight submits that passed concurrency decision but haven't entered turn queue
- Resolved race condition where these helpers could return while a submit was still tracked in `_pendingEnqueueCount`
- Fixed long-standing flaky test 'merge concatenates overlapping queued user messages into one follow-up turn'
- Bumped test stream durations (10×100ms → 15×150ms) to give WS dispatch enough headroom under CI load
Full Release Notes
### Patch Changes
- [#1340](https://github.com/cloudflare/agents/pull/1340) [`3cbe776`](https://github.com/cloudflare/agents/commit/3cbe77668df356906244db6a75c4cfba2daa1836) Thanks [@threepointone](https://github.com/threepointone)! - `waitForIdle` and `waitUntilStable` now also drain in-flight submits that have passed the concurrency decision but haven't yet entered the turn queue (i.e. submits mid-`persistMessages`). Previously these helpers only awaited `_turnQueue.waitForIdle()`, which could return while a submit was still tracked in `_pendingEnqueueCount` — racing with anything that called them (tests, recovery code, callers waiting for quiescence).
Fixes a long-standing flake in the `merge concatenates overlapping queued user messages into one follow-up turn` test. The test's stream durations are also bumped (10×100ms → 15×150ms) to give the WS dispatch enough headroom under CI load to bump `_latestOverlappingSubmitSequence` before the first turn finishes.