Skip to content

fix(server): resumed background agents show in the Agents panel again - #173

Merged
badcuban merged 2 commits into
mainfrom
fix/resumed-subagent-tracking
Aug 22, 2026
Merged

badcuban merged 2 commits into
mainfrom
fix/resumed-subagent-tracking

Conversation

@badcuban

Copy link
Copy Markdown
Collaborator

A thread could sit at "waiting" while a background agent worked, with the Agents panel insisting no agents exist. Resuming a background agent by sending it a message (SendMessage with its agent id) never touched the agent's roster row: the row settled after the first run and nothing recognized the revival, including across a provider session restart, where the in-memory launch records are gone entirely.

Two layers, matching how the identity survives:

  • The adapter learns each background agent's id from its launch result. When the model sends a message to a known agent id, it clears the settled bookkeeping from the previous run (task status, start-edge dedupe, completed-item sets) and re-emits the agent as running, so the same roster row goes live immediately and the run's eventual notification settles it again with its new result. Unknown targets (teammates, cross-session addresses) are ignored: only real agents of this thread ever appear.
  • The subagent projection re-opens a settled row when its task reports work again, matched by the durable task id link. This covers the restart case, where the adapter context remembers nothing: the SDK repeats task_started under the original task id and the row returns to running from the projection alone. Guarded to agent-shaped tasks and update-only, so background commands and unknown tasks can never create or move a row.

Task snapshots now keep the spawning call as their tool id (first writer wins), so a resumed run's completion replays onto the original spawn item instead of minting a duplicate row keyed by the resuming call.

Known limitation, deliberately out of scope: after a provider restart, a resumed agent's live commentary text does not stream into the panel (the launch record it routes through is gone); the row's status lifecycle is correct. Codex has no resume-by-message equivalent, so nothing applies there.

A background agent the model revives by sending it a message keeps
working under its original task id, but reports that work under the call
that resumed it. The roster matched only on the spawning tool call, so
the row stayed settled and the Agents panel showed nothing while the
agent ran.

Agent task starts and progress now re-open a settled row, matched by the
transcript link the task stream established. Update-only: a task that
names no known agent still creates no row.
Every path that settles a background agent stops at the task and item ids
it has already seen finish, so a SendMessage resume was swallowed: no new
start edge, no second completion, and the agent's live text and final
result had nowhere to land.

The adapter now remembers which spawn owns each launched agent id and,
when the model sends that agent a message, clears the bookkeeping the
previous run left behind and reports the agent as running again. A target
that is not a background agent of this session is ignored, so no row is
invented for an agent the thread cannot show.
@vercel

vercel Bot commented Aug 22, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
threadlines Skipped Skipped Aug 22, 2026 8:39am

Request Review

@github-actions github-actions Bot added size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Aug 22, 2026
@badcuban
badcuban merged commit b0774a7 into main Aug 22, 2026
15 checks passed
@badcuban
badcuban deleted the fix/resumed-subagent-tracking branch August 22, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant