René's URL Explorer Experiment


Title: feat(sdk): onEvent observability callback on the chat transport by ericallam · Pull Request #4187 · triggerdotdev/trigger.dev · GitHub

Open Graph Title: feat(sdk): onEvent observability callback on the chat transport by ericallam · Pull Request #4187 · triggerdotdev/trigger.dev

X Title: feat(sdk): onEvent observability callback on the chat transport by ericallam · Pull Request #4187 · triggerdotdev/trigger.dev

Description: Summary sendMessage from useChat gives no feedback about whether a message actually reached the backend, and the fetch override is wire-level: it requires knowing endpoint semantics, cannot attribute requests to messages, and misses the headStart first-turn POST entirely. This adds a typed onEvent observability callback to TriggerChatTransport / useTriggerChatTransport so send-success metrics, time-to-first-token, and "sent but never answered" watchdogs become a few lines of client code. Example const transport = useTriggerChatTransport({ task: "my-chat", accessToken: ({ chatId }) => mintChatAccessToken(chatId), onEvent: (event) => { switch (event.type) { case "message-sent": // Durably acknowledged by the session's input stream, not just "request accepted". metrics.increment("chat.message_sent", { source: event.source }); metrics.timing("chat.send_duration_ms", event.durationMs); break; case "message-send-failed": metrics.increment("chat.message_send_failed", { status: event.status }); break; case "first-chunk": metrics.timing("chat.ttft_ms", event.sinceSendMs ?? 0); break; case "turn-completed": metrics.timing("chat.turn_duration_ms", event.sinceSendMs ?? 0); break; } }, }); Design One callback, one discriminated union (ChatTransportEvent): message-sent / message-send-failed: terminal send outcomes with messageId, a source discriminator (submit, regenerate, steer, action, stop, head-start), durationMs, bodyBytes, the append's idempotency key (partId, also stored on the server-side record), and error + HTTP status on failure. message-sent means the append was durably acknowledged, after any internal token-refresh retries. stream-connected (with a resumed flag and the cursor it connected from), first-chunk (chunk type plus sinceSendMs for time-to-first-token), turn-completed (sinceSendMs full-turn latency and the agent's committed input cursor), and stream-error follow the response side, so a send can be paired with the answer that should follow it. messageId on response events is client-side attribution from the last turn-producing send on that chat. Emissions sit at the transport's existing choke points, covering every send path uniformly (including steering and headStart, which the fetch override cannot observe). Exceptions thrown by the callback are swallowed: observability can never break the chat. The React hook keeps the callback live across renders instead of freezing the first-render closure. Verification Unit tests drive the transport directly with the fetch override as the network stub (send success/failure per source, stream lifecycle, resumed flag, field enrichment, callback exceptions swallowed). Verified end-to-end against a realistic metrics setup in the ai-chat reference app (counters, send-duration and TTFT histograms, and both watchdogs built purely on these events): a healthy two-turn chat produces exactly the expected event sequence and TTFT values; an oversized append records message_send_failed with status 413; and killing the worker after a durable send fires both sent_but_no_stream and sent_but_unanswered, reproducing and detecting the "message disappeared" failure mode that motivated this feature.

Open Graph Description: Summary sendMessage from useChat gives no feedback about whether a message actually reached the backend, and the fetch override is wire-level: it requires knowing endpoint semantics, cannot attribu...

X Description: Summary sendMessage from useChat gives no feedback about whether a message actually reached the backend, and the fetch override is wire-level: it requires knowing endpoint semantics, cannot attribu...

Opengraph URL: https://github.com/triggerdotdev/trigger.dev/pull/4187

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:98b21fa7-6121-0a4b-e6a3-78fb4ce212ff
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idAAB4:3098FD:3BEF89:5890C7:6AFAE4B4
html-safe-noncef9730367862effdff7a0da18ca14e203133f9b72f0020ae35f36196942401e42
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQUI0OjMwOThGRDozQkVGODk6NTg5MEM3OjZBRkFFNEI0IiwidmlzaXRvcl9pZCI6Ijg2NTA0MDQ5MjAxMTg5Mjg1NjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac49ed7038a9367287a9df615ee6cb6521a80208ccb325994e9e72cd8e20f1c869
hovercard-subject-tagpull_request:4009850169
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/triggerdotdev/trigger.dev/pull/4187/files
twitter:imagehttps://avatars.githubusercontent.com/u/534?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/534?s=400&v=4
og:image:altSummary sendMessage from useChat gives no feedback about whether a message actually reached the backend, and the fetch override is wire-level: it requires knowing endpoint semantics, cannot attribu...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None0178036d8230524a18422872393ab7e708443ae4c2047f758560a2db870c1913
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/triggerdotdev/trigger.dev git https://github.com/triggerdotdev/trigger.dev.git
octolytics-dimension-user_id95297378
octolytics-dimension-user_logintriggerdotdev
octolytics-dimension-repository_id572570113
octolytics-dimension-repository_nwotriggerdotdev/trigger.dev
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id572570113
octolytics-dimension-repository_network_root_nwotriggerdotdev/trigger.dev
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release12fff95459b24b0f882a66698ee6a36a5934d247
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/triggerdotdev/trigger.dev/pull/4187/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fpull%2F4187%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fpull%2F4187%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=triggerdotdev%2Ftrigger.dev
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/4187/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/4187/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/4187/files
triggerdotdevhttps://github.com/triggerdotdev
trigger.devhttps://github.com/triggerdotdev/trigger.dev
Codehttps://github.com/triggerdotdev/trigger.dev
Issues203 (203)https://github.com/triggerdotdev/trigger.dev/issues
Pull requests66 (66)https://github.com/triggerdotdev/trigger.dev/pulls
Discussionshttps://github.com/triggerdotdev/trigger.dev/discussions
Actionshttps://github.com/triggerdotdev/trigger.dev/actions
Projectshttps://github.com/triggerdotdev/trigger.dev/projects
Security and quality39 (39)https://github.com/triggerdotdev/trigger.dev/security
Insightshttps://github.com/triggerdotdev/trigger.dev/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2Fnew%2Fchoose
ericallamhttps://github.com/ericallam
mainhttps://github.com/triggerdotdev/trigger.dev/tree/main
feature/tri-11786-transport-observability-hook-onevent-with-typed-send-streamhttps://github.com/triggerdotdev/trigger.dev/tree/feature/tri-11786-transport-observability-hook-onevent-with-typed-send-stream
Conversation 22 https://github.com/triggerdotdev/trigger.dev/pull/4187
Commits 9 https://github.com/triggerdotdev/trigger.dev/pull/4187/commits
Checks 60 https://github.com/triggerdotdev/trigger.dev/pull/4187/checks
Files changed https://github.com/triggerdotdev/trigger.dev/pull/4187/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4187/files
feat(sdk): onEvent observability callback on the chat transport https://github.com/triggerdotdev/trigger.dev/pull/4187/files#top
Show all changes 9 commits https://github.com/triggerdotdev/trigger.dev/pull/4187/files
f6de9a5 feat(sdk): onEvent observability callback on the chat transport ericallam Jul 7, 2026 https://github.com/triggerdotdev/trigger.dev/pull/4187/commits/f6de9a5820733676a412c0ca1a8c44793c26d59a
54fa790 feat(sdk): enrich transport events with correlation and timing fields ericallam Jul 7, 2026 https://github.com/triggerdotdev/trigger.dev/pull/4187/commits/54fa7907d026a5acb6eb00131760075208dd8f64
27fcb0d chore: show the enriched events in the changeset example ericallam Jul 7, 2026 https://github.com/triggerdotdev/trigger.dev/pull/4187/commits/27fcb0d59fa413978729a2c968e3eccd85a940e2
259fb01 chore: tighten the changeset ericallam Jul 7, 2026 https://github.com/triggerdotdev/trigger.dev/pull/4187/commits/259fb01f68eba2406736d0e1ca58683a0dd7d92a
55ec228 docs(ai-chat): drop the unbounded chatId metric tag from the watchdog… ericallam Jul 7, 2026 https://github.com/triggerdotdev/trigger.dev/pull/4187/commits/55ec228871b348452bee3094a56db0d7e88a27a7
78deb6c docs(ai-chat): note the watchdog map scope and intentional chat keying ericallam Jul 8, 2026 https://github.com/triggerdotdev/trigger.dev/pull/4187/commits/78deb6c186e2e93c9f730b894e0b7b7f1f121a72
43d4a9b fix(sdk): re-arm the first-chunk event per turn on watch-mode streams ericallam Jul 8, 2026 https://github.com/triggerdotdev/trigger.dev/pull/4187/commits/43d4a9b22afff068a6e5c32fa0250f7faf937542
2434ee0 feat(sdk): emit stream lifecycle events on the headStart first-turn path ericallam Jul 8, 2026 https://github.com/triggerdotdev/trigger.dev/pull/4187/commits/2434ee0f61921da6e67bb6a40af60b572f55a574
a917250 fix(sdk): emit stream-error on the headStart response path ericallam Jul 8, 2026 https://github.com/triggerdotdev/trigger.dev/pull/4187/commits/a91725096971fedc944346f74cfe5ed9898e9cb0
Clear filters https://github.com/triggerdotdev/trigger.dev/pull/4187/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4187/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4187/files
chat-transport-onevent.md https://github.com/triggerdotdev/trigger.dev/pull/4187/files#diff-966f79482203ea87f81a7912218278671fa060a2c54abe2c1ae73fca902ac4ab
frontend.mdx https://github.com/triggerdotdev/trigger.dev/pull/4187/files#diff-0ca382a5d50361ead811d9e36ac14fe4767f49ee2e751b45b77cb45712902e87
reference.mdx https://github.com/triggerdotdev/trigger.dev/pull/4187/files#diff-58e648685c48d39e8d19f714ccdb9a6eca84024f3490b656f62a0ff535a22f3d
chat-react.ts https://github.com/triggerdotdev/trigger.dev/pull/4187/files#diff-bd66505962858e47bbc1ab2ae3b1422b22cd1365d0ff53a87e201b3c8d661372
chat.ts https://github.com/triggerdotdev/trigger.dev/pull/4187/files#diff-fcabf40729dcab619f789d289291c0187dcc76366e51bf53dfe5bb6225587420
chat-transport-events.test.ts https://github.com/triggerdotdev/trigger.dev/pull/4187/files#diff-e845612269862dcc918347582a7595361a24acad6f097325fc43eefa35e89508
.changeset/chat-transport-onevent.mdhttps://github.com/triggerdotdev/trigger.dev/pull/4187/files#diff-966f79482203ea87f81a7912218278671fa060a2c54abe2c1ae73fca902ac4ab
View file https://github.com/triggerdotdev/trigger.dev/blob/a91725096971fedc944346f74cfe5ed9898e9cb0/.changeset/chat-transport-onevent.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4187/{{ revealButtonHref }}
docs/ai-chat/frontend.mdxhttps://github.com/triggerdotdev/trigger.dev/pull/4187/files#diff-0ca382a5d50361ead811d9e36ac14fe4767f49ee2e751b45b77cb45712902e87
View file https://github.com/triggerdotdev/trigger.dev/blob/a91725096971fedc944346f74cfe5ed9898e9cb0/docs/ai-chat/frontend.mdx
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4187/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/4187/files#diff-0ca382a5d50361ead811d9e36ac14fe4767f49ee2e751b45b77cb45712902e87
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4187/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4187/files
docs/ai-chat/reference.mdxhttps://github.com/triggerdotdev/trigger.dev/pull/4187/files#diff-58e648685c48d39e8d19f714ccdb9a6eca84024f3490b656f62a0ff535a22f3d
View file https://github.com/triggerdotdev/trigger.dev/blob/a91725096971fedc944346f74cfe5ed9898e9cb0/docs/ai-chat/reference.mdx
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4187/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/4187/files#diff-58e648685c48d39e8d19f714ccdb9a6eca84024f3490b656f62a0ff535a22f3d
https://github.com/triggerdotdev/trigger.dev/pull/4187/files#diff-58e648685c48d39e8d19f714ccdb9a6eca84024f3490b656f62a0ff535a22f3d
packages/trigger-sdk/src/v3/chat-react.tshttps://github.com/triggerdotdev/trigger.dev/pull/4187/files#diff-bd66505962858e47bbc1ab2ae3b1422b22cd1365d0ff53a87e201b3c8d661372
View file https://github.com/triggerdotdev/trigger.dev/blob/a91725096971fedc944346f74cfe5ed9898e9cb0/packages/trigger-sdk/src/v3/chat-react.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4187/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/4187/files#diff-bd66505962858e47bbc1ab2ae3b1422b22cd1365d0ff53a87e201b3c8d661372
https://github.com/triggerdotdev/trigger.dev/pull/4187/files#diff-bd66505962858e47bbc1ab2ae3b1422b22cd1365d0ff53a87e201b3c8d661372
https://github.com/triggerdotdev/trigger.dev/pull/4187/files#diff-bd66505962858e47bbc1ab2ae3b1422b22cd1365d0ff53a87e201b3c8d661372
https://github.com/triggerdotdev/trigger.dev/pull/4187/files#diff-bd66505962858e47bbc1ab2ae3b1422b22cd1365d0ff53a87e201b3c8d661372
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4187/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4187/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.