Skip to content

feat(cloudflare): Rotate agent conversation id on chat clear - #22720

Merged
JPeer264 merged 2 commits into
jp/cloudflare-instrument-agentsfrom
jp/cloudflare-instrument-reset-conv-id
Jul 28, 2026
Merged

feat(cloudflare): Rotate agent conversation id on chat clear#22720
JPeer264 merged 2 commits into
jp/cloudflare-instrument-agentsfrom
jp/cloudflare-instrument-reset-conv-id

Conversation

@JPeer264

Copy link
Copy Markdown
Member

Within agents or workers-ai there is no concept of conversation IDs. In the main PR it was kept simple and only the name was taken in order to retrieve the conversation ID. When using const { clearHistory } = useAgent() from the frontend, then the event message:clear is being called as an event (https://developers.cloudflare.com/agents/runtime/operations/observability/#message-tool-and-submission-events).

This shows 3 transcripts all cleared with clearHistory: https://sentry-sdks.sentry.io/explore/traces/trace/0666c413e4104032a349056ed8c51f8a/?tab=ai-spans

@JPeer264 JPeer264 self-assigned this Jul 27, 2026
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 29.85 kB - -
@sentry/browser - with treeshaking flags 28.05 kB - -
@sentry/browser (incl. Tracing) 47.42 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 47.43 kB - -
@sentry/browser (incl. Tracing, Profiling) 52.16 kB - -
@sentry/browser (incl. Tracing, Replay) 86.74 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 76.16 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 91.48 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 104.11 kB - -
@sentry/browser (incl. Feedback) 47.16 kB - -
@sentry/browser (incl. sendFeedback) 34.69 kB - -
@sentry/browser (incl. FeedbackAsync) 39.78 kB - -
@sentry/browser (incl. Metrics) 30.92 kB - -
@sentry/browser (incl. Logs) 31.14 kB - -
@sentry/browser (incl. Metrics & Logs) 31.83 kB - -
@sentry/react 31.64 kB - -
@sentry/react (incl. Tracing) 49.64 kB - -
@sentry/vue 34.77 kB - -
@sentry/vue (incl. Tracing) 49.37 kB - -
@sentry/svelte 29.88 kB - -
CDN Bundle 31.89 kB - -
CDN Bundle (incl. Tracing) 47.76 kB - -
CDN Bundle (incl. Logs, Metrics) 33.44 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.14 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 72.8 kB - -
CDN Bundle (incl. Tracing, Replay) 85.4 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.68 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.17 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.47 kB - -
CDN Bundle - uncompressed 95.12 kB - -
CDN Bundle (incl. Tracing) - uncompressed 143.26 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 99.83 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 147.25 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 224.6 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 262.52 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 266.49 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 276.23 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 280.18 kB - -
@sentry/nextjs (client) 52.23 kB - -
@sentry/sveltekit (client) 47.84 kB - -
@sentry/core/server 79.73 kB - -
@sentry/core/browser 51.61 kB - -
@sentry/node 122.35 kB - -
@sentry/node/import (ESM hook with diagnostics-channel injection) 166 B - -
@sentry/node - without tracing 85.75 kB - -
@sentry/aws-serverless 93.77 kB - -
@sentry/cloudflare (withSentry) - minified 197.53 kB +0.14% +269 B 🔺
@sentry/cloudflare (withSentry) 485.64 kB +0.09% +399 B 🔺

View base workflow run

@JPeer264
JPeer264 force-pushed the jp/cloudflare-instrument-reset-conv-id branch from c842206 to 04a692d Compare July 27, 2026 19:38
@JPeer264
JPeer264 force-pushed the jp/cloudflare-instrument-reset-conv-id branch 2 times, most recently from f7d5470 to 7fb8e0d Compare July 28, 2026 06:15
@JPeer264
JPeer264 marked this pull request as ready for review July 28, 2026 06:16
@JPeer264
JPeer264 requested a review from a team as a code owner July 28, 2026 06:16
@JPeer264
JPeer264 requested review from andreiborza and isaacs and removed request for a team July 28, 2026 06:16
@JPeer264
JPeer264 force-pushed the jp/cloudflare-instrument-reset-conv-id branch from 7fb8e0d to 9b6f0c3 Compare July 28, 2026 07:29
@JPeer264
JPeer264 force-pushed the jp/cloudflare-instrument-reset-conv-id branch from 2e1b802 to ddb3946 Compare July 28, 2026 13:35
JPeer264 and others added 2 commits July 28, 2026 17:05
Clearing an agent's chat should start a fresh conversation in Sentry's
AI monitoring, but recreating the Durable Object for that would drop the
per-instance MCP/OAuth state (GitHub/Sentry sign-in). Instead, watch the
WebSocket stream for cf_agent_chat_clear and rotate an in-memory
conversation id on the instance, falling back to the instance name before
the first clear — a fresh conversation id per reset while the instance
(and its auth) stays put.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@JPeer264
JPeer264 force-pushed the jp/cloudflare-instrument-reset-conv-id branch from ddb3946 to e9cb8bc Compare July 28, 2026 14:05
@JPeer264
JPeer264 merged commit 214d1a8 into develop Jul 28, 2026
84 of 112 checks passed
@JPeer264
JPeer264 deleted the jp/cloudflare-instrument-reset-conv-id branch July 28, 2026 17:15
JPeer264 added a commit that referenced this pull request Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants