Repository navigation
Replies: 2 comments
|
This does look like a lifecycle mismatch in the current cleanup model. If retention cleanup only runs when the same Durable Object later completes another stream, then one-chat-per-DO deployments will naturally accumulate old rows even when the application no longer needs them. |
|
The implementation has changed since this report. On current Normal message persistence now settles the stream and drops its buffer rows in the same transaction. Remaining terminal streams are reclaimed on the next stream start. The adapter also includes migration of the legacy Sources:
I would check your installed |
Uh oh!
There was an error while loading. Please reload this page.
Hi Cloudflare Agents team,
First of all, thank you for
@cloudflare/agentsand@cloudflare/ai-chat— they’ve been really helpful for building resumable streaming on Workers.I am using
AIChatAgentwith a common pattern: one Durable Object instance per chat (e.g. DO name =chatId). While reviewing storage growth, I noticed the built-in cleanup logic runs inside_completeStream()via_maybeCleanupOldStreams().From the current implementation, cleanup is:
CLEANUP_INTERVAL_MS(10 minutes)status = 'completed'streams older thanCLEANUP_AGE_THRESHOLD_MS(24 hours)cf_ai_chat_stream_chunksandcf_ai_chat_stream_metadataThis seems to imply the following behavior:
If a given DO instance (chatId) becomes inactive after a single conversation (i.e. no more stream completions happen in that DO), then its SQLite tables (
cf_ai_chat_stream_chunks,cf_ai_chat_stream_metadata) may never be cleaned up, because_maybeCleanupOldStreams()will not be called again for that DO.In our app, we persist final messages to Postgres as the source of truth, so we don’t need the DO to retain completed stream chunks long-term. We currently override
_completeStream()to delete that stream’s chunks/metadata immediately to keep DO storage bounded, but we’re not sure if that’s the recommended approach.Questions / request for guidance:
All reactions