Skip to content

feat(agents): Run child Turns without an invocation on the Conversation loop - #3206

Merged
dcramer merged 16 commits into
mainfrom
feat/children-on-conversation-turn
Nov 12, 2026
Merged

dcramer merged 16 commits into
mainfrom
feat/children-on-conversation-turn

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

Step 5 of #3060.

What changes

A child Conversation (Thread or Task) with no open Agent invocation now runs its Turns on the Conversation loop, the same loop that roots use. This covers Watch Events and replies from the child's own child agents.

These still create Agent invocation rows and finish on the legacy worker until step 6:

  • spawn and messageAgent
  • grandchild results
  • any child that has an open row

How a child Turn on the Conversation loop behaves

turnBehavior decides this from the Conversation kind, as it does for roots.

  • Reply: reply goes to the parent. The mailbox id includes the Turn id, so the parent can see that this Turn already answered. The child then does not show in waiting_on.
  • No answer: a Task gets one re-ask. If it still does not answer, the parent gets "No reply was sent." A Thread stays quiet, with telemetry.
  • Failure: a thrown error or a worker that gives up sends failed to a Task's parent. A Thread keeps the failure stored.
  • Stop: the loop checks for a stop at each step. This also covers a person's Turn in a Thread.
  • Status: searchAgents shows the child as running while such a Turn runs, or while its Watch Event waits in the mailbox. A person's Turn in a Thread does not count.
  • Auth: these Turns keep interactive auth off, as on the legacy worker.

Rollback to main

Grandchild results stay on Agent invocations. A child Turn on the Conversation loop writes only agent-reply: mailbox messages and Turn records, and main reads them the same way. A paused child Turn stays paused until new input comes.

via @dcramer.

--

View Session [Sentry]

…on loop

Input to a child Conversation with no open Agent invocation now runs on the
shared Conversation Turn worker. turnBehavior picks the reply target, the
gate, and the failure notice. The shared loop checks the stored stop at each
step and passes the child's parent to the run. Rows that are open at deploy,
and parent tasks and messages, still finish on the legacy worker.

Step 5 of #3060.

Co-Authored-By: David Cramer <[email protected]>
@vercel

vercel Bot commented Nov 11, 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 12, 2026 12:16am UTC

Request Review

…bundle

A child agent's Turn on the Conversation loop can run as the web user who
started it, but it cannot wait for that person to sign in. Missing auth
blocks it, as on the agent invocation path.

Move the child-input check out of result-event-type so the API schema entry
no longer pulls server code into the dashboard build.
Keep grandchild results on Agent invocations so a rollback to main
leaves no unread result that main counts as open work. Show a child
whose work runs on the Conversation loop as running, send a Task's
parent a failed result when its worker fails repeatedly, drop replies
sent after a stop, and carry the spawn's grants to grandchild input.
Count isTopLevelKind as a kind branch and restore reply card selection.

Co-Authored-By: David Cramer <[email protected]>
…ersation-turn

# Conflicts:
#	packages/junior/src/chat/agent-invocations/work.ts
Key the reply of a Turn on a child's Conversation loop by its Turn id.
Under the parent mailbox lock, a child whose open Turn already has a
reply in the parent's inbox is not listed in waiting_on.

Co-Authored-By: David Cramer <[email protected]>
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

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

Review screenshots in Frameshift

Automation Run Details · Desktop
Automation Run Details · Desktop
Changed
Automation Skill Editor · Desktop
Automation Skill Editor · Desktop
Changed
Automation Skill Editor · Mobile
Automation Skill Editor · Mobile
Changed
Automations Runs Filters · Desktop
Automations Runs Filters · Desktop
Changed
Code · Desktop
Code · Desktop
Changed
Conversation Details Watched Linked Work · Desktop
Conversation Details Watched Linked Work · Desktop
Changed
Show 5 more changed screenshots
Conversation Event Log Virtual · Mobile
Conversation Event Log Virtual · Mobile
Changed
Conversation Long Transcript Touch · Mobile
Conversation Long Transcript Touch · Mobile
Changed
Conversation Question Stepper · Desktop
Conversation Question Stepper · Desktop
Changed
Conversation Stop Active · Mobile
Conversation Stop Active · Mobile
Changed
Push Notifications Tip · Desktop
Push Notifications Tip · Desktop
Changed

… loop

- Count only gated, non-person child Turns, and queued Watch Events, as
  work that answers the parent.
- Drop a reply from stopped work also after the child gets a new task.
- Keep the spawn's grants only for a grandchild result, not a reply.
- Select a Conversation loop reply's cards from its own Turn.

Co-Authored-By: David Cramer <[email protected]>
@dcramer

dcramer commented Nov 11, 2026

Copy link
Copy Markdown
Member

the PR description isnt very easy to reason about, fix it

A grandchild result, or input to a stopped or replaced child, starts an
agent invocation, so it does not keep the child running. A Turn that
replies before its first checkpoint is keyed by its first input.

Co-Authored-By: David Cramer <[email protected]>
sentry-junior Bot and others added 2 commits November 11, 2026 22:21
…ies at stop

routeChildInput now decides agent invocation, Conversation loop, or
dropped for routing, the stop skips, and the child agent status. A stop
drops unread replies from stopped Conversation loop Turns by message id,
so a new task cannot bring them back. A Turn that replies before its
first checkpoint matches any pending input's Turn id.

