Repository navigation
perf(chat): run independent task-execution and agent reads at once - #3633
Merged
Merged
Conversation
Burn down the no-await-in-loop baseline for the task-execution group in packages/junior/src/chat. Independent reads and per-Conversation work run through pLimit(FAN_OUT_CONCURRENCY), and child sender reads share one legacy query. Loops that must stay in order get a disable comment that says why. Co-Authored-By: BYK <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-Authored-By: BYK <[email protected]> # Conflicts: # scripts/await-in-loop-baseline.json # tools/oxlint/await-in-loop.json
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 592caa6. Configure here.
… cap Callers already run each child under pLimit(FAN_OUT_CONCURRENCY). A second limiter inside runsOnConversationLoop multiplied in-flight reads against the pool. Route one input at a time and stop at the first loop route. Co-Authored-By: BYK <[email protected]>
Contributor
|
4 screenshot changes — 4 changed · 0 added · 0 removed Review screenshots in Frameshift
|
BYK
approved these changes
Nov 18, 2026
BYK
added a commit
that referenced
this pull request
Nov 18, 2026
Sequential awaits on independent reads slow down skill discovery, App Home, link unfurls and thread image hydration. This is the last chat group of the `no-await-in-loop` burn-down: Slack, ingress, Conversations, events, services, review items, plan, skills and the rest of `packages/junior/src/chat`. It does not include the task-execution group in #3633 or `chat/automations/` (2 sites). The baseline drops from 187 sites in 53 files to 108 sites in 20 files. With #3633 too, only the 2 automation sites stay in the chat baseline. **Runs at once now (15 sites):** - Skill discovery reads every root and skill directory at once. Then it merges them in root and name order, so the first root still wins a name. `loadSkillsByName` reads the selected `SKILL.md` files at once. - App Home reads each provider connection at once. - Dashboard link unfurls read each linked Conversation at once. The channel access check is still shared and runs once. - Thread image hydration downloads and summarizes images at once. A file that two replies share is summarized once. - Watch match-key lookup reads each identifier index at once. - Child result cards read each child's terminal event at once, then select cards newest first. - Task outcomes open the creator DM once, not once for each outcome. - An Identity write clears both cached Users at once. **Stays in order (64 sites)**, each with a disable comment that says why: cursor pagination (Slack, event pages), retries and lock polls, statements in one transaction or on the caller's executor, reply chunks (the first one can set the thread root), event-lock order in purge, the attachment loop (the image cap and cached summary index follow attachment order), and the guardian worker pool, which is the limiter itself. Timer claims, Watch cancels, timer ingest and Watch delivery stay sequential on purpose. They update the timer index or dispatch index, and those locks fail at once when another holder has them. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A7e1432c2f4a2110ee7bb48718f8b6fad --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A7e1432c2f4a2110ee7bb48718f8b6fad) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A7e1432c2f4a2110ee7bb48718f8b6fad/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
BYK
added a commit
that referenced
this pull request
Nov 18, 2026
…3652) The heartbeat recovers pending agent-invocation appends and results one at a time, so every mailbox waits for every other one. The order matters only inside one mailbox: a child must read its tasks in the order they were created, and a parent must get results in the order they ended. Both recovery loops in `agent-dispatch/heartbeat.ts` now group the list by the mailbox they write to: `childConversationId` for invocation appends and `parentConversationId` for results. Each group runs in list order, and `mapBounded` runs the groups at once under the default cap. A failed item is still logged, and the next item in its mailbox still runs. The dispatch and plugin loops stay sequential, because they take the shared pending-append index lock, which does not wait. Follows up on the ordering discussion in #3633. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A7e1432c2f4a2110ee7bb48718f8b6fad --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A7e1432c2f4a2110ee7bb48718f8b6fad) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A7e1432c2f4a2110ee7bb48718f8b6fad/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
24 tasks done
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Sequential awaits on independent work slow down stops, Turn setup and heartbeats. This is the next step of the
no-await-in-loopburn-down after #3631. It covers the task-execution group inpackages/junior/src/chat: task-execution, agent invocations, agent dispatch, agent, and Scheduled and Event automations. The baseline drops from 187 sites in 53 files to 81 sites in 35 files. It does not touchchat/automations/(2 sites).Runs at once now (11 sites):
readChildMessageSendersreads the sender of each mailbox message with one legacy query, not one query for each message. A stop,hasOpenChildWorkand the loop-reply drop use it.Stays in order (95 sites), each with a disable comment that says why: the worker slice loop and the agent step loop, lock polls, paused-Turn resume (it stops at the first Turn that resumes), MCP restore (it stops at the first provider that needs sign-in), mailbox appends and queued invocations (message order), statements in one transaction, and the tree lock walk.
runsOnConversationLooproutes one input at a time, because its callers already run each child under the fan-out cap.Event automation dispatch, plugin heartbeats and dispatch-append recovery stay sequential on purpose. Each dispatch takes the pending-append index lock in
agent-dispatch/store.ts, andacquireLockfails at once when another holder has it. A parallel version would fail dispatches.via @BYK.
--
View Session [Sentry]