Repository navigation
Agent launches carry the surface that started them - #23697
Conversation
The host now attributes every agent it builds to the surface that asked for it, resolving a missing or unrecognized surface to 'unknown' in one place instead of silently skipping it. The CLI names itself on worktree.create and orchestration workers name themselves host-side.
The host builds a third kind of agent launch: a worktree.create with a startupDraft and no startupAgent, where the host picks the agent itself. It carried no launch record at all and ignored the caller's launchSource. Route it through the same resolver as the other two builders, and derive the startupAgent terminal record only from the resolver so no prebuilt record can stand in for it.
…nches terminal.createAgentSession builds a fresh agent's launch on the host, like the other startup builders, but spawned it with no launch record, so those launches were never counted. Record them through the same resolver; the request names no surface, so they count as unknown.
…ilt agent startup
Review status: ready for review (still a draft; not merged)Head What review changed
Verification
Live host check (separate Mac, development build of this branch vs
Round 1 results (head CLI
Desktop quick launch at head Known gaps (all predate this PR and are listed in the description)
Not covered live: orchestration federation to a paired server (the rig had no paired server), and desktop entry points other than the quick launch, which this PR does not change. |
|
| 'startupCommandDelivery' | ||
| 'startupCommandDelivery', | ||
| // The launch carries its own; a create's copy would be a second, possibly contradicting, answer. | ||
| 'launchSource' |
There was a problem hiding this comment.
Ignored source causes replay conflict A create payload's
launchSource is now ignored when the launch runs, but it is still included when the host fingerprints the request. If a retry uses the same operation ID and changes or omits only that ignored copy, the host returns agent_session_operation_conflict instead of replaying the launch result. Exclude the reserved field from the fingerprint too.
Knowledge Base Used: Relay protocol and transport
| it('has an attribution decision for every builder call', () => { | ||
| const undecided = [...found] | ||
| .filter(([path, calls]) => calls > (LISTED.get(path)?.calls ?? 0)) | ||
| .map(([path, calls]) => `${path}: ${calls} calls, ${LISTED.get(path)?.calls ?? 0} decided`) | ||
| expect(undecided, `New host-built agent startup. ${DECIDE}`).toEqual([]) | ||
| }) | ||
|
|
||
| it('has no stale entry', () => { | ||
| // A count left above reality lets the next call in that file land without a decision. | ||
| const stale = [...LISTED] | ||
| .filter(([path, entry]) => entry.calls > (found.get(path) ?? 0)) | ||
| .map(([path, entry]) => `${path}: ${found.get(path) ?? 0} calls, ${entry.calls} listed`) | ||
| expect(stale, 'Lower or delete the entry to match the calls that remain.').toEqual([]) |
There was a problem hiding this comment.
Call counts miss replacements The guard compares only the number of builder calls in each file. Replacing an attributed call with an unattributed one leaves that number unchanged, so all these checks pass and the new launch can go uncounted. Checking call-site identity or attribution at each site would close this non-blocking coverage gap.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (29)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe change forwards launch-source values from CLI, RPC, and orchestration callers into worktree and terminal startup paths. Runtime startup builders now attach agent-start telemetry to host-built agent launches. Missing or unrecognized sources are recorded as Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to No actionable issue remains identified for this change; it is mergeable after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to Launch-origin reporting changes across several launch paths, but the inspected behavior does not let an origin label authorize a launch or select a workspace. The main residual risk is that callers can claim an origin for reporting; the effect of that claim outside launch counts is not established. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 28 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
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. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Host-side attribution resolver — new
agentStartedTelemetryunifies the two private copies and resolves a missing/unrecognized surface to'unknown'instead of dropping the record, so a launch is never silently uncounted. - Runtime terminal attribution —
createTerminalnow takes the caller'slaunchSourceand derives the triple from the agent it actually resolved (resolveAgentTerminalCreateOptions), leaving a bare typed command unattributed. - Create-path propagation —
worktree.creategains an open-stringlaunchSource, mapped tostartupLaunchSource; the worktree startup builders always attach telemetry, withAttributedWorktreeStartupLaunchmaking omission a compile error. - Producer wiring — CLI sends
cli, orchestration workers nameorchestrationhost-side,terminal.createAgentSessionrecordsunknown, andlaunchSourceis added to the reserved create fields so a launch's own source outranks a create payload's copy. - Vocabulary + guard —
cli/mobile/orchestrationadded tolaunchSourceSchema, plus a source-scanning test that requires an attribution decision for every host-side startup builder call.
I traced every host-side builder call site in the diff and its immediate callers in src/main. Each fresh start reaches the telemetry attachment except the three gaps the description declares as pre-existing (desktop prebuilt startupCommand at worktree.create, the phone's session.tabs.createTerminal, and agent-session resume). The new tests are meaningful (they assert the exact triple, and the unchanged source would leave it undefined), pnpm tc:node passes, and oxlint is clean on the changed files. The runtime-service specs (orca-runtime-tests/*.spec.ts) fail in this container with selector_not_found, including their pre-existing tests, because no real git worktree exists here — environment, not this PR.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏





ELI5
When Orca itself builds an AI agent's launch, it now always notes which part of Orca asked for it — the desktop app, the
orcacommand line, or an orchestration worker, orunknownwhen the caller did not say. Before, agents started from the command line or by orchestration carried no such note, so Orca could not tell where they came from. Today that note is used in one place: Orca's record that an agent started (theagent_startedevent), which is how launches are counted per surface.What Changed
Before: the host recorded which surface started an agent only when the caller happened to name one, and silently recorded nothing otherwise. The
orcaCLI (worktree create --agent/--prompt, andorchestration worker-start, which the host runs as an orchestration worker) never named one, so those launches were invisible.After: every agent the host builds is attributed to a surface. A caller that names none — including older CLIs and phones — is recorded as
unknownrather than dropped.Mechanism:
agentStartedTelemetryinsrc/main/agent-launch/agent-started-telemetry.ts, replaces two identical private copies. It keeps a known surface and resolves a missing or unrecognized one tounknown.startupAgent(used byagent.launch, orchestration workers in an existing worktree, and federation); the worktree-create builder for a named agent (used byworktree.create,agent.launchinto a new worktree, orchestration workers in a new worktree, and headless-server automations, both the ones that create a workspace and the ones that run in an existing one); the worktree-create builder for astartupDraft, where the host picks the agent itself (the task-driven create from the phone and from a desktop connected to a remote Orca server); andterminal.createAgentSession, which a desktop connected to a remote Orca server, and the web client, use to start a new agent tab. The draft builder andterminal.createAgentSessionpreviously recorded nothing at all;terminal.createAgentSessionnames no surface on the wire (its params are strict), so it recordsunknown.createTerminaltakes the caller'slaunchSourcestring instead of a prebuilt record, and derives the record only from it, so the host takes the agent kind from the agent it actually resolved.worktree.creategains an optionallaunchSource, sharing one open-string schema (LaunchSourceParam) withagent.launch. The CLI sendscli. Inside anagent.launchcreate, the launch's ownlaunchSourceis authoritative, so a copy in the create payload is stripped with the other reserved agent fields.orchestrationhost-side; nothing new crosses the wire for them.telemetry, so dropping it fails to compile; and a test lists every host-side call that builds an agent's startup command with its decision (attributes,resume, or the phone follow-up), so a new call fails until its author decides whether it is a fresh start.cli,mobileandorchestration.mobileis added now so hosts from this release already recognise it when the phone starts sending it; the phone change is a separate follow-up.Not changed: a bare agent command typed into
terminal create --commandstays unattributed, as before. Structured chat sessions still report no start on any surface, desktop included. Three host paths still record nothing, as before: the startup command a desktop connected to a remote Orca server prebuilds for a new workspace (it arrives as a plain command); an agent tab the phone opens withsession.tabs.createTerminal(the host builds that launch, but when a desktop window is open it hands the spawn to that window, where no record travels today); and resuming an agent session (a resume, not a new start). These gaps predate this change. Headless automations name no surface, so they are now recorded asunknown, which is what desktop automations already report.Why
Launches are converging on one entry point used by desktop, phone, CLI, orchestration and later plugins, so the surface that started each launch has to come with the launch itself. Today the host uses it only for the
agent_startedrecord; it is not stored with the agent, and no host behaviour depends on it. The desktop does readlaunch_sourcein one place, a Windows focus guard for its own sidebar history resumes, which a host-built launch (always a new start) can never match. Resolving the default in the host, at the point the agent is built, means a new caller cannot silently opt out — the alternative, asking each caller to remember, is exactly how the CLI and orchestration went missing.Deriving the surface from the connection type was considered and rejected: it only distinguishes phones, since the CLI and a remote desktop connect the same way, so it would be a second, partial defaulting rule.
Mixed versions stay safe: the wire field is an open string, so an older host receives a newer client's surface without refusing the launch (it records nothing, as today), an older host without the field ignores it, and an older client sending nothing to a new host is recorded as
unknown.Linked Issue
None; part of the agent-launch series.
Visual Proof
N/A — no UI or interaction change; this changes what the host records about a launch, not what the user sees.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
New tests fail without the change (11 failing when the source files are reverted to
main) and pass with it: runtime attribution for a named, missing and unrecognized surface; the startup builder'sunknowndefault;worktree.createpassing the surface through (including an unrecognized one without refusing the create); the CLI sendingcli; orchestration workers sendingorchestrationin both the new-worktree and existing-worktree paths.Agent sessions the host builds (
terminal.createAgentSession, added in review) are recorded asunknown; this fails without the fix.Startup-draft creates (added in review): the draft builder attributes both of its launch shapes, a named surface or
unknown, and a runtime create passes the caller's surface through to the spawned agent. These fail without the fix.Attribution guards (added in review):
host-agent-startup-attribution.test.tsfails on a new builder call in a new or already-listed file (reformatted across lines too), on a stale count, and on an unknown decision; commented-out calls are ignored. Droppingtelemetryfrom a worktree startup builder is a compile error.Regression guards that pass on both: a bare typed command stays unattributed; an
agent.launchcreate uses the launch's own surface, never the create payload's copy.Existing
agent.launchtests updated: the handler now forwards the caller's surface to the runtime instead of building the record itself.pnpm tc:nodeandpnpm tc:clipass; oxlint andcheck:code-quality:changedare clean; 1,512 test files pass acrosssrc/cli,src/shared,src/main/runtime/rpc, the runtime service suite,src/main/agent-launch,src/main/ipc/ptyandsrc/main/agent-hooks. One timing test (src/cli/runtime/transport.test.tskeepalive) failed once under full load and passed 3/3 in isolation; it is unrelated.Live host check on a separate Mac, with a development build of this branch and of
main(a QA-only log line prints each record the host would send, since development builds send none; every agent was a stand-in process): CLIworktree create --agentrecordscli; orchestration workers in a new and an existing worktree recordorchestration;agent.launchwith no surface or an unknown one recordsunknownand is not refused; a startup-draft create records the named surface orunknown;terminal.createAgentSessionrecordsunknownonce and a replay adds nothing; a bareterminal create --command clauderecords nothing; the desktop quick launch recordstab_bar_quick_launchon both builds; and a CLI built frommainagainst this build recordsunknownwhile the create succeeds.mainrecords nothing for any of the host-built launches.Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Security: no new input is trusted; the surface is a label parsed leniently, and the host never reads it as behaviour.
Cross-platform: no platform-dependent code.
SSH/remote: the resolver runs in the Orca host that builds the launch, the same place for local, SSH and folder workspaces, through the same create paths.
Mobile: no mobile code changes and no recorded fixtures move. Phones keep working unchanged; their
agent.launchand task-driven creates are recorded asunknownuntil the follow-up sendsmobile, and their session-tab agents stay unattributed (see Not changed).Desktop fallback: when the host cannot spawn a startup it built and hands it to the desktop to spawn instead, that startup now carries the record, so the desktop's spawn records
agent_started(oragent_errorfor that agent if the spawn fails). The desktop also reads the record's agent kind, as it already does for startups it builds itself, to mark the tab as that agent and to treat the tab's output while hidden as an agent's (restored from a snapshot on reveal, with its startup terminal queries still answered). Before, such a tab was left unmarked and got that hidden-output handling only when the desktop recognised the launch command.Backwards compatibility: covered in Why; the new field is optional and open, and no capability or opcode is added.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)