Skip to content

feat(orchestration): default worker-start --agent to the Settings default agent - #20401

Open
trs-80 wants to merge 7 commits into
stablyai:mainfrom
trs-80:feat/orchestration-default-agent
Open

trs-80 wants to merge 7 commits into
stablyai:mainfrom
trs-80:feat/orchestration-default-agent

Conversation

@trs-80

@trs-80 trs-80 commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Resubmits #15935 standalone against current main. That PR was stacked on the IBM Bob branch and got closed when the Bob work was consolidated into #20397 — but this change is unrelated to Bob and was never superseded. It is now rebased onto main with every Bob reference removed, as a single commit.

What changes

worker-start required an explicit --agent whenever it created a terminal, even though Settings already holds the user's default agent and the new-workspace picker honours it. Omitting --agent now resolves that default on the worker host, matching how --model and --effort already inherit the user's configuration.

# before — the flag was mandatory
ORCA orchestration worker-start --spec "<task>" --worktree current --agent codex --json

# now — omit it and the worker launches the Settings default
ORCA orchestration worker-start --spec "<task>" --worktree current --json

Resolution is deliberately strict

The point of a default is convenience, not guessing, so nothing silently substitutes an agent the caller did not ask for:

  • An explicit --agent must be a known agent id. A mistyped one is rejected, not quietly replaced by the default — that was the failure mode worth closing.
  • An empty or valueless --agent counts as explicit-but-invalid rather than omitted, and is rejected at the CLI boundary before any RPC is sent.
  • A disabled default agent is never swapped for a different one.
  • No usable default fails with agent_unconfigured. That is also what an older worker host returns when it cannot resolve one, so version skew surfaces as an explicit, recoverable error instead of a silent substitution.

Docs placement

The always-loaded orchestration kernel sits exactly at its 202-line budget (config/scripts/orchestration-skill-guidance.test.mjs enforces it, since that guide is in context for every orchestration turn). So the kernel carries only the example — worker A now omits the flag, which demonstrates the behaviour at zero line cost — and the detail lives in references/coordinator-loop.md next to the --model/--effort rules it mirrors. The agent_unconfigured recovery path is documented in references/recovery-and-cleanup.md.

Verification

  • pnpm tc clean across node, cli, and web.
  • Full unit suite: 79,379 passing. The 7 remaining failures were confirmed against a pristine origin/main worktree and fail identically there — developer-env ANTHROPIC_API_KEY, a real Claude CLI, and network-dependent cross-version-wire specs. Nothing fails because of this branch.
  • pnpm run check:code-quality:changed: 0 new findings across 8 changed files.
  • 1010 tests pass across the touched areas (src/cli/flags, the orchestration RPC methods, the CLI orchestration handlers, and the skill-guide generators), including new coverage for each rejection case above.

🤖 Generated with Claude Code

@pullfrog pullfrog 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.

ℹ️ Minor suggestions only. The resolution logic is correct on both the local and federated paths, and the version-skew story (agent_unconfigured is already a known remote-start failure) holds up.

Reviewed changes

  • Strict default resolution — resolveWorkerStartAgent now treats only an omitted --agent as "use the Settings default"; a non-empty unknown id throws Unknown --agent "<id>", and a resolved default must be a known, enabled TUI agent. Shared by the local and federated attachment entry points.
  • Default resolver on the runtime — new resolveDefaultOrchestrationAgent() returns settings.defaultTuiAgent when it is a valid, enabled agent, else null; a disabled default is not swapped.
  • CLI empty-value guard — getOptionalStringFlagRejectingEmpty rejects --agent "" / --agent (valueless) as invalid_argument before any RPC; applied to --agent and --terminal.
  • Spec and guide updates — usage changes (--agent | --terminal) to [--agent | --terminal], the retry note reflects the default, and the kernel example omits the flag at zero line cost.

ℹ️ Nitpicks

  • references/coordinator-loop.md lists an empty --agent among the cases that "fail with agent_unconfigured", but the CLI rejects --agent "" earlier as invalid_argument (getOptionalStringFlagRejectingEmpty). Only a direct RPC call with an empty string reaches the agent_unconfigured path, so dropping it from that sentence (or scoping the sentence to the runtime) would keep the guide honest.
  • The new test's fakeRuntime re-implements the default-resolution semantics, so the production resolver in orca-runtime-get-terminal-interactive-wait.ts:197 is never exercised directly. validateOrchestrationAgentLauncher still refuses a disabled id at runtime, so this is a coverage nit rather than a live gap.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The worker-start command now permits omitted agent and terminal flags. Omitted agents resolve from the enabled Settings default, while explicit invalid or empty values fail. Terminal reuse does not perform default-agent lookup. CLI tests and worker-start validation tests cover these paths. Orchestration guides and retry examples now describe the default-agent behavior and explicit placement options.

Merge Risk: Minimal · previous review 54f56

Federated worker starts resolve an omitted agent using the destination host’s Settings, consistent with the documented behavior. No identified issue blocks merging.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description clearly explains the user-facing change, strict resolution rules, implementation scope, and verification results. However, it does not follow the repository template: it omits the requ… Add the missing template sections. Include a valid issue reference after 'Fixes #', state 'N/A' with a reason for Visual Proof if no visual or interaction change exists, complete the Testing checklist, and address the Review, Agent skill up…
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 8 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)

Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: making the worker-start --agent flag use the Settings default agent when omitted.
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: Description check

Explanation

The description clearly explains the user-facing change, strict resolution rules, implementation scope, and verification results. However, it does not follow the repository template: it omits the required Linked Issue entry, Visual Proof or an explicit N/A statement, the Testing checklist, Review section, Agent skill upstream boundary section, Notes, and the final Checklist.

Resolution

Add the missing template sections. Include a valid issue reference after 'Fixes #', state 'N/A' with a reason for Visual Proof if no visual or interaction change exists, complete the Testing checklist, and address the Review, Agent skill upstream boundary, Notes, and Checklist sections.

Full details: Docstring Coverage

Explanation

Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 8 files. (1 skipped: 1 unsupported.)

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
ℹ️ Recent review info

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 29adce3f-24ac-425e-a17f-ee8b221c44fc

📥 Commits

Reviewing files that changed from the base of the PR and between d2e10350e0f14e3a4ec05b53adf25c869c916835 and 54f56b9f6294fbfc3e614b58e1d7af9ff884bad4.

📒 Files selected for processing (3)

  • skill-guides/orchestration/references/coordinator-loop.md
  • src/cli/bundled-skill-guides.ts
  • src/cli/specs/orchestration-worker-specs.ts
🚧 Files skipped from review as they are similar to previous changes (1)

  • src/cli/specs/orchestration-worker-specs.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@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

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: adeae118-ca47-4a50-9083-b4a05020b090

📥 Commits

Reviewing files that changed from the base of the PR and between 403b62a and 35dab25a48fd8ec506c63d2922e48a87965fd167.

📒 Files selected for processing (11)
  • skill-guides/orchestration.md
  • skill-guides/orchestration/references/coordinator-loop.md
  • skill-guides/orchestration/references/recovery-and-cleanup.md
  • src/cli/bundled-skill-guides.ts
  • src/cli/flags.test.ts
  • src/cli/flags.ts
  • src/cli/handlers/orchestration/worker-launch-handler.ts
  • src/cli/specs/orchestration-worker-specs.ts
  • src/main/runtime/orca-runtime-get-terminal-interactive-wait.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-start-validation.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-start-validation.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Named the unknown --agent on the remote path — validateFederatedWorkerStartPlacement now throws Unknown --agent "<id>", matching the local refusal instead of the generic "an agent is required" message, which resolves the one open thread from the prior review.
  • Corrected the coordinator guide — an omitted --agent resolves against the worker host's Settings default (not the caller's); a named agent that is unknown or disabled fails with agent_unconfigured, and an empty --agent is rejected at the CLI with invalid_argument. The bundled skill guide is regenerated in sync.
  • Reworked the resolution tests — driven through the real resolveDefaultOrchestrationAgent and validateOrchestrationAgentLauncher prototype methods rather than a re-implementation, with new coverage for the remote unknown-agent refusal and a Settings-disabled explicit agent.

I verified the touched tests locally: worker-start-validation.test.ts (7 passed), flags.test.ts (2), orchestration-skill-guidance.test.mjs (29), and generate-bundled-skill-guides.mjs --check (clean).

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@trs-80

trs-80 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review in b94855f5e1 (both inline threads answered). Pullfrog nitpicks:

  • Empty --agent listed under agent_unconfigured: fixed. coordinator-loop.md now lists only an omitted --agent with no enabled default, an unknown or disabled named agent, and a host too old to resolve a default under agent_unconfigured, and notes that the CLI rejects an empty --agent earlier with invalid_argument.
  • Test re-implemented the default resolution: fixed. The fake runtime now calls the real resolveDefaultOrchestrationAgent and validateOrchestrationAgentLauncher from OrcaRuntimeWithGetTerminalInteractiveWait on a stub Settings store, so the production resolver is exercised directly. Added a case for an explicit --agent that Settings disables.

Verification: 373 tests across the orchestration worker, CLI flags, and skills suites pass; pnpm tc passes; verify:bundled-skill-guides passes; changed-code quality gate reports 0 new findings.

@trs-80
trs-80 force-pushed the feat/orchestration-default-agent branch 2 times, most recently from d2e1035 to 54f56b9 Compare September 24, 2026 11:53
@trs-80
trs-80 force-pushed the feat/orchestration-default-agent branch from 54f56b9 to b05987e Compare October 1, 2026 20:52
@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Medium risk] Changes how worker-start picks an agent when none is named.

The PR appears safe to merge, with a non-blocking federated worker-observation discrepancy to address.

Findings

  1. P2 Federated worker agent goes unrecorded ▶

Summary

This PR lets worker-start use the worker host’s enabled Settings default when --agent is omitted.

  • Explicit unknown, empty, or disabled agents remain errors, and the CLI help and orchestration guides describe the new behavior.
  • Federated starts need to persist the agent resolved by the worker host so later observations reflect the launched worker.
Diagram
sequenceDiagram
  participant CLI
  participant Home as Run home
  participant Host as Worker host
  CLI->>Home: worker-start without --agent
  Home->>Host: federationAttachStart(agent omitted)
  Host->>Host: Resolve enabled Settings default
  Host-->>Home: Ready receipt with resolved agent
  Home-->>CLI: Ready receipt
  Note over Home: Persisted start options still say agent=null
Loading

Reviews (1) · Last reviewed commit: "test(orchestration): annotate the worker..."

Comment on lines +43 to +45
// Why: an explicit --agent must be a known id; an omitted one is resolved by the
// worker host against its own Settings default.
if (!params.terminal && params.agent && !isTuiAgent(params.agent)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Federated worker agent goes unrecorded

When a federated start omits --agent, the worker host launches its Settings default, but the Run home saves agent: null and a pending launch receipt. The ready response includes the resolved agent, yet worker-show reads the saved values, so it cannot show which agent actually ran. Persist the worker host’s resolved agent and launch selection on the home dispatch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 324d8975d0. When the worker host reports the launch it resolved, the home now writes that receipt into the Dispatch's start options, and its agent when it is a known agent id (the receipt crosses the federation boundary unvalidated, so an unknown id is ignored). worker-show then names the agent that actually ran. An older host that sends no launch receipt leaves the start options unchanged. Tests: federated-worker-start-receipt.test.ts (records the host-resolved agent; ignores an unknown one). The first fails without the fix.

@trs-80
trs-80 force-pushed the feat/orchestration-default-agent branch from b05987e to df05bfa Compare October 2, 2026 11:27

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

This run re-reviewed the delta since the last Pullfrog review: the branch now records the agent a federated worker host resolved. The prior head (b05987e) is not an ancestor, so the change was isolated by tree-diffing the PR files; the delta is three files (PR grew 11 → 14).

  • Federated launch persisted — startFederatedWorker now calls a new recordWorkerStartLaunch when the remote receipt carries a launch, writing the host-resolved effective.agent and the receipt into the home dispatch's start_options, so observations show the agent that actually ran.
  • Unknown host agent not trusted — only a launch.effective.agent that is a known TUI id is written; otherwise the saved agent is left untouched (the raw receipt is still stored under launch).
  • recordWorkerStartLaunch DB mutator — JSON-merges agent/launch into start_options with a dispatch_not_found guard; exposed via WorkerDispatchStageMethods.
  • Coverage — federated-worker-start-receipt.test.ts drives the real startFederatedWorker path for both a known and an unknown host-resolved agent.

I verified the touched tests locally (federated-worker-start-receipt.test.ts + worker-start-validation.test.ts, 10 passed), orchestration-skill-guidance.test.mjs (29), pnpm tc:node, and generate-bundled-skill-guides.mjs --check.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@trs-80
trs-80 force-pushed the feat/orchestration-default-agent branch from df05bfa to 3602195 Compare October 5, 2026 10:03
@trs-80

trs-80 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@greptile-apps review

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

This run re-reviewed the delta since the last Pullfrog review: the branch now accepts Settings-configured command aliases for an explicit --agent and scopes default resolution to the worker host. The delta is docs + tests only — no production source changed — and the tests pass locally (13 across the three touched files).

  • Alias behavior documented — references/coordinator-loop.md now states a named --agent may be an agent id or a command alias configured on the worker host, and separates the empty---agent case (invalid_argument at the CLI) from agent_unconfigured, which also resolves the prior review's nitpick.
  • Remote passthrough test — the remote-path test that expected a local rejection of an unknown --agent is replaced by one asserting a non-id name is forwarded for the worker host to resolve; a new local test asserts a configured alias resolves instead of the Settings default.
  • Generated skill guide regenerated — src/cli/bundled-skill-guides.ts is in sync with the edited reference.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@trs-80
trs-80 force-pushed the feat/orchestration-default-agent branch from 3602195 to ceecf8b Compare October 8, 2026 12:28
@trs-80
trs-80 force-pushed the feat/orchestration-default-agent branch 3 times, most recently from 848aee3 to 5933998 Compare October 15, 2026 12:50
trs-80 and others added 7 commits November 9, 2026 12:56
…ault agent

`worker-start` required an explicit `--agent` whenever it created a terminal,
even though Settings already holds the user's default agent and the
new-workspace picker honours it. Omitting `--agent` now resolves that default on
the worker host, matching how `--model` and `--effort` already inherit.

Resolution is deliberately strict, so a typo can never silently launch something
the caller did not ask for:

- An explicit `--agent` must be a known agent id. A mistyped one is rejected
  rather than falling through to the default.
- An empty or valueless `--agent` counts as explicit-but-invalid, not omitted,
  and is rejected at the CLI boundary before an RPC is sent.
- A disabled default agent is never swapped for another one.
- No usable default fails with `agent_unconfigured`, which is also what an older
  worker host returns when it cannot resolve one — an explicit, recoverable
  failure rather than a silent substitution.

The always-loaded kernel is at its 202-line budget, so it carries only the
example (worker A now omits the flag) and the detail lives in
`references/coordinator-loop.md` beside the `--model`/`--effort` rules it
mirrors.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ault to the worker host

- Remote worker-start refuses an unknown --agent with the same
  `Unknown --agent "<id>"` message as the local path.
- Coordinator guide: an omitted --agent uses the worker host's Settings
  default; the CLI rejects an empty --agent as invalid_argument.
- Tests drive the real runtime default resolver and launcher validator.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…or the casting gate

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…erated start

A federated worker-start with no --agent is resolved against the worker host's
Settings default, but the Run home saved agent: null and a pending launch
receipt, so worker-show could not say which agent ran. The home now writes the
host's launch receipt, and its agent when it is a known id, back into the
Dispatch's start options.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ettings default

Main now resolves an explicit --agent that names a command alias configured in
Settings (stablyai#24648). Keep that, and keep this branch's rule that only an omitted
--agent falls back to the Settings default:

- An explicit --agent resolves as an agent id or a configured alias; anything
  else, including an empty name, fails by name instead of launching the default.
- A remote start no longer rejects a non-id name on the home side, since only
  the worker host knows its aliases; the host validates it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ime module

Main (stablyai#27602) moved orca-runtime-get-terminal-interactive-wait.ts under
runtime/terminal/wait/; the validation test's import follows it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…unch settings

Main now records the worker host's launch receipt into the Dispatch
(recordWorkerLaunchObservation) and leaves the saved --agent selector untouched,
so the branch's own recordWorkerStartLaunch is redundant: drop it and keep a
regression test that a federated start with no --agent shows the host's agent.

Resolve the Settings default through runtime.getClientAgentLaunchSettings() and
a shared resolveEnabledDefaultTuiAgent instead of a new runtime method, and use
main's getPresentStringFlag for the empty --agent check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trs-80
trs-80 force-pushed the feat/orchestration-default-agent branch from 5933998 to 44da0fb Compare November 9, 2026 18:38

This branch has not been deployed

No deployments
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