Skip to content

Orchestrator hierarchy: one orchestrator per project with sub-orchestrators per lane, switched out on a schedule #1156

Backlog

Description

@scuttletoby

Why: one orchestrator thread per project does everything: PR queue, reviews, merges, CI, issues, machine updates, owner questions. A study of 40 days of agent transcripts found orchestrator threads used 23% of all tokens (174k tokens per turn, against 98k for a review agent) and sat 64.6 h blocked on foreground sub-agents. Long sessions also get slower and compact often, and one thread is a single point of failure.

Idea: keep ONE orchestrator per project as the thread the owner talks to and sees, and give it sub-orchestrators: child agents with an orchestrator role that each own a lane (for example the PR queue, the issue backlog, CI and machines), run their own children, and report up in short summaries. Sub-orchestrators and the main one are switched out on a schedule (fresh session from generated state, e.g. daily or after about 300 turns) without losing the children they run.

Design questions:

  • Which lanes, and how a lane hands an item to another lane.
  • What state each level keeps, generated from live threads, PRs and waits (builds on G10 Orchestrator state, handoff and session hooks as a fork feature #851), and which decisions move into code (Orchestrator logic as software, not prose #870).
  • How the owner sees it: one thread per project in the UI, with lanes visible under it.
  • Switching out a level: when, how its children and waits move to the new session, and what happens if the switch stops half-way.
  • Limits: slots, usage and model per level, so the hierarchy does not cost more than it saves.

Done when: a design with options is agreed, then built as fork features: the orchestrator role for sub-agents, lane state, and scheduled switch-out.

Related: #851, #870.

🤖 Generated with Claude Code

Activity

  1. scuttletoby commented on Nov 28, 2026

    @scuttletoby
    OwnerAuthor

    Design summary: lanes under one project orchestrator

    This is a design only; no code is written yet. Three options were compared.

    What exists already

    Most of the hierarchy can be assembled from parts that are already there:

    • Upstream: nested delegate_task children that show inside their parent's view and not in thread lists; a child's result wakes its parent, not the root; approval and secret requests roll up to the listed ancestor; t3_thread_send; scheduled tasks.
    • Fork: handoff in the same thread (the thread id, children, waits and watched PRs are kept), the threadRoles orchestrator pointer, wait_for, delegated results with reminders, agent slots, usage pacing, the slot filler route, lens_start, MCP profiles, stopping finished children, run records.

    Missing: a role for a long-lived child, a lane concept, a claim on a PR or issue, switch-out by turns or age, and a lane view for the owner.

    Options

    A: by convention B: server lanes + agents C: lane programs
    What it is Long-lived children with a "you run the PR queue" brief and hand-kept state files The server holds the lane registry, claims, state and reports; a lane thread is an ordinary delegated child that decides only what needs judgement Each lane is a tested program that starts a short agent for single judgement steps
    Server code none small, in fork files large, per lane
    Two lanes on one PR not prevented refused by the claim store refused by the claim store
    A lane dies half-way found by hand noticed by a watchdog, replaced from state on disk a service restart
    Token cost lane contexts plus a main turn per report lane contexts; main turns only for escalations lowest
    Time to first value days 2-3 weeks of small PRs months

    Recommendation: B, built so a lane can move to C step by step

    • Lanes are defined in settings (off by default, person-only): pr-queue and issues first, ops and temporary campaign lanes later. No lane per machine by default, because placement rules already decide where work runs. Two levels only: main, lanes, workers.
    • One owner per item. An item (pr:<repo>#<n>, issue:<repo>#<n>) is claimed by one lane. A second claim is refused, and lens_start and the slot filler refuse a caller that is not the owner. Each lane thread has a generation number, so a replaced thread can no longer act as the lane.
    • Workers wake the lane, not the main orchestrator. A lane's workers have the lane thread as parent. The main orchestrator reads a short board when it needs to, and is woken only by escalations (delivered at least once, joined into one message).
    • Switch-out is the existing same-thread handoff with two new triggers (turn count, age) and a new notes source: the lane's state file, read live by the server. The agent does not have to write its own handoff. A new thread is started only when the old one is dead, in journaled steps that are safe to repeat.
    • The owner sees one row per project, with a small row per lane under it and a Lanes panel in the main thread. Requests from any depth flag the main row.
    • A lane gets a driver: agent now, program later. The stores and the board are the same for both, so routine steps can move into code (direction C, and Orchestrator logic as software, not prose #870) without changing what the owner sees.

    Failure cases

    Case What happens
    A lane thread dies half-way Its claims, notes, waits and children are on disk or live in T3. It is replaced from that state, and results owed by its running workers are forwarded.
    Two lanes claim the same PR The second claim is refused, and tools that act on the item refuse a non-owner.
    The main orchestrator is restarted Same thread, fresh session, the board in its handoff. Lanes belong to the project, not to a thread id.
    Usage runs out Lanes pause and say so once. Events wait in queues and nothing is downgraded.
    A lane store cannot be read It counts as unknown, not empty: claims and starts are refused until it reads again.

    Phased plan (small PRs, each with its tests and its state question)

    1. A trial by convention with one lane, plus a lane field in run records, to measure first.
    2. Settings and contracts.
    3. Lane stores: registry, claims, outbox, notes.
    4. lane_start, lane_stop, lane_board and a lanes tool group.
    5. Claims and handover, with the owner check in lens_start and the slot filler route.
    6. Reports up: lane_note, lane_escalate, joined delivery.
    7. Switch-out: turn and age triggers, the lane-state handoff source.
    8. Health and replacement: watchdog and lane_replace, report-only first.
    9. The owner's view: lane rows and the Lanes panel (can be built in parallel once 3 is merged).
    10. Rules and limits: owns rules, children per lane in the slot gate, tokens per level.
    11. Lane programs for the routine steps of pr-queue.

    The measure for the whole feature: orchestrator-level tokens per merged PR. If that number is not lower after two weeks, the setting goes off.

    Open points for the owner (recommendation first)

    1. May the orchestrator invent lanes? Recommended: no. Lanes are defined in settings, and the orchestrator switches defined lanes on and off.
    2. Replace a dead lane thread automatically? Recommended: report-only for the first week, then automatic.
    3. Which lanes first? Recommended: pr-queue and issues.

    🤖 Generated with Claude Code

  2. 21 remaining items

  3. added
    area:agents
    size:big
    type:feature
    on Nov 29, 2026
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

    area:agentssize:bigtype:feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions