Repository navigation
feat(conversations): Accept a person's input in a Thread - #2840
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
af9eaed to
ca4822f
Compare
ca4822f to
a246047
Compare
This comment has been minimized.
This comment has been minimized.
|
11 screenshot changes — 11 changed · 0 added · 0 removed Review screenshots in Frameshift |
647e991 to
08526e2
Compare
The restack kept this branch's Thread test helpers. Add the running person Turn helper there, so the recovery case from feat/thread-input-path runs.
The restack kept this branch's Thread test helpers. Add the running person Turn helper there, so the recovery case from feat/thread-input-path runs.
dcramer
left a comment
There was a problem hiding this comment.
whats the cause of this change being so large? is there not anything that should have been refact ored to tighten this up and make it simpler? it just feels like a lot of code for something that shouldn't need a ton of changes
The restack kept this branch's Thread test helpers. Add the running person Turn helper there, so the recovery case from feat/thread-input-path runs.
… fixture The restack onto targeted wakes replaced the wake-order cases. Use the shared fixture for them, and drop queueWatchEvent, which no case uses now. Co-Authored-By: David Cramer <[email protected]>
ee54ba6 to
aa545ac
Compare
Restacked onto the one-open-Turn Thread model in #2840. - stopAgent binds the queue that runs child work. The tree stop wakes each stopped Conversation with stopConversationTurn. - The tree stop cancels a Thread's sign-in-paused person Turn with the stopped-resume cleanup (cancelSignInPausedTurn), because the stop wake can go to queued input first. abandonTurnRecord with onlyIfAuthPaused keeps a Turn that a worker already resumed. - A person's Message after a stop restarts a Thread, so later results and watch Events run again. - The Thread scenarios share tests/fixtures/thread-input.ts, and the stop cases have their own file. Co-Authored-By: David Cramer <[email protected]>
Restacked onto the one-open-Turn Thread model in #2840. - stopAgent binds the queue that runs child work. The tree stop wakes each stopped Conversation with stopConversationTurn. - The tree stop cancels a Thread's sign-in-paused person Turn with the stopped-resume cleanup (cancelSignInPausedTurn), because the stop wake can go to queued input first. abandonTurnRecord with onlyIfAuthPaused keeps a Turn that a worker already resumed. - A person's Message after a stop restarts a Thread, so later results and watch Events run again. - The Thread scenarios share tests/fixtures/thread-input.ts, and the stop cases have their own file. Co-Authored-By: David Cramer <[email protected]>
Restacked onto the one-open-Turn Thread model in #2840. - stopAgent binds the queue that runs child work. The tree stop wakes each stopped Conversation with stopConversationTurn. - The tree stop cancels a Thread's sign-in-paused person Turn with the stopped-resume cleanup (cancelSignInPausedTurn), because the stop wake can go to queued input first. abandonTurnRecord with onlyIfAuthPaused keeps a Turn that a worker already resumed. - A person's Message after a stop restarts a Thread, so later results and watch Events run again. - The Thread scenarios share tests/fixtures/thread-input.ts, and the stop cases have their own file. Co-Authored-By: David Cramer <[email protected]>
ef13148 to
eb202a5
Compare
Restacked onto the one-open-Turn Thread model in #2840. - stopAgent binds the queue that runs child work. The tree stop wakes each stopped Conversation with stopConversationTurn. - The tree stop cancels a Thread's sign-in-paused person Turn with the stopped-resume cleanup (cancelSignInPausedTurn), because the stop wake can go to queued input first. abandonTurnRecord with onlyIfAuthPaused keeps a Turn that a worker already resumed. - A person's Message after a stop restarts a Thread, so later results and watch Events run again. - The Thread scenarios share tests/fixtures/thread-input.ts, and the stop cases have their own file. Co-Authored-By: David Cramer <[email protected]>
4867178 to
156a5cb
Compare
dcramer
left a comment
There was a problem hiding this comment.
i dont really understand why we have as much web specific code here?
like some of these errors i imagine could be generalized? some of the helpers? slack and web arent all that different. theres obviously per-location identity stuff and what not but lets make sure we need everyhting we added
A person can send web Messages to a Thread. The Thread runs them as a person's Turn, like a web Turn on a root, and replies stay in Junior: only a root delivers to its Location. - Route a Thread's web input and its empty wakes to the Conversation Turn worker. Agent invocation input and watch Events keep the child worker. - Keep one open Turn per Thread. A person's Message ends an open Agent invocation, and an Agent invocation ends a person's open Turn. Each ended invocation reports to the parent. - Read the Thread's own row for kind, Destination, Location, and visibility. A child now exposes its stored Destination, like every Conversation. Its work still keeps none. - Run a person's Turn in a Thread as private when visibility is missing, with subagents and memory off. Refs #2792 Co-Authored-By: David Cramer <[email protected]>
156a5cb to
3aff81a
Compare
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 3aff81a. Configure here.
| return { kind: "mailbox", batch }; | ||
| } | ||
| if (context.attempt.messages.length > 0) { | ||
| return undefined; |
There was a problem hiding this comment.
Mixed Thread inputs crash the worker
High Severity
resolveThreadTurnWork runs parseWebMessages over the whole attempt. That helper throws when only some messages look like web input. On an idle Thread, a person's Message and parent messageAgent input can sit in the same mailbox, so the worker crashes and retries the same mixed batch instead of routing each kind.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 3aff81a. Configure here.
Stacked on #2840. Part 3b of #2792 (Thread input path): stop and restart. **Tree stop.** `finishStoppedTree` now calls `stopConversationTurn` for each Conversation instead of `stopConversationWork`. A Thread can hold a person's Turn that waits for sign-in; only the sign-in-pause-aware stop ends it, so a later sign-in callback cannot resume a stopped Thread. The stop paths need the work queue for this, so `queue` is now required on `stopChildAgent`, `stopConversationSession`, `stopChildAgentsOf`, `createStopAgentTool`, and the agent invocation worker. **Restart rule.** In `startAgentInvocationsForChildInput`, a Thread no longer counts as stopped when a person sent a web Message after its `stoppedAt`. This is an extra condition on the Task rule, so Tasks (and a parent restart through `messageAgent`) keep today's behavior. The three existing "is stopped" rules stay separate. Nobody can create a Thread until PR 6, so roots and Tasks do not change. One side effect for Tasks: `stopConversationTurn` can add a wake when the work is `requested`. The full suite passes. Tests (`thread-input.test.ts`, through real wiring, agent not run): - a person's Turn that waits for sign-in ends when the tree stops - watch Events run in a stopped Thread after a person messages it Both fail when their fix is reverted. <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A0c260f265cf935f8188916d24d15112d --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A0c260f265cf935f8188916d24d15112d) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A0c260f265cf935f8188916d24d15112d/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>


PR 3a of #2792 (Thread input path). Stop and the Thread restart rule come in #2845. Nobody can create a Thread until PR 6, so roots and Tasks keep today's behavior.
Every check reads the stored Conversation row (
kind, Destination). None parse ids.Input.
acceptsWebMessagesis the one check. A child accepts web input only whenkind === "thread". The dashboard, ACP and review-desk replies all use it. A Task still gets 409.Router. For a Thread, a web batch goes to the mailbox worker. A resume wake goes to a person's Turn only when it names that Turn. Everything else goes to the invocation worker.
A person's Turn in a Thread:
assertRunConsistencygetskindfrom the rowexecuteAgentRunalready reads. For a Thread, it skips the source/destination id match.subagentsis disabled. Memory tasks are skipped.supersede-turns.ts.Child work keeps no Destination.
wakePausedTurnandrecordWebConversationActivitypass none for a non-root row, so the invocation worker's guard still holds.Deviation: invocation input does not queue behind a person's Turn that is paused for sign-in.
Tests store a Thread by spawning a child and setting
kind = 'thread'in SQL.via @dcramer.
--
View Session [Sentry]