Repository navigation
refactor(agent-launch): make the launch-mode decision surface-neutral - #19848
Conversation
`decideWorkerStartMode` was the only shared answer to "structured chat session
or terminal agent?", but it lived in an orchestration-named module and spoke
orchestration's vocabulary, so the other launch surfaces could not call it.
Move the decision to `main/agent-launch/agent-launch-mode` unchanged and leave
`orchestration-worker-start-mode` as the adapter that supplies the noun.
A worker is not a special kind of launch; it is the same launch with a dispatch
attached. Naming the receipt's subject is the only thing orchestration actually
contributed, so that is the only thing the adapter keeps: "worker" in both
sentences, plus the `--terminal` wording, which reads as nonsense anywhere a
`--terminal` flag does not exist. Both are pinned, because they are asserted.
No behavior change. The receipts are byte-identical for every reachable case,
proven by running the new pin against both implementations.
Also pins the wording, which nothing was holding. The existing suites assert
`toContain` fragments ('terminal agent', 'cannot create') and the CLI suite
asserts a receipt handed to it by a mock rather than one this code produced;
all six files stayed green against a deliberately corrupted vocabulary. A
dispatch receipt is the only place a structured-to-terminal downgrade explains
itself, so the whole sentence is the contract, not a fragment of it.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Extract shared launch-mode decision — moves
decideWorkerStartModeand its host-resolution half intosrc/main/agent-launch/agent-launch-mode.ts(decideAgentLaunchMode,resolveAgentLaunchModeOnHost,downgradeAgentLaunchModeForHost,readAgentLaunchModeSettings), parameterizing the receipt noun and per-reason wording throughAgentLaunchModeVocabulary. - Thin orchestration adapter —
orchestration-worker-start-mode.tsre-exports the old names and contributes onlyWORKER_START_VOCABULARY("…worker" nouns plusdetailOverridesforremote_execution_hostandreused_terminal), preserving the--terminaland "worker" wording. - Receipt-wording pin — new
orchestration-worker-start-receipt-wording.test.tsasserts 11 exact receipt sentences that were previously unpinned.
I verified the receipts are byte-identical: the old orchestration wording differed from the neutral defaults only on remote_execution_host and reused_terminal, exactly the two reasons the adapter overrides. The decision mappings (BLOCKER_REASON, HOST_SUPPORT_REASON, resolveStructuredNativeChatSupport input) moved verbatim, and every old export is re-exported so no caller breaks. The new test is load-bearing by construction — it toEquals full detail strings rather than toContain fragments — and the affected suites pass (36/36 across the new pin and the existing mode test).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe pull request adds a launch-mode module for structured and terminal agent sessions. It produces receipts with the selected mode, preference, reason, and detail. The decision runs before workspace resolution and then applies host support results. Settings reads return Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to No concrete merge-blocking issue remains established. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description is detailed and covers the required sections, testing, scope, platform impact, and visual proof. However, the required Linked Issue entry is missing: it contains
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: b5d309c6-8531-410e-91f4-18031a15dac1
📒 Files selected for processing (3)
src/main/agent-launch/agent-launch-mode.tssrc/main/runtime/rpc/methods/orchestration-worker-start-mode.tssrc/main/runtime/rpc/methods/orchestration-worker-start-receipt-wording.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| export type WorkerStartMode = AgentLaunchMode | ||
| export type WorkerStartModeReason = AgentLaunchModeReason | ||
| export type WorkerStartModeReceipt = AgentLaunchModeReceipt |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Restore the WorkerStartModeSettings export.
The adapter no longer exports the existing WorkerStartModeSettings name. Existing consumers that import this type will fail type checking.
Add an alias and retain it in the worker-facing signatures. This keeps the adapter API stable as required by the PR objective.
Proposed fix
export type WorkerStartMode = AgentLaunchMode
export type WorkerStartModeReason = AgentLaunchModeReason
export type WorkerStartModeReceipt = AgentLaunchModeReceipt
+export type WorkerStartModeSettings = AgentLaunchModeSettings
export function decideWorkerStartMode(args: {
params: WorkerStartModePlacement
- settings: AgentLaunchModeSettings | null | undefined
+ settings: WorkerStartModeSettings | null | undefined
}): WorkerStartModeReceipt {
export function readWorkerStartModeSettings(
runtime: Pick<OrcaRuntimeService, 'getClientSettings'>
-): AgentLaunchModeSettings | null {
+): WorkerStartModeSettings | null {Also applies to: 53-53, 80-80
|
Review completed.
|
There was a problem hiding this comment.
Caution
The origin/main merge (9b5188c) reverted the refactor of orchestration-worker-start-mode.ts, so this PR no longer does what it claims: the surface-neutral decision module it introduces is now orphaned dead code, and the typecheck is red.
Reviewed changes
- Merged
origin/main— brought the branch up to date, but the merge resolvedorchestration-worker-start-mode.tsback to its pre-refactor form and pulled in an unrelatedconsole.logreformat intests/e2e/worktree-switch-first-paint.spec.ts.
🚨 The merge undid the refactor, leaving the new decision module orphaned
The merge commit reverted orchestration-worker-start-mode.ts to its original 217-line form (inline decision logic, orchestration vocabulary), while src/main/agent-launch/agent-launch-mode.ts (248 lines) remains in the tree as a new file. Nothing imports it — a repo-wide search finds zero references outside a comment. The decision is back to living inside the orchestration module, which is exactly the state this PR exists to change, and the new orchestration-worker-start-receipt-wording.test.ts now imports decideWorkerStartMode/downgradeWorkerStartModeForHost from the reverted module, so it pins the old code while its own doc comment claims the decision "moved to main/agent-launch/agent-launch-mode".
Technical details
# Restore the refactor lost in the merge
## Affected sites
- `src/main/runtime/rpc/methods/orchestration-worker-start-mode.ts` — reverted to the pre-refactor implementation; should be the thin adapter that re-exports the `WorkerStart*` names and supplies `WORKER_START_VOCABULARY`.
- `src/main/agent-launch/agent-launch-mode.ts` — new module, currently orphaned (no importers).
- `src/main/runtime/rpc/methods/orchestration-worker-start-receipt-wording.test.ts` — currently asserts the reverted module's output, not the new module's.
## Required outcome
- The `orchestration-worker-start-mode.ts` adapter (as it existed at `f34d08a`) is restored so it imports and delegates to `agent-launch-mode`.
- `agent-launch-mode.ts` has at least one real consumer.
## Open questions for the human
- Was the merge conflict resolved by taking `main`'s version of the file? If so, re-apply the adapter change on top.DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…son map main removed the draft-prompt blocker in #19681 (a structured session now holds an unsent draft), so the exhaustive Record no longer typechecks.
…2025/revive-agent-launch-mode
…cast The type-assertion gate landed after this branch's base, so the new file's copy of the worker-start cast is now a changed-code finding.
There was a problem hiding this comment.
Important
The new commits fix the stale 'draft-prompt' entry, and the typecheck is green again. But the prior review's central requested change — restoring the refactor the merge reverted — is still absent. orchestration-worker-start-mode.ts remains main's original, so agent-launch-mode.ts is orphaned and this PR does not yet do what its title and body claim.
Reviewed changes
- Fixed the stale
'draft-prompt'entry — dropped it fromBLOCKER_REASONinagent-launch-mode.ts;tsc --noEmit -p config/tsconfig.node.jsonnow exits clean. - Carried a
SAFETY:rationale on theplacement.agent as TuiAgentcast. - Reverted the unrelated
tests/e2e/worktree-switch-first-paint.spec.tsconsole.logreformat pulled in by the earlier merge. - Merged
origin/mainforward (base is now18d0afc).
⚠️ The refactor is still missing, so agent-launch-mode has no consumer
src/main/runtime/rpc/methods/orchestration-worker-start-mode.ts is unchanged from main — the same 217-line implementation with inline decision logic and orchestration vocabulary, no import of agent-launch-mode and no WORKER_START_VOCABULARY. A repo-wide search for agent-launch-mode finds only the new test's doc comment, so the 248-line module is dead code. The new orchestration-worker-start-receipt-wording.test.ts imports decideWorkerStartMode/downgradeWorkerStartModeForHost from that reverted module, so it still passes against main's existing code, and its own comment ("the decision moved to main/agent-launch/agent-launch-mode") is false. Net effect of the PR today is two added files, one of them unreferenced.
Technical details
# Restore the orchestration adapter lost in the merge
## Affected sites
- `src/main/runtime/rpc/methods/orchestration-worker-start-mode.ts` — still the pre-refactor implementation; should be the thin adapter as of `f34d08a`: import `decideAgentLaunchMode`, `downgradeAgentLaunchModeForHost`, `readAgentLaunchModeSettings`, `resolveAgentLaunchModeOnHost` from `../../../agent-launch/agent-launch-mode`, re-export the `WorkerStart*` names as aliases of the `AgentLaunchMode*` types, and export `WORKER_START_VOCABULARY` (`structured: 'a structured chat session worker'`, `terminal: 'a terminal agent worker'`, `detailOverrides` for `remote_execution_host` and `reused_terminal`).
- `src/main/agent-launch/agent-launch-mode.ts` — new module, currently zero importers.
- `src/main/runtime/rpc/methods/orchestration-worker-start-receipt-wording.test.ts` — pins the reverted module's output; will exercise the new module once the adapter is re-applied.
## Required outcome
- `orchestration-worker-start-mode.ts` delegates to `agent-launch-mode` and is the module's consumer.
- The receipts stay byte-identical to `main`'s (the new pin covers this), so the move remains behavior-preserving.
## Suggested approach (optional)
Re-apply the `f34d08a` version of `orchestration-worker-start-mode.ts` on top of the current tree; the merge conflict was resolved by taking `main`'s side, so nothing in that file needs reconciling.
## Open questions for the human (optional)
- Was it intentional to land the neutral module ahead of its consumer, with the adapter deferred to a later PR in the stack? If so, the PR title/body and the new test's doc comment need to say that.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…tion The decision was never moved out of orchestration-worker-start-mode; this PR adds a second copy beside it. Say so, and name the unenforced agreement.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The only commit since the prior pullfrog review (1dd74f6) is documentation-only: it corrects the receipt-wording test's doc comment, with no behavioral surface touched. The pin still passes 11/11.
- Corrected the receipt-wording test's premise — its doc comment no longer claims the decision "moved to
main/agent-launch/agent-launch-mode". It now states that the test pins orchestration's own module, that the neutral module is a second copy of the same policy, and that nothing yet enforces the two agree. This matches the PR body, which documents the two-copy state as intentional stack groundwork rather than a migration.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…launch-mobile The base moved 31 commits: #19849 merged main forward, #19848 landed on main as a squash, and several mobile domains migrated onto typed RpcOperations. The only conflicts were 12 settings goldens, and only in two header digests. Both sides had moved a digest for a legitimate and different reason: upstream added ~35 files under src/test-support/rpc-recording/, which recorderSha256 covers, while this branch edited workspace-settings-mounts.ts, which adapterSha256 covers - and upstream never touched that adapter. So neither side's pair described the merged tree, and taking either wholesale would have committed a header that lies about the sources it was recorded from. Resolved by re-recording from the merged tree, which computes both digests from the actual merged files. The result pairs upstream's recorderSha256 with this branch's adapterSha256. All 12 bodies are byte-identical to what was already on disk, so nothing behavioural changed: the conflict was entirely provenance. The golden set grew 208 -> 509 with upstream's new scenarios; recorded set and on-disk set match exactly, with no stale and no missing files.
…stablyai#19848) * refactor(agent-launch): make the launch-mode decision surface-neutral `decideWorkerStartMode` was the only shared answer to "structured chat session or terminal agent?", but it lived in an orchestration-named module and spoke orchestration's vocabulary, so the other launch surfaces could not call it. Move the decision to `main/agent-launch/agent-launch-mode` unchanged and leave `orchestration-worker-start-mode` as the adapter that supplies the noun. A worker is not a special kind of launch; it is the same launch with a dispatch attached. Naming the receipt's subject is the only thing orchestration actually contributed, so that is the only thing the adapter keeps: "worker" in both sentences, plus the `--terminal` wording, which reads as nonsense anywhere a `--terminal` flag does not exist. Both are pinned, because they are asserted. No behavior change. The receipts are byte-identical for every reachable case, proven by running the new pin against both implementations. Also pins the wording, which nothing was holding. The existing suites assert `toContain` fragments ('terminal agent', 'cannot create') and the CLI suite asserts a receipt handed to it by a mock rather than one this code produced; all six files stayed green against a deliberately corrupted vocabulary. A dispatch receipt is the only place a structured-to-terminal downgrade explains itself, so the whole sentence is the contract, not a fragment of it. * fix(agent-launch): drop the deleted draft-prompt blocker from the reason map main removed the draft-prompt blocker in stablyai#19681 (a structured session now holds an unsent draft), so the exhaustive Record no longer typechecks. * chore(agent-launch): carry a SAFETY rationale on the agent placement cast The type-assertion gate landed after this branch's base, so the new file's copy of the worker-start cast is now a changed-code finding. * docs(agent-launch): stop the receipt-wording comment claiming a migration The decision was never moved out of orchestration-worker-start-mode; this PR adds a second copy beside it. Say so, and name the unenforced agreement. --------- Co-authored-by: Merge Sim <sim@local>

ELI5
There is one question — "should this agent open as a chat, or as a terminal?" — and the code that answers it lives inside orchestration's folder, speaking orchestration's words, where other parts of the app cannot use it. This PR writes a neutral home for that question so everyone can eventually ask it. Orchestration is not moved onto it here: its copy stays exactly where it is, so for now the same policy exists in two places.
Stack: 1 of 5. This PR alone changes no behavior.
What Changed
Two files, both purely added. Nothing is moved, deleted, or rewritten.
src/main/agent-launch/agent-launch-mode.ts(+248) — the decision in surface-neutral form, with the receipt noun parameterized so a phone does not read "worker". It has no callers in this PR.orchestration-worker-start-receipt-wording.test.ts(+140), pinning the exact receipt sentences oforchestration-worker-start-mode.ts.src/main/runtime/rpc/methods/orchestration-worker-start-mode.tsis untouched — byte-identical tomain(blob92dc5c644a89, 217 lines). It does not shrink, does not become an adapter, and re-exports nothing.Two copies exist as of this PR
This is the honest state a reviewer should merge with, not a migration:
WorkerStartMode↔AgentLaunchMode,WorkerStartModeReceipt↔AgentLaunchModeReceipt,decideWorkerStartMode↔decideAgentLaunchMode,downgradeWorkerStartModeForHost↔downgradeAgentLaunchModeForHost,readWorkerStartModeSettings↔readAgentLaunchModeSettings— with identical ten-member reason vocabularies in the same order.agent-launch/, and nothing enforces that the two agree. A reason added to one can silently diverge from the other.agent-launch-mode.tshas no test and no importer in this PR.The cutover — orchestration reduced to a thin adapter over the shared module — is later stack work (PRs 4–5, which do not exist yet). Do not merge this believing orchestration is already migrated.
Why
A worker is not a special kind of launch — it is the same launch with a dispatch attached. The only thing orchestration genuinely contributes to this decision is the noun in the receipt ("worker") and the
--terminalwording, which reads as nonsense on a surface where no--terminalflag exists. That is why the neutral module parameterizes the vocabulary: so the later cutover can keep orchestration's wording without keeping orchestration's copy of the policy.This is groundwork for the rest of the stack, where mobile and the CLI ask the same question instead of each routing for themselves.
Why the new test
The receipt wording was not pinned by anything. The vocabulary was corrupted deliberately and all six candidate suites stayed green:
orchestration-worker-start-mode.test.tsassertstoContain('terminal agent')— the corrupted string'ABLATION terminal agent worker'still contains it.orchestration-worker-cli.test.tsasserts the full sentence, but against a receipt handed to it by a mock rather than one this code produced.A dispatch receipt is the only place a structured-to-terminal downgrade explains itself, so the whole sentence is the contract, not a fragment of it.
Linked Issue
Fixes #
Visual Proof
N/A— no UI and no behavior change. Both files are additions and neither is reachable from a running surface: the new module has no callers, and the new test only asserts sentences orchestration already produced.Testing
Verified at head
1dd74f6309:orchestration-worker-start-mode.ts. Because that module is unchanged by this PR, the pin is a characterization test of existing behavior — it locks today's sentences rather than proving a migration preserved them.pnpm tcclean;oxlintclean; changed-code quality gate 0 findings across all six scans.Not re-verified at this head, and carried over from the original authoring: the claim that ablating the vocabulary reddens 9 of 11, and the "81 tests across 6 files" affected-set count.
Platforms: macOS. No platform-dependent code paths touched.
AI Disclosure
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 surface. Cross-platform: no platform-dependent paths. Remote SSH: the
remote_execution_hostdowngrade reason and its wording are preserved exactly. Mobile: untouched by this PR. Backwards compatibility: no wire change, no capability change, no RPC change. Performance: neutral.Duplication is the known cost of this step and is intentional for reviewability; it is discharged by PRs 4–5, not by this one.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)