Skip to content

feat: live Cursor subagent activity in the task card - #99

Merged
justin-carper merged 2 commits into
mainfrom
subagent-output-into-subagent-view
Aug 21, 2026
Merged

feat: live Cursor subagent activity in the task card#99
justin-carper merged 2 commits into
mainfrom
subagent-output-into-subagent-view

Conversation

@justin-carper

Copy link
Copy Markdown
Collaborator

A Cursor subagent's task card now behaves like a native opencode subagent card: navigable while running, with a live ↳ <Tool> <title> activity subtitle, and the child session carries the subagent's own output.

How it works

  • Child session up-front. The child session is created when the task call starts and state.metadata.sessionId is stamped on the running task part via part.update (the native task tool's execute-time metadata equivalent). The TUI reads part.state.metadata.sessionId for navigation, so the card is clickable / ctrl+x-navigable from the start of the run, not just after completion.
  • Live activity from streamed events. The Cursor SDK streams a local subagent's nested activity via taskUpdate payloads on the parent task's tool-call-delta updates (text, thinking, tool-start/tool-result with id + name + input). These are normalized into subagent-events and written into the child session as real tool parts via the part.update upsert — the exact mechanism opencode's processor uses — so the TUI's task card shows live activity while the subagent runs. Tool calls complete when their tool-result arrives; any call left open is completed at finalize.
  • Full transcript in the child session. The child session is seeded with the subagent's prompt and receives its rendered activity: assistant text, thinking, tool calls with args and results, conversation steps, final answer, and duration. No truncation.
  • Reliable child writes. upsertToolPart treats a resolved { error } response as failure (the hey-api client does not throw on 4xx) and always sends state.metadata on completed parts, which opencode's completed-state schema requires. Child-session writes are best-effort: a failed write is logged, never breaks the parent turn.
  • cursor_delegate also links a child session seeded with its transcript, discoverable via the TUI's subagent panel.

Verification

  • npm run typecheck && npx vitest run && npm run build — 567/567 tests pass.
  • Live opencode run exercise (with the local provider override): tool parts appear in the child session mid-run with real start/end timestamps, and the parent task part carries state.metadata.sessionId while the subagent is still running.

The 08-06 plan's transcript-tail design is annotated as superseded: the
Cursor SDK streams nested subagent activity live via taskUpdate payloads
on the parent task's tool-call-delta updates, and short subagents only
checkpoint their on-disk transcript at completion.
A Cursor subagent's task card now behaves like a native opencode subagent
card: clickable while running, with a live activity subtitle.

- Child session is created up-front when the task call starts and
  state.metadata.sessionId is stamped on the RUNNING task part via
  part.update (the native task tool's execute-time equivalent), so the
  card is navigable from the start of the run.
- Nested subagent activity (taskUpdate payloads on the parent task's
  tool-call-delta updates) is normalized into subagent-events and
  materialised as real tool parts in the child session (upserted via
  part.update): running on tool-start, completed on tool-result, with
  stragglers completed at finalize. This is what the TUI reads for its
  live activity subtitle.
- The child session is seeded with the subagent's prompt and its
  rendered activity (text, thinking, tool calls, conversation steps,
  final answer, duration).
- upsertToolPart treats a resolved { error } response as failure
  (hey-api's request does not throw on 4xx) and always sends
  state.metadata on completed parts, which the schema requires.
- cursor_delegate also links a child session seeded with its transcript.
@justin-carper
justin-carper merged commit f925868 into main Aug 21, 2026
8 checks passed
@justin-carper
justin-carper deleted the subagent-output-into-subagent-view branch August 21, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant