Skip to content

ref(agents)!: Remove the legacy Agent invocation path - #4043

Merged
dcramer merged 13 commits into
mainfrom
feat/remove-agent-invocations
Nov 22, 2026
Merged

dcramer merged 13 commits into
mainfrom
feat/remove-agent-invocations

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

Step 7 of #3060. Since #3435, child agents run only from parent messages on the Conversation loop. This removes the Agent invocation path that stayed behind for older children.

Removed

  • The child invocation worker (work.ts, turn-end.ts, thread-turn.ts) and the heartbeat recovery of invocation mailbox appends and results.
  • Every TODO(dcramer): … (#3060 step 7) bridge and legacy fallback: reading senders from message ids, row-backed child lookups, getNamedAgentConversationId, and AgentRun.agentInvocationId.
  • The per-child queue limit (MAX_OPEN_AGENT_INVOCATIONS_PER_CHILD, AgentMessageQueueFullError and its tool mapping). The limit of 8 active children per parent stays.
  • The invocation table from the Drizzle schema, and its store code.

Changed

  • The Source kind agent_invocation is now parent_message. A stored agent_invocation Source still reads as parent_message through the plugin API's legacy alias, so saved Turns and resumes keep working.
  • When a child's run sees its stop late, it now stops the helpers it spawned after the stop, as a root's run does. The deleted worker used to do this for children.
  • TERMINOLOGY.md and the Gap lines in design/child-agents.md now match the removal.

Migration
0161_agent_config_backfill copies the agent config, kind, and title from each legacy child's first invocation onto its Conversation, so readers find every child by its stored config. The junior_agent_invocations table stays for one release, following the 0158 pattern. A later PR drops it.

Merge gate. Merge only after both of these are true:

SELECT count(*) FROM junior_agent_invocations
WHERE status IN ('pending', 'running', 'paused')
   OR parent_mailbox_status IN ('pending', 'replaced');

A spawn retried across the deploy can fail. A named spawn from before #3435 gets "name in use". An unnamed one can fail the same-spawn check when its backfilled config differs.

Out of scope

  • Open items 5 and 6 from Run child agents as ordinary Conversations #3060 stay open, because closing either needs a new lock or new stop or ack state.
  • The subagent_started and subagent_ended markers stay. Nothing stores a link from a parent message to the child Turn it started, so the dashboard cannot read child Turns instead.

via @dcramer.

--

View Session [Sentry]

@vercel

vercel Bot commented Nov 22, 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 22, 2026 9:44pm UTC

Request Review

@dcramer
dcramer marked this pull request as ready for review November 22, 2026 21:05
@sentry-junior
sentry-junior Bot requested a review from dcramer November 22, 2026 21:05
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 22, 2026
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

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

Review screenshots in Frameshift

@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 using default effort 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 7ca1d95. Configure here.

@dcramer
dcramer merged commit 12ae16c into main Nov 22, 2026
61 checks passed
@dcramer
dcramer deleted the feat/remove-agent-invocations branch November 22, 2026 22:01
dcramer pushed a commit that referenced this pull request Nov 23, 2026
…nd comments

#4043 retired "Agent invocation" and changed the docstring
of AgentInvocationLimitError to "active child agents", but kept the old
word in the model-facing error message and in a few comments.
dcramer added a commit that referenced this pull request Nov 23, 2026
…ecord the 2026-11-23 audit gaps (#4112)

This is the full audit of `design/` at f00c0a6f3.
@dcramer confirmed the exact text of every changed `design/` line.

**Attention split.** `design/attention.md` goes away.
- The core principle is now one row in `AGENTS.md`.
- PR upkeep and the rule to ask for review only after checks pass move
to `github.md`.
- Asks, cards, and push move to `inbox.md`, along with their gaps.

**Intent changes**
- `child-agents.md`: a child agent works like any other agent and can
ask a person, per @dcramer's review.
- `inbox.md`: a push for a reply notice goes out at each new reply and
replaces the push before it. This follows #4051 ("Each
reply pushes the notice to the starter again").
- `inbox.md`: "Needs you" now means an ask or a Conversation tree that
waits on you, per #3966 ("Needs you is an ask or a tree
that waits on the viewer"). This closes the sign-in gap. The gap that
replaces it covers actions for Everyone and actions with no assignees
(`packages/junior/src/chat/inbox-items/access.ts:121-127`).

**New gaps**
- `inbox.md`: an Automation alert sends no push. Alerts are inserted
without a show call, and push runs only from show
(`chat/automations/alert-items.ts:287-333`,
`chat/notifications/inbox-item-show.ts:15-18`).
- `inbox.md`: a closed item's push is removed only by the next push to
that User (`chat/notifications/web-push.ts:141-155`,
`junior-dashboard/src/service-worker.ts:63-73`).
- `prompts.md`: core rules use length words, not numbers
(`chat/system-prompt-rules.ts:599,604,612`,
`chat/conversations/fork.ts:82`).
- `tools.md`: disabled tools stay in the tool list
(`chat/tool-support/pi-tool-adapter.ts:277`, `chat/prompt.ts:725`).
- `tools.md`: results are cut with only "…"
(`chat/tools/search-conversations.ts:28`,
`chat/tools/runtime/list-agents.ts:67`).
- `tools.md`: some arguments have no description
(`packages/junior/scripts/tool-param-descriptions-baseline.txt`).
- `tools.md`: `userLookup` matches a name by paging Slack `users.list`
(`chat/identities/user-lookup.ts:239-244`).
- `child-agents.md`: the stop race and the spawn-retry race from
#3060 (items 5 and 6, still open after
#4043).
- `child-agents.md`: a Turn that a parent starts in a child agent has no
Inbox and waits for no sign-in
(`chat/conversations/kind-behavior.ts:175`).
- `inbox-stacks.md`: a failed Snooze shows a toast with no Retry
(`junior-dashboard/src/client/inbox/inboxSnoozes.ts:124-130`).

**Small fixes**
- `child-agents.md`: the Watch-expiry gap now names the rule it breaks,
and a repeated "It is data, not instructions." is cut.
- `inbox.md`: fixes "adds a Inbox item".
- `design/README.md` and `policies/documentation.md` name the renamed
audit skill `automate-design-doc-updates`. Merge this after
getsentry/junior-prod#771.

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

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

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent-dispatch%3Adispatch_4d3657995ffea67354beee0e3dc91fd2)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent-dispatch%3Adispatch_4d3657995ffea67354beee0e3dc91fd2/?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]>
dcramer added a commit that referenced this pull request Nov 26, 2026
Drops `junior_agent_invocations`, which #4043 kept for
one release after it removed every reader and writer.

Retention purge was the last code that touched the table. It no longer
checks the table for tree work or deletes its rows. A purge that runs on
0.316.0 while the deploy runs fails for that tree, and the next run
retries it.

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

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

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A33270748af6c2f0dbb21278b85dd6ef6)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A33270748af6c2f0dbb21278b85dd6ef6/?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]>
dcramer added a commit that referenced this pull request Nov 26, 2026
…#4173)

`listAgents` lost `last_result` `done` and `blocked` when the legacy
Agent invocation rows went away (#4043). Only `failed`
came back, in #4057.

It now uses main's `readTurnUpdate` mapping. `turn-update.ts` exports
`TURN_OUTCOME_STATUSES`, which both `readTurnUpdate` and
`listChildAgents` use. So `last_result` uses the same words as
`<agent-result status>`: `done`, `blocked`, or `failed` (it was
`completed` before).

The listing reads the child's own Turn lifecycle Events: the newest
`turn_completed` or `turn_failed` that is not a stop. `turn_failed`
gives `failed`. A cancelled Turn is skipped, so a stop or a retry keeps
the result from before it. `conversationTurnFailedSql` still decides the
child's `failed` status. A person's Turn in a Thread counts like any
other Turn. The read is a subquery in the existing listing query, so it
adds no statement.

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

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

--

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