Skip to content

feat(agents): Let a parent spawn a Thread - #2931

Merged
dcramer merged 9 commits into
mainfrom
feat/spawn-thread
Nov 8, 2026
Merged

dcramer merged 9 commits into
mainfrom
feat/spawn-thread

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

PR 6 of #2792.

Until now, spawnAgent could only start Tasks. That meant Threads (child Conversations that people can message) could exist only in tests. With this PR, a parent picks the kind when it spawns a child, and it can clean up Threads it no longer needs.

  • spawnAgent takes kind: "thread" | "task". The default is task, so existing calls keep working. The kind is stored on the child Conversation and does not change after that. A replayed spawn with a different kind is refused. The tool description says when to pick each one: a Thread for long-lived work that people will want to follow, steer, or talk to; a Task for background work that only the parent messages. The result now also returns the child's dashboard_url.
  • The cap of 8 children per parent applies to Threads the same way as to Tasks: a child counts only while it has open work. An idle Thread does not count, so Threads that people use never lock the parent out. The rule stays in the single shared assertChildAgentCapacity helper.
  • New deferred archiveAgent tool, for tidying up. It archives only the caller's own direct Threads. It refuses a Task, a Conversation that is not a direct child, and a Thread that is in use: an open agent invocation, or a pending, running, or paused Turn (for example, a person's queued message). It also refuses a Thread that a person messaged after its last result. That person can archive it from the dashboard, and new work from the parent gives the Thread back. In the eval, the model archived such a Thread from the description alone, and it also set an opt-out flag on its own, so the rule has no opt-out. It goes through the same archive path as the dashboard (feat(conversations)!: Archive conversations for everyone #2900), so it has the same apply_to_children cascade and the same refusal when the Thread has new activity.
  • searchAgents now shows kind, archived, and dashboard_url for children and siblings.
  • No new gates on root, Thread, or Task. A person's Turn in a Thread still has no subagent tools (from feat(conversations): Accept a person's input in a Thread #2840), and that now covers archiveAgent too.

Evals: evals/agent/threads.eval.ts covers picking a Thread, and archiving a finished Thread but not one that a person still uses. The delegation eval now also checks that background research stays a Task. To support this, the eval fixture gets conversation.child(id), which posts to a child Thread as the person.

No dashboard changes.

via @dcramer.

--

View Session in Sentry

spawnAgent takes kind thread or task (default task). Threads count toward
the cap of 8 active children until they are archived. archiveAgent
archives an idle Thread that the caller started, through the shared
archive path.

Refs #2792

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

vercel Bot commented Nov 8, 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 10:08pm UTC

Request Review

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

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

Review screenshots in Frameshift

Automation Run Details · Desktop
Automation Run Details · Desktop
Changed
Automation Run Details Light · Desktop
Automation Run Details Light · Desktop
Changed
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
Show 8 more changed screenshots
Conversation Captured Memories Popover · Desktop
Conversation Captured Memories Popover · Desktop
Changed
Conversation Details Watched Linked Work · Desktop
Conversation Details Watched Linked Work · Desktop
Changed
Conversation Details Watched Linked Work · Mobile
Conversation Details Watched Linked Work · Mobile
Changed
Conversation Event Log Virtual · Mobile
Conversation Event Log Virtual · Mobile
Changed
Conversation Long Transcript Touch · Mobile
Conversation Long Transcript Touch · Mobile
Changed
Conversation Share Details · Desktop
Conversation Share Details · Desktop
Changed
Memories · Mobile
Memories · Mobile
Changed
Settings Mcp · Desktop
Settings Mcp · Desktop
Changed

sentry-junior Bot and others added 2 commits November 8, 2026 19:50
Co-Authored-By: David Cramer <[email protected]>

# Conflicts:
#	packages/junior/src/chat/tools/runtime/spawn-agent.ts
…ast result

archiveAgent now refuses a Thread when a person messaged it after its
latest result, unless the caller passes person_asked. The eval showed the
model archives such a Thread from the description alone. searchAgents no
longer lists last_person_message_at, because the archive owns that rule.

Co-Authored-By: David Cramer <[email protected]>
The model set person_asked whenever the parent's person asked for cleanup,
so the flag did not hold. archiveAgent now always refuses a Thread that a
person messaged after its last result. The person can archive it from the
dashboard, and new work from the parent gives the Thread back.

Co-Authored-By: David Cramer <[email protected]>
The model can archive through codemode, which hides archiveAgent calls from
the tool-call list. The Thread eval now reads each Thread's archived state
through the reporting API.

Co-Authored-By: David Cramer <[email protected]>
An idle Thread counted until it was archived, and archiveAgent cannot
archive a Thread that a person took over. A parent could lose every slot
to Threads that people use. Every child now counts only while it has open
work, so the cap goes back to the Task rule.

Co-Authored-By: David Cramer <[email protected]>
@sentry-junior
sentry-junior Bot marked this pull request as ready for review November 8, 2026 21:56
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 8, 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.

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 6d4f8b5. Configure here.

The guard compared a person's last message with the latest invocation's
updatedAt. Later writes, such as a mailbox append, move that time after the
result, so the parent could archive a Thread that a person had taken over.
Compare with the invocation's creation time, which never moves: a person who
messaged the Thread since the parent last gave it work keeps it.
@dcramer
dcramer merged commit cb93980 into main Nov 8, 2026
49 of 50 checks passed
@dcramer
dcramer deleted the feat/spawn-thread branch November 8, 2026 22:21

This branch was successfully deployed

1 active deployment
Preview – junior-docs — ca01246c 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