Skip to content

Show a card in the chat when its agent hands work to another agent - #36848

Merged
brennanb2025 merged 7 commits into
mainfrom
brennanb2025/agent-handoff-inline-card
Nov 1, 2026
Merged

brennanb2025 merged 7 commits into
mainfrom
brennanb2025/agent-handoff-inline-card

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​365 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​354
Prod 37 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​295 $\color{#cf222e}{\Huge{\mathbf{−}}}$​58 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​237

Problem

When an agent in a native chat hands work to a new agent (orca agent launch ... --prompt <brief>, or orca worktree create --agent ... --prompt <brief>, which the orchestration skill uses for "just hand over the work"), the new chat starts and gets its task, but the original chat only shows the agent's own prose. There is no card and no way to click through to the agent that took over, so it is hard to find it or check that the handoff happened. A supervised orca orchestration worker-start already leaves a "Started worker" card; an independent handoff left nothing because the launch command never told Orca which chat it came from.

What changes for users

After an agent in a chat starts another agent, the original chat shows a card linking to it, on desktop and on the phone: the receiving agent's icon, name and live status, and the arrow that opens its chat (or terminal).

  • When a task was handed over, the card is headed "Handed off to agent" and shows the task.
  • When the agent was started without a task (no --prompt, a draft prompt, or a prompt that could not be typed into its terminal), the card is headed "Started agent" with no body.

The card survives restart and is drawn once per launch, even if the launch is retried or replayed. Supervised workers keep their "Started worker" card.

How

  • The CLI now sends its chat's Orca session ID on agent.launch / agent.launchReplay, only when it runs on the same host (never from a WSL environment or against a paired server). Older hosts ignore it.
  • After a successful launch from the orca CLI inside a chat, the host writes a display-only agent-handoff journal item into that chat, keyed by the launch operation ID, through the same path as the worker-start card (skips a cleared or rewound chat, never re-adds a removed card). Nothing here can refuse, hold or delay the launch.
  • The item projects to the existing agent card on desktop and phone; the heading is chosen from whether the card has a task (all locales). The card keeps the launched agent's icon when Orca can no longer look the agent up, the same as worker-start cards.

Differences from the common pattern

  • Separate item kind for an independent launch vs a supervised worker, keyed by the launch command, linking to the child, recorded whether or not a task was given: same as the common pattern.
  • The card also shows the task text and the agent's live status: intended, it is the existing approved agent card.
  • A prompt that couldn't be typed into the new agent's terminal still leaves a card (without the task): intended. The common pattern fails the creation call there and its keyed retry ends with a card; our launch reports success and hands the text back to the caller, so nothing retries, and the agent the card links to is running.
  • Recording the card can never fail or delay the launch (the common pattern fails the call if recording fails): intended, display bookkeeping never gates a user action. So if Orca quits in the moment between the launch finishing and the card being written, that card is lost: intended, same as worker-start cards.
  • orca worktree create --agent ... --prompt also leaves the card: intended, it is the skill's main handoff command and the ticket asks for a card on handoffs.
  • A terminal-surface handoff (including one onto a remote execution host) links by terminal handle, so after a restart that reissues handles the arrow reports the agent as gone: intended, same as worker-start terminal cards.
  • No card for the in-app "Hand Off to Another Agent" dialog: intended, the common pattern records only agents started by an agent's own tool call, not a person's UI action.
  • No card for chats running in WSL or a CLI pointed at a paired server: intended, the session ID only identifies a chat on the same host.

Compatibility

Older desktops and phones skip the unknown item over the wire (open schema). On disk, Orca's strict chat storage reader (#36024) opens a chat containing an item kind it doesn't know read-only. No desktop release contains #36024 yet (checked 2026-11-01: latest is v1.4.245), so nobody can hit this today. It would matter only if a desktop release ships #36024 without this PR and a user downgrades from a build with this PR to that release: chats holding this card would open read-only until they upgrade again, with no data lost. Merging this before the next desktop cut that includes #36024 means no such release exists.

Tests

  • agent-launch-handoff-card.test.ts: real agent.launchReplay from an agent's CLI through the real chat host and journal: one card per launch (a replay adds none), two launches give two cards, a removed card stays removed across a host restart (strict storage reader), structured and terminal addresses, cards without a task, and windows, a CLI outside a chat and failed launches record nothing.
  • client-execution-host.test.ts: the CLI sends the chat's session ID on launches (including from a chat with no terminal handle), and sends nothing from WSL or to a paired server.
  • journal-row-schema.test.ts: the item round-trips through the strict storage reader and projects to the card.
  • NativeChatAgentMessageCard.test.tsx and the phone agent card test: "Handed off to agent" with a task, "Started agent" without, "Started worker" for supervised workers.

Tracked in STA-13209.

An agent that hands work off with 'orca agent launch' from a native chat
now leaves a 'Handed off to agent' card there, linking to the new chat or
terminal, the way a supervised worker-start leaves 'Started worker'.

The CLI names its chat on agent launches (same-host only); the host records
a display-only agent-handoff item after a successful launch with a submitted
prompt, once per launch operation. Nothing about the card can refuse or delay
the launch.

Tracked in STA-13209.
@brennanb2025
brennanb2025 marked this pull request as ready for review November 1, 2026 01:51
@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 605fdf53-80f3-4f33-a99e-fd8b04f41fb0
Commits

Reviewing files that changed from the base of the PR and between a4c5551 and 7af8eb7.

Files selected for processing: 17
  • mobile/src/i18n/locales/de.json
  • mobile/src/i18n/locales/en.json
  • mobile/src/i18n/locales/es.json
  • mobile/src/i18n/locales/fr.json
  • mobile/src/i18n/locales/ja.json
  • mobile/src/i18n/locales/ko.json
  • mobile/src/i18n/locales/pt.json
  • mobile/src/i18n/locales/ru.json
  • mobile/src/i18n/locales/tr.json
  • mobile/src/i18n/locales/zh-Hant.json
  • mobile/src/i18n/locales/zh.json
  • mobile/src/session/native-chat/transcript/MobileNativeChatAgentMessageCard.tsx
  • mobile/src/session/native-chat/transcript/MobileNativeChatMessage.test.ts
  • src/main/runtime/orchestration/structured-mail-source.test.ts
  • src/main/runtime/rpc/methods/orchestration/agent-message-command-contract.test.ts
  • src/renderer/src/i18n/locales/ja.json
  • src/shared/agent-session/agent-message-presentation.ts
Files skipped from review as they are similar to previous changes: 1
  • src/renderer/src/i18n/locales/ja.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Walkthrough

The change adds journal support for agent handoffs and records eligible agent launches as handoff items. Local CLI launch calls can include caller session evidence. Native chat projects handoff items with an agent sender and selects handoff or agent-start headings based on message content. Localized labels and tests cover the new behavior and launch conditions.

Merge Risk: Minimal · up to 7af8e

No actionable merge-blocking risk was identified for the handoff cards.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check Warning The description clearly explains the problem, user-visible behavior, implementation, scope, compatibility risks, and tests. However, it does not follow the required template for several required items… Add the required template sections. Link the actual issue with Fixes #... or an equivalent issue link. Add before/after screenshots or videos, or state N/A with a brief reason if no visual or interaction change applies. Complete AI Disc…
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: showing a chat card when an agent hands work to another agent.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 16 functions across 24 files. (12 skipped: 12 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Full details: Description check

Explanation

The description clearly explains the problem, user-visible behavior, implementation, scope, compatibility risks, and tests. However, it does not follow the required template for several required items: it lacks an actual linked issue in the Linked Issue section, provides no Visual Proof section or explicit N/A statement, and omits the required AI Disclosure, Review, Notes, Agent skill upstream boundary, and Checklist sections.

Resolution

Add the required template sections. Link the actual issue with Fixes #... or an equivalent issue link. Add before/after screenshots or videos, or state N/A with a brief reason if no visual or interaction change applies. Complete AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist, including testing commands, platforms tested, and cross-platform/remote/mobile/backwards-compatibility considerations.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2669ba13-b946-470e-9cce-ee69663c3541
Commits

Reviewing files that changed from the base of the PR and between af211d6 and 9aa2f64.

Files ignored due to path filters: 1
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing: 30
  • src/cli/runtime/client.ts
  • src/cli/runtime/orchestration-compatibility-envelope.ts
  • src/main/native-chat/agent-session-journal/journal-row-schema.test.ts
  • src/main/native-chat/agent-session-journal/journal-storage-schema.ts
  • src/main/native-chat/agent-session-wire/structured-agent-start-journal.ts
  • src/main/runtime/orchestration/worker-start-card.ts
  • src/main/runtime/rpc/methods/agent-launch-handoff-card.test.ts
  • src/main/runtime/rpc/methods/agent-launch-handoff-card.ts
  • src/main/runtime/rpc/methods/agent-launch.ts
  • src/main/runtime/rpc/methods/orchestration/worker-start-card-operations.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker-start-card.test.ts
  • src/renderer/src/components/native-chat/NativeChatAgentMessageCard.test.tsx
  • src/renderer/src/components/native-chat/NativeChatAgentMessageCard.tsx
  • src/renderer/src/i18n/locales/de.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/pt.json
  • src/renderer/src/i18n/locales/ru.json
  • src/renderer/src/i18n/locales/tr.json
  • src/renderer/src/i18n/locales/zh-Hant.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/agent-journal-creation-facts.ts
  • src/shared/agent-session-journal-schemas.ts
  • src/shared/agent-session-journal-types.ts
  • src/shared/agent-session/agent-message-presentation.ts
  • src/shared/native-chat-types.ts
  • src/shared/structured-agent-start-projection.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

brennanb2025 and others added 6 commits October 31, 2026 19:17
The launch-caller evidence read the host stamp off an absent evidence object, so every orca command from an ordinary native chat threw before sending. Adds CLI tests for which requests name the launching chat, restores the lockfile to the base, and fixes the Korean heading.
A caller passing only the started flag drew a handoff as Started worker; the heading now takes the message's flags as one argument.
A launch without a delivered task now records the card too, with no task text, as the common pattern records every agent a chat creates. The handoff tests now run the real chat host and journal: one card per launch operation, none on replay, a removed card stays removed across a restart, and the clock is fixed.
Handed off to agent now appears only when the card carries a task; a card for an agent started with no task (no prompt, a draft, or a prompt that wasn't delivered) reads Started agent. The heading is derived from the card's text, so nothing new is saved. Also drops a self-launch check the launch path already refuses first.
Resolve conflicts with the session-module reorganization and with the
worker-start card's launched-agent fallback (#36653): the handoff card
uses the same fallback, keeping the launched agent's kind when the
sender lookup can't find it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The phone card passed only the started flag, so with the new heading rules it would draw every creation card as a plain message. It now passes the message and has a heading for every case, so a missing one fails the build. The heading function now requires the message's creation facts, so no caller can leave them out. Adds the phone strings in every language, and the Japanese "Started agent" now uses the catalog's term for agent.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@brennanb2025

brennanb2025 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Review loop status

The problem. When an agent in a native chat handed work to a new agent (orca agent launch ... --prompt, or orca worktree create --agent ... --prompt, the orchestration skill's "just hand it over" path), the new chat started and got its task, but the original chat showed only the agent's prose: no card, and no way to click through to the agent that took over. The launch command never told Orca which chat it came from, so nothing could be recorded there.

What changes for users. The original chat now shows a card linking to the agent it started, on desktop and on the phone. It is headed "Handed off to agent" with the task when a task was handed over, and "Started agent" with no body when there was no task. The card survives restart and appears once per launch. Supervised workers keep "Started worker".

Fixed during review.

  • Every orca command run from a native chat with no terminal handle would have thrown before it started. Fixed, with a CLI test.
  • A launch without a task now gets a card too, matching the common pattern, under a neutral "Started agent" heading instead of claiming a handoff.
  • The heading function now requires the message, so no caller can drop the handoff facts. This caught main's new phone cards (Show agent message cards in phone chats #36162), which had been passing the old flag: after merging main, phone worker cards would have read "Message from …" instead of "Started worker". The phone card now uses the new headings, with phone strings in every language.
  • Smaller fixes: test coverage of the real launch → journal → card path, a lockfile revert, the Korean and Japanese wording, and dead code.

Deferred (not blocking). The card can be lost if Orca quits in the instant between the launch finishing and the card being written. Worker-start cards have the same gap.

Verified.

  • Review: 4 rounds plus a check of the main merge. The last round found nothing new, and the final reference comparison found every difference labelled in the PR description.
  • Real QA run on a4c5551, this Mac, with real Claude and Codex native chats, 6 flows, all PASS:
    • Claude hands off to Codex, and Codex hands off to Claude: one card each, the arrow opens the receiver, and the receiver gives a real reply.
    • orca worktree create --agent: card and real reply.
    • A launch with no prompt shows "Started agent" with no body.
    • Other orca commands still work from inside a chat.
    • After a graceful restart, the card counts and content are unchanged.
  • The commit after QA (7af8eb7) changes only the phone card, the shared heading helper's signature (desktop already passed the message) and the Japanese string. Those are covered by renderer tests, CI and the iPhone simulator screenshots below, taken on 7af8eb7.
  • CI green on 7af8eb7.

Not verified. Android phone (iOS simulator only). The phone screenshot's open arrow was answered by a mock host, not a real one.

For Brennan's review

  • Desktop, task handed over (Claude → Codex): (screenshot removed: contained real product data)
  • Desktop, Codex → Claude: (screenshot removed: contained real product data)
  • Desktop, new worktree handoff: (screenshot removed: contained real product data)
  • Desktop, launch with no task ("Started agent"): (screenshot removed: contained real product data)
  • Desktop, after restart: (screenshot removed: contained real product data)
  • Phone (en), worker / handoff / started: (screenshot removed: contained real product data)
  • Phone (de): (screenshot removed: contained real product data)
  • Where judgment matters:

Noticed, not this PR (on main):

  • Phone language files other than English lack the older agent-card strings, so a German phone shows "Started worker" in English next to "Agent gestartet".
  • The phone takes an agent card's icon only from that agent's open tab (untested guess that it falls back to a generic icon once the tab is gone).
  • A Codex chat's login shell can put a stale /usr/local/bin/orca ahead of Orca's own CLI.
  • The model name shows as "Claude Opus 5 5", missing its dot.

@brennanb2025
brennanb2025 merged commit ad864a6 into main Nov 1, 2026
66 checks passed
audichuang pushed a commit to audichuang/orca that referenced this pull request Nov 2, 2026
…tablyai#36848)

* Show a card in the chat when its agent hands work to another agent

An agent that hands work off with 'orca agent launch' from a native chat
now leaves a 'Handed off to agent' card there, linking to the new chat or
terminal, the way a supervised worker-start leaves 'Started worker'.

The CLI names its chat on agent launches (same-host only); the host records
a display-only agent-handoff item after a successful launch with a submitted
prompt, once per launch operation. Nothing about the card can refuse or delay
the launch.

Tracked in STA-13209.

* Keep orca commands working in a native chat that has no terminal handle

The launch-caller evidence read the host stamp off an absent evidence object, so every orca command from an ordinary native chat threw before sending. Adds CLI tests for which requests name the launching chat, restores the lockfile to the base, and fixes the Korean heading.

* Read a card's heading from its creation flags together

A caller passing only the started flag drew a handoff as Started worker; the heading now takes the message's flags as one argument.

* Show the handoff card for every agent a chat launches

A launch without a delivered task now records the card too, with no task text, as the common pattern records every agent a chat creates. The handoff tests now run the real chat host and journal: one card per launch operation, none on replay, a removed card stays removed across a restart, and the clock is fixed.

* Head a launch card Started agent when no task reached the new agent

Handed off to agent now appears only when the card carries a task; a card for an agent started with no task (no prompt, a draft, or a prompt that wasn't delivered) reads Started agent. The heading is derived from the card's text, so nothing new is saved. Also drops a self-launch check the launch path already refuses first.

* Show the handoff headings on the phone's agent cards

The phone card passed only the started flag, so with the new heading rules it would draw every creation card as a plain message. It now passes the message and has a heading for every case, so a missing one fails the build. The heading function now requires the message's creation facts, so no caller can leave them out. Adds the phone strings in every language, and the Japanese "Started agent" now uses the catalog's term for agent.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

(cherry picked from commit ad864a6)
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