Skip to content

Race one task across agents in parallel worktrees and pick the best result #112

Description

@titan-ron

Idea

Run one task prompt in parallel across 2–4 lanes, each in its own isolated worktree, where a lane is an agent (Claude, Codex or Copilot, providers may repeat with different models or accounts). Then compare the lanes' results side by side and pick one to ship.

"Race" is a working name; the final name should fit Cockpit's vocabulary (the board, flying, on the ground).

Why it could be worth it

  • Hard or ambiguous tasks benefit from several attempts; picking the best diff beats iterating on one weak attempt.
  • Cockpit already drives three different agent CLIs and has a review panel, so the same task could run on different agents, not just different models, and their diffs could be compared in one place.

Why not now

It is the most cross-cutting of the recent features (new persisted record, IPC, a new view, entry points on home, new session, board, palette and sidebar) and it multiplies agent usage per task. Worth doing once the review panel, PR feedback and notifications have settled.

What already exists to build on

  • Isolated worktrees: createWorkspace in src/main/workspace.ts cuts a cockpit/<slug> branch per session; sessions start through startSession in App.tsx (home composer and new-session form).
  • Comparison: the review panel (ReviewPanel.tsx, main side diff.ts + diff-core.ts) shows a worktree's diff against its base, with the PR strip once a PR exists. Reuse it per lane rather than building a second diff view.
  • Multi-agent precedent: roundtables (roundtable.ts + roundtable-core.ts) persist to <userData>/roundtables/ with write-then-rename, push events, seat pickers, and appear on the home board. Unlike roundtable seats, lane sessions are real work that may ship, so they should stay ordinary, openable sessions grouped by the race record.
  • Live status: busy-session tracking already drives the board.
  • Cleanup: cleanup.ts removes worktrees safely (never --force, dirty ones refused).

Sketch of the scope

  • Start a race from the task composer and the new-session form: 2–4 lanes (agent + account + model), one repo, one prompt. Main validates everything (known repo root, provider allowlist, lane count, per-agent options).
  • One worktree and one session per lane, with distinguishable branch names.
  • Persist the race record (lanes → session, branch, provider/model; the picked lane) under userData, with the logic in an IO-free -core.ts module and unit tests.
  • A race view: per lane the agent, flying / landed / failed, elapsed time, diff stat and files; open a lane's session or its review; pick a lane, which opens that session to ship through Create PR and offers to clean up the other lanes' worktrees.
  • Find races again on the home board, in the ⌘K palette and in the sidebar.
  • Design page under design-system/cockpit/pages/, the new view in the 560×420 minimum-window audit and the UI tour, a docs/guide page.

Open questions

  • Should lanes be able to share an account, and how is the extra usage made visible before starting?
  • Pick one winner only, or allow cherry-picking files across lanes?
  • Should notifications announce "all lanes landed" rather than each lane separately?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions