Skip to content

feat(conversations): Accept a person's input in a Thread - #2840

Merged
dcramer merged 1 commit into
mainfrom
feat/thread-input-path
Nov 8, 2026
Merged

dcramer merged 1 commit into
mainfrom
feat/thread-input-path

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

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. acceptsWebMessages is the one check. A child accepts web input only when kind === "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:

  • Destination: from the Thread's own row. Reads no longer hide the Destination a child copied at creation (ref(conversations): Save a child's Location when it is created #2865). Delivery stays root-only.
  • Run consistency: assertRunConsistency gets kind from the row executeAgentRun already reads. For a Thread, it skips the source/destination id match.
  • Visibility: the Thread's. Private when missing.
  • subagents is disabled. Memory tasks are skipped.
  • New input supersedes open mailbox Turns. The code is shared with roots in supersede-turns.ts.

Child work keeps no Destination. wakePausedTurn and recordWebConversationActivity pass 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]

@vercel

vercel Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 8, 2026 1:32am UTC

Request Review

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@blacksmith-sh

This comment has been minimized.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

11 screenshot changes — 11 changed · 0 added · 0 removed

Review screenshots in Frameshift

Conversation Attachment · Desktop
Conversation Attachment · Desktop
Changed
Conversation Attachment · Mobile
Conversation Attachment · Mobile
Changed
Conversation Attachment Modal · Desktop
Conversation Attachment Modal · Desktop
Changed
Conversation Attachment Zoom · Desktop
Conversation Attachment Zoom · Desktop
Changed
Conversation Captured Memories Popover · Desktop
Conversation Captured Memories Popover · Desktop
Changed
Conversation Details Watched Linked Work · Desktop
Conversation Details Watched Linked Work · Desktop
Changed
Show 5 more changed screenshots
Conversation Details Watched Linked Work · Mobile
Conversation Details Watched Linked Work · Mobile
Changed
Conversation Long Transcript Touch · Mobile
Conversation Long Transcript Touch · Mobile
Changed
Conversation Share Details · Desktop
Conversation Share Details · Desktop
Changed
Conversations Sections Collapsed · Desktop
Conversations Sections Collapsed · Desktop
Changed
Settings Mcp · Desktop
Settings Mcp · Desktop
Changed

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

sentry-junior Bot added a commit that referenced this pull request Nov 6, 2026
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.
sentry-junior Bot added a commit that referenced this pull request Nov 6, 2026
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 dcramer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

sentry-junior Bot added a commit that referenced this pull request Nov 7, 2026
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.
sentry-junior Bot added a commit that referenced this pull request Nov 7, 2026
… 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]>
@sentry-junior
sentry-junior Bot force-pushed the feat/thread-input-path branch from ee54ba6 to aa545ac Compare November 7, 2026 01:16
@sentry-junior
sentry-junior Bot changed the base branch from feat/targeted-wakes to main November 7, 2026 01:16
sentry-junior Bot added a commit that referenced this pull request Nov 7, 2026
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]>
sentry-junior Bot added a commit that referenced this pull request Nov 7, 2026
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]>
sentry-junior Bot added a commit that referenced this pull request Nov 7, 2026
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]>
@sentry-junior
sentry-junior Bot force-pushed the feat/thread-input-path branch from ef13148 to eb202a5 Compare November 7, 2026 02:30
sentry-junior Bot added a commit that referenced this pull request Nov 7, 2026
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]>

@dcramer dcramer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3aff81a. Configure here.

@dcramer
dcramer merged commit ee8c735 into main Nov 8, 2026
44 checks passed
@dcramer
dcramer deleted the feat/thread-input-path branch November 8, 2026 02:14
dcramer added a commit that referenced this pull request Nov 8, 2026
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]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 3aff81a3 Deployed Nov 8, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant