Skip to content

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

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

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

Conversation

@trs-80

@trs-80 trs-80 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

ELI5

orca orchestration worker-start now launches the user's default agent (from Settings) when the coordinator doesn't pass --agent.

What Changed

  • worker-start without --agent resolves to defaultTuiAgent when that agent is enabled (OrcaRuntimeService.resolveDefaultOrchestrationAgent). An explicit --agent still wins; a missing, blank, or disabled default still fails with agent_unconfigured — the default is never silently swapped for another agent. --terminal reuse is unchanged.
  • The client-side federated pre-check only rejects an explicit unknown --agent; an omitted one is resolved by the worker host against its own Settings.
  • Orchestration skill guide: "omit --agent to use the user's default; pass it only when a specific agent is called for", with examples; bundled guide regenerated.
  • Unit tests for fallback, explicit override, no usable default, and --terminal reuse.

Why

Workers only ever took the agent from an explicit --agent, and the guide's examples showed claude/codex, so coordinators always dispatched Claude regardless of the user's default agent (observed in dispatch receipts: requested.agent: "claude" on every worker). The orchestration path now follows the same default the new-workspace picker uses.

Linked Issue

Fixes #

Visual Proof

N/A — CLI/RPC behavior only. Receipt before: launch.requested.agent: "claude" with no --agent possible; after: omitted --agent → launch.requested.agent equals the Settings default.

Testing

macOS (Darwin 25.5.0):

  • pnpm vitest run src/main/runtime/rpc/methods src/main/runtime/orchestration src/cli → 2355 passed.

  • Live: Settings default = IBM Bob; orca orchestration worker-start --task <id> --worktree current --json (no --agent) → launch.effective.agent: "bob", worker succeeded, worker_done received by the coordinator.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Claude (Fable 5) via Claude Code assisted with analysis, implementation and testing; reviewed and run locally by the author.

Review

Agent skill upstream boundary

N/A

@coderabbitai

coderabbitai Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: d1df8a41-5b59-4383-bbf4-4ebb3928a81e

📥 Commits

Reviewing files that changed from the base of the PR and between 12be5ae and e9c1e7a.

📒 Files selected for processing (6)
  • skill-guides/orchestration.md
  • src/cli/bundled-skill-guides.ts
  • src/cli/specs/orchestration-worker-specs.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-validation.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-validation.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/main/runtime/rpc/methods/orchestration-worker-start-validation.test.ts
  • skill-guides/orchestration.md
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-validation.ts
  • 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.


📝 Walkthrough

Walkthrough

Orchestration worker starts now accept an omitted --agent and use the enabled Settings default. Explicit agents remain supported and take precedence. Invalid, unavailable, or unconfigured agents produce configuration errors. Terminal reuse skips agent resolution. The runtime provides the default-agent lookup, validation tests cover the resolution paths, and the orchestration guide documents default, explicit, and unavailable-agent behavior.

Merge Risk: 🟡 Moderate · up to e9c1e

This change makes omitted --agent use the configured default, but current validation still has bounded correctness risks: some invalid explicit values may be accepted as the default, terminal reuse may accept an empty value, and the unavailable-default error contract is not fully protected by tests. Merge should wait for these cases to be corrected or explicitly accepted by the owner.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change, rationale, testing, and AI disclosure. However, the required Linked Issue is empty, and the required Checklist section is missing. Add the issue reference after "Fixes #" and complete the template Checklist, including the required validation items.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 3 files. (2 skipped: 1 … 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 main change: using the Settings default agent when worker-start omits --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 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 3 files. (2 skipped: 1 unsupported, 1 too large.)


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

Comment @coderabbitai help to get the list of available commands.

@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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/runtime/rpc/methods/orchestration-worker-start-validation.ts (1)

145-177: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Reject an invalid explicit agent before default resolution.

Line 147 uses the Settings default when args.agent is present but invalid. Local worker-start --agent unknown can then launch the default agent. Federated worker-start rejects the same input at lines 45-48.

Only resolve the default when the caller omitted --agent.

Proposed fix
+  const explicitAgent = parseTuiAgent(args.agent)
+  if (!args.terminal && args.agent && !explicitAgent) {
+    throw new OrchestrationError('agent_unconfigured', args.missingAgentMessage)
+  }
   const agent = args.terminal
     ? undefined
-    : (parseTuiAgent(args.agent) ?? resolveDefaultWorkerAgent(args.runtime))
+    : (explicitAgent ?? resolveDefaultWorkerAgent(args.runtime))

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3c84513f-3622-4443-81b1-85a9992a948c

📥 Commits

Reviewing files that changed from the base of the PR and between 6b51ef4 and a82fc1f2f0fe17d380e4c7c61fe90d3ca4496fda.

📒 Files selected for processing (5)
  • skill-guides/orchestration.md
  • src/cli/bundled-skill-guides.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-validation.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-validation.ts

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

@trs-80

trs-80 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

CodeRabbit feedback addressed

  1. bob is not a TuiAgent on main — correct; it arrives with feat: add IBM Bob agent support (Bob Shell 2.x) #14895. The tests now use gemini and type the fake runtime's parameters as TuiAgent, and the guide examples/list no longer mention Bob (the Bob PR re-adds it where it belongs).
  2. Terminal reuse must not consult the default resolver — the resolver is now a vi.fn() and the --terminal test asserts it is never called.

@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: Pro Plus

Run ID: f42edca4-8ea0-40ee-9780-d7586ca5e285

📥 Commits

Reviewing files that changed from the base of the PR and between a82fc1f2f0fe17d380e4c7c61fe90d3ca4496fda and 1f6d6dd772e72454c00aada966a2250ea5757d91.

📒 Files selected for processing (3)
  • skill-guides/orchestration.md
  • src/cli/bundled-skill-guides.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-validation.test.ts

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

@trs-80

trs-80 commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Follow-up from an internal audit (174f9da8aa):

  • A mistyped --agent (e.g. codx) now fails with agent_unconfigured: Unknown --agent "codx" instead of silently falling back to the Settings default — restores main's behavior for unknown ids; test added.
  • orca orchestration worker-start --help usage now shows [--agent <agent> | --terminal <handle>] and the retry hint (CLI spec + guide) no longer says --agent must be repeated.

@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: Pro Plus

Run ID: 6a843c7f-c2c0-4c88-9575-2b4be29d7337

📥 Commits

Reviewing files that changed from the base of the PR and between 1f6d6dd772e72454c00aada966a2250ea5757d91 and 174f9da8aa114840957f58eff015e8571da9103e.

📒 Files selected for processing (5)
  • skill-guides/orchestration.md
  • src/cli/bundled-skill-guides.ts
  • src/cli/specs/orchestration-worker-specs.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-validation.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-validation.ts

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

@trs-80

trs-80 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

Addressed (af4b696d66): an explicit empty --agent "" is now rejected as unknown rather than treated as omitted — the check is args.agent !== undefined, and the test covers both codx and "".

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/runtime/rpc/methods/orchestration-worker-start-validation.ts (1)

145-152: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Reject an explicit empty agent in terminal mode.

resolveWorkerStartAgent skips validation when args.terminal is set. The caller also checks params.agent by truthiness, so --terminal --agent "" reaches this terminal branch and succeeds. This silently ignores an explicit invalid agent.

Check explicit-agent presence with !== undefined before the terminal branch, or reject the combination in the worker-start validator.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a4ec9324-3228-4cc0-a59f-c527eafa294f

📥 Commits

Reviewing files that changed from the base of the PR and between 174f9da8aa114840957f58eff015e8571da9103e and af4b696d66f40ff423fe7584baa7a2bd19a3ddbc.

📒 Files selected for processing (2)
  • src/main/runtime/rpc/methods/orchestration-worker-start-validation.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-validation.ts

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

trs-80 and others added 5 commits August 31, 2026 22:14
Workers only take the agent from an explicit --agent flag; the guide's
examples showed claude/codex only, so coordinators never dispatched Bob.

Co-Authored-By: Claude Fable 5 <[email protected]>
…ault agent

Coordinators had to name an agent on every worker-start and the guide
only showed claude/codex, so the user's default agent was never used.
An omitted --agent now resolves to the enabled Settings default; an
explicit --agent still wins and a missing/disabled default still fails
with agent_unconfigured.

Co-Authored-By: Claude Fable 5 <[email protected]>
…agents

Type the fake runtime with TuiAgent, assert terminal reuse never consults
the default resolver, and drop IBM Bob from the guide examples until that
agent lands.

Co-Authored-By: Claude Fable 5 <[email protected]>
…e default

Only an omitted --agent falls back to the Settings default; an unknown id
fails as before. CLI usage and retry guidance now describe --agent as
optional.

Co-Authored-By: Claude Fable 5 <[email protected]>
@trs-80
trs-80 force-pushed the feat/orchestration-default-worker-agent branch from af4b696 to e9c1e7a Compare September 1, 2026 02:16
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@greptile-apps

greptile-apps Bot commented Sep 1, 2026

Copy link
Copy Markdown

Greptile Summary

The PR makes supervised worker creation resolve an omitted --agent from the worker host’s enabled Settings default while preserving explicit-agent and terminal-reuse behavior.

  • Adds host-side default-agent resolution for local and federated worker starts.
  • Relaxes the federated pre-check so the remote host can resolve an omitted agent.
  • Updates CLI guidance and bundled orchestration documentation.
  • Adds focused tests for fallback, override, invalid defaults, and terminal reuse.

Confidence Score: 4/5

The explicit empty-agent path should be fixed before merging because it can silently launch the Settings default instead of rejecting the caller’s invalid selection.

The new fallback is sound for genuinely omitted values, but existing CLI and RPC normalization collapses an explicitly empty agent into the same undefined representation, defeating the changed resolver’s intended invalid-input check.

Files Needing Attention: src/main/runtime/rpc/methods/orchestration-worker-start-validation.ts, src/main/runtime/rpc/methods/orchestration-worker-start-validation.test.ts

Important Files Changed

Filename Overview
src/main/runtime/rpc/methods/orchestration-worker-start-validation.ts Adds default-agent fallback, but parser-normalized empty explicit values become indistinguishable from omission and can launch the default agent.
src/main/runtime/orca-runtime.ts Adds a Settings-backed resolver that returns only recognized, enabled default agents.
src/main/runtime/rpc/methods/orchestration-worker-start-validation.test.ts Covers core resolution behavior, although its empty-string case bypasses the real CLI and RPC normalization path.
src/cli/specs/orchestration-worker-specs.ts Updates worker-start usage and retry guidance to describe the optional agent and Settings fallback.
skill-guides/orchestration.md Revises orchestration examples and guidance to prefer the user’s default agent.
src/cli/bundled-skill-guides.ts Regenerates the bundled orchestration guide from the updated source documentation.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    CLI[worker-start request] --> A{terminal supplied?}
    A -->|Yes| R[Reuse existing terminal]
    A -->|No| B{agent present?}
    B -->|Valid explicit ID| V[Validate enabled launcher]
    B -->|Omitted| D[Resolve worker-host Settings default]
    B -->|Invalid explicit ID| E[agent_unconfigured]
    D --> C{Default recognized and enabled?}
    C -->|Yes| V
    C -->|No| E
    V --> L[Create supervised worker]
Loading

Reviews (1): Last reviewed commit: "fix(orchestration): treat an empty --age..." | Re-trigger Greptile

Comment on lines +150 to +152
const agent = args.terminal
? undefined
: (parseTuiAgent(args.agent) ?? resolveDefaultWorkerAgent(args.runtime))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Empty agent triggers fallback

When a caller explicitly supplies an empty --agent, CLI and RPC normalization convert it to undefined, so this resolver launches the Settings default instead of rejecting the invalid selection with agent_unconfigured.

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 f18956a. The leak was CLI-side, as you said: getOptionalStringFlag collapses --agent "" (and bare --agent) to undefined before the resolver's !== undefined guard could see it. The handler now rejects an explicitly empty or valueless --agent (and --terminal) with invalid_argument at the CLI boundary — matching main's failure on the same input. The RPC path was already covered: the schema's .min(1) rejects an empty string rather than converting it.

…oundary

getOptionalStringFlag collapses --agent "" and bare --agent to undefined, so
the resolver's explicit-empty guard never saw them and worker-start launched
the Settings default. Reject them (and --terminal "") in the handler with a
clear invalid_argument error, matching main's failure on the same input. The
validation tests now also pin the agent_unconfigured error code.

Co-Authored-By: Claude Fable 5 <[email protected]>
@trs-80

trs-80 commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

Closing as part of consolidating the IBM Bob stack into a single PR, #20397.

To be clear about the record: this change is not superseded and is not included in #20397. It only shared a branch base with the Bob work; the content — defaulting worker-start --agent to the Settings default agent, plus the --agent validation fixes (empty, valueless, and mistyped values rejected at the CLI boundary rather than silently launching the default) — is unrelated to Bob and remains unmerged.

Closed to unstack, not because it was rejected. The 6 commits are intact on feat/orchestration-default-worker-agent and can be reopened or resubmitted standalone against current main.

@trs-80

trs-80 commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

Resubmitted standalone against current main as #20401 — rebased off the Bob branch, Bob references removed, squashed to a single commit.

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