René's URL Explorer Experiment


Title: fix(sdk): custom agent loop parity for continuations, steering, and subtasks by ericallam · Pull Request #3936 · triggerdotdev/trigger.dev · GitHub

Open Graph Title: fix(sdk): custom agent loop parity for continuations, steering, and subtasks by ericallam · Pull Request #3936 · triggerdotdev/trigger.dev

X Title: fix(sdk): custom agent loop parity for continuations, steering, and subtasks by ericallam · Pull Request #3936 · triggerdotdev/trigger.dev

Description: Summary Three fixes that bring custom agent loops (chat.customAgent hand-rolled loops and chat.createSession) up to the behavior chat.agent users already get, and that the docs already promise: Continuation runs no longer replay already-answered messages. A chat continuing after a cancel, crash, or upgrade re-delivered every prior user message into the loop's first wait, so the model re-answered an old message while the real new one had to arrive via steering. The .in resume cursor is now seeded before any listener attaches, using the same boot logic as chat.agent. Mid-stream steering no longer wipes the in-flight response. chat.pipeAndCapture (also backing turn.complete()) streamed without a server-generated message id, so a prepareStep injection regenerated the assistant id mid-stream and the frontend replaced the partial message, discarding everything streamed before the injection. Task-backed tools now work from custom agent loops. A child task triggered via ai.toolExecute failed with "chat.agent session handle is not initialized" because the parent's chatId only threaded from the per-turn context that hand-rolled loops never set. It now falls back to the session handle the chat.customAgent wrapper binds at run boot, so children can stream progress into the chat with chat.stream.writer({ target: "root" }) (the documented sub-agent pattern). Root cause on the replay fix Attaching any .in listener (chat.createStopSignal, chat.messages.on, the first wait) opens the SSE tail with Last-Event-ID taken from the seq cursor at attach time. Custom loops attached before any cursor existed, so S2 replayed from seq 0. The fix resolves the cursor from the latest turn-complete header and seeds both manager cursors (setLastSeqNum drives the SSE resume point, setLastDispatchedSeqNum gates waiter dispatch) before attach; chat.createSession now creates its stop signal lazily on the first iteration, after the seed. Seeding only the first cursor after attach does not work, which is why the earlier attempt at this was reverted. All three were reproduced red-green against the references ai-chat project: the replay repro showed the continuation wait consuming a stale message in 403ms with the real message arriving via steering injection; post-fix the wait consumes the real message directly with no injection. Steering now preserves the full in-flight response, and the deepResearch sub-agent streams its progress parts into a raw-loop parent. Existing behavior verified unchanged: full SDK unit suite, chat.agent steering, and stop-then-continue on chat.createSession.

Open Graph Description: Summary Three fixes that bring custom agent loops (chat.customAgent hand-rolled loops and chat.createSession) up to the behavior chat.agent users already get, and that the docs already promise: Co...

X Description: Summary Three fixes that bring custom agent loops (chat.customAgent hand-rolled loops and chat.createSession) up to the behavior chat.agent users already get, and that the docs already promise: Co...

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

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:18b62c36-c249-8b47-dbfb-27e7897be3ee
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE66C:23CE74:17DFA43:20A1894:6AFB8257
html-safe-noncef84c8dcd33f8962a804f5fd2a396158cc56b09ea1ad68615130d94b389e80156
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNjZDOjIzQ0U3NDoxN0RGQTQzOjIwQTE4OTQ6NkFGQjgyNTciLCJ2aXNpdG9yX2lkIjoiMzk0MTI2MzI1NDc3MTk1ODM2MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacc407723878750a22f6aac40a1f182b9899f223988e68cb3d4f3c425cd23667d9
hovercard-subject-tagpull_request:3856516626
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/3936/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 Three fixes that bring custom agent loops (chat.customAgent hand-rolled loops and chat.createSession) up to the behavior chat.agent users already get, and that the docs already promise: Co...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneef32892d4269fb87b55e81cc4ba8d86e0f16aa28446ffbf46cba8be5179ab188
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
releasebc3703b4dcbe820d1284ef63c88b001c850be25e
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/triggerdotdev/trigger.dev/pull/3936/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fpull%2F3936%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%2F3936%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/3936/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/3936/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/3936/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 requests67 (67)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
fix/custom-agent-loop-fixeshttps://github.com/triggerdotdev/trigger.dev/tree/fix/custom-agent-loop-fixes
Conversation 15 https://github.com/triggerdotdev/trigger.dev/pull/3936
Commits 4 https://github.com/triggerdotdev/trigger.dev/pull/3936/commits
Checks 57 https://github.com/triggerdotdev/trigger.dev/pull/3936/checks
Files changed https://github.com/triggerdotdev/trigger.dev/pull/3936/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3936/files
fix(sdk): custom agent loop parity for continuations, steering, and subtasks https://github.com/triggerdotdev/trigger.dev/pull/3936/files#top
Show all changes 4 commits https://github.com/triggerdotdev/trigger.dev/pull/3936/files
1a935dd fix(sdk): custom agent loop parity with chat.agent for continuations,… ericallam Jun 12, 2026 https://github.com/triggerdotdev/trigger.dev/pull/3936/commits/1a935dd83d998db87a4d26d28508b2b7a7e61198
174ba12 fix(sdk): seed the custom-loop resume cursor without a continuation gate ericallam Jun 12, 2026 https://github.com/triggerdotdev/trigger.dev/pull/3936/commits/174ba12870881ca33069815edd07eb2e7f98c058
09f8e7a fix(sdk): thread the boot payload chatId into subtask metadata explic… ericallam Jun 13, 2026 https://github.com/triggerdotdev/trigger.dev/pull/3936/commits/09f8e7ae94a7c99e7b806be1ec9875c1d55baffd
04c89b9 docs(sdk): correct the createSession example to use chat.customAgent ericallam Jun 13, 2026 https://github.com/triggerdotdev/trigger.dev/pull/3936/commits/04c89b9387f0c67fcbd727f12e94b3abac5cf7f0
Clear filters https://github.com/triggerdotdev/trigger.dev/pull/3936/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3936/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3936/files
custom-agent-loop-fixes.md https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-72e327baa8d096dc71aee3d0e7f933788a299f9025e6d6124465f8a08ce3b1ef
ai.ts https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
.changeset/custom-agent-loop-fixes.mdhttps://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-72e327baa8d096dc71aee3d0e7f933788a299f9025e6d6124465f8a08ce3b1ef
View file https://github.com/triggerdotdev/trigger.dev/blob/04c89b9387f0c67fcbd727f12e94b3abac5cf7f0/.changeset/custom-agent-loop-fixes.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/3936/{{ revealButtonHref }}
packages/trigger-sdk/src/v3/ai.tshttps://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
View file https://github.com/triggerdotdev/trigger.dev/blob/04c89b9387f0c67fcbd727f12e94b3abac5cf7f0/packages/trigger-sdk/src/v3/ai.ts
Open in desktop https://desktop.github.com
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3936/files
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/3936/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3936/files
https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
https://github.com/triggerdotdev/trigger.dev/pull/3936/files#diff-1a41664a01679e09d7182b5d113a193cea9eaad0f2092f68b4beca081617a53a
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3936/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.