Co-Authored-By: David Cramer <[email protected]>
@dcramer
dcramer marked this pull request as ready for review November 11, 2026 22:29
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 11, 2026

@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.

A Turn sends its reply before it saves. When its worker is then lost,
the parent already has the answer, so the Task sends no failure.

@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.

… parent lock

A reply stamped before a stop can reach the parent's mailbox after the
stop dropped the unread ones. The append now checks the sender's stored
stop under the parent mailbox lock and drops such a reply.

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.

Stale Bugbot comment from a previous run.

…rns on a lost worker

A loop reply dropped under the parent lock now records its id, so a retry
of the stopped Turn is a duplicate. The lost-worker notice matches only the
open Turn or pending input, not the input of earlier Turns.
@dcramer

dcramer commented Nov 11, 2026

Copy link
Copy Markdown
Member

did we address the previous cursor feedback?

@sentry-junior

sentry-junior Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

3 of the 4 Cursor findings are fixed and their threads are resolved:

  • "Lost worker fails after a reply": fixed in 599ffd5.
  • "Prior replies suppress later crash notices" and "Dropped replies can reappear after resume": both fixed in ae8a8d5. Each has a test in the stop and worker-crash scenarios that fails without the fix.

Still open on purpose: "Mixed grandchild batch skips Conversation loop" (4543990851). If a batch mixes a grandchild result with a reply, the whole batch runs as an Agent invocation, which is what main does today. That's not a regression, so I left it for step 6/7, which removes that legacy path.

@dcramer

dcramer commented Nov 11, 2026

Copy link
Copy Markdown
Member

needs rebased

…ersation-turn

# Conflicts:
#	scripts/test-architecture-baseline.json
@sentry-junior

sentry-junior Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Merged main in 4cc0fae3a instead of rebasing, so your approval stays.

@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.

A person's stop of a child agent now also drops its unread Conversation
loop replies from its parent's mailbox, as the parent's stop does.

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 9e6e812. Configure here.

…p is stored

The drop of a child's own unread loop replies now runs after
stopConversation stores the stop, so the parent mailbox lock drops a
later reply and a failed stop leaves the replies in place.
@dcramer
dcramer merged commit 0e456af into main Nov 12, 2026
64 of 66 checks passed
@dcramer
dcramer deleted the feat/children-on-conversation-turn branch November 12, 2026 00:31
sentry-junior Bot added a commit that referenced this pull request Nov 17, 2026
Agents that trip a ratchet check add a baseline entry and the check passes.
Review caught this in #3035 and #3564, and it
merged in #3460, #3226, and #3206.

baseline-growth:check compares each debt baseline to the merge base with
origin/main and fails when a rule's total rises. Totals per rule let a file
move or split without failing.

Co-Authored-By: David Cramer <[email protected]>
BYK pushed a commit that referenced this pull request Nov 21, 2026
…its check (#3612)

## Baselines can only shrink

The ratchet baselines (`type-assertions`, `await-in-loop`,
`test-architecture`, `typecheck-coverage`, `migration-locks`,
`tool-descriptions`, `file-length-exceptions`) already say "do not add
entries". But when a check trips, an agent can still add an entry and
the check passes. Review caught this on #3564 and
#3035, both from @BYK. It merged without review in
#3460, #3226, and #3206.

`pnpm baseline-growth:check` is now part of `pnpm lint`. It compares
each baseline to the merge base with `origin/main` and fails when a
rule's total goes up. The error names the baseline, the rule, and the
entries that caused it. Totals are counted per rule, so a file that
moves or splits still passes. A rule or baseline that is new in the
change is skipped, because that is how a new check gets adopted. The CI
lint job now uses `fetch-depth: 0` so it has a merge base.

`tool-error-classification-baseline.txt` is left out because it is an
allowlist of approved system errors and grows on purpose.

## Use data the system already has before you add plumbing

Agents fix missing information with new hooks, resolvers, and lookups
instead of using data the system already stores, as in
#3610, #3404, and #3457.
No check can tell a needed abstraction from a speculative one, so
`policies/correctness-complexity.md` now names this case.

## Generate deterministic output in code, not prompt text

Agents fix deterministic behavior with prompt or policy text.
#3610 first tried to fix PR links with a GitHub system
prompt change, and @dcramer rejected it: "We know if it's a pull request
or an issue. We should just be generating the right link." The bot name
in prompts (#3404) had to become a check, and
#3438 was told not to add policy text when a rule can
enforce it. `policies/agent-steering.md` now says to generate links,
IDs, and formats in code.

## Rule table

The AGENTS.md rules are now a table that says what enforces each rule. A
correction for a rule marked "Review" shows that the rule is a repeat
and needs a higher-level fix.

## Open decision

- There is no override for baseline growth. If a reviewer approves a
growth, they have to change the check. Should there be an approved
override, such as a PR label?

<!-- junior-request-attribution:start -->
via @dcramer.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A9da30a1e94fc26f2b83022cfd8dd95fc -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A9da30a1e94fc26f2b83022cfd8dd95fc)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A9da30a1e94fc26f2b83022cfd8dd95fc/?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 — f528f718 Deployed Nov 12, 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