LazyTools agent orchestrator

1. Goal

LazyTools turns a reviewed plan into trackable coding jobs. A lead can give work to Codex or Claude Code, leave it running while the caller moves on, and come back to job results, approval requests and evidence tied to a specific task. The dispatcher unlocks dependent tasks after acceptance. The orchestration MCP server lets an agent use the same job and review mechanisms as the CLI.

Sources · Code bridge · Projects queue · MCP design goal

2. Components and roles

Sources · Repository boundaries · Dispatcher and workers · Owner credential · LazyBridge primitives

3. Architecture

The lead drives the dispatcher and bridge. The owner configures approvals. Local and cloud engines exchange work and results with the bridge. Lead / CEO Owner CLICLI / MCP DispatcherPlace, claim and settle tasks Code bridgeRun jobs and collect evidence Approval registryPolicy, cards and tickets Projects StoreBoard and task receipts Job StoreStatus and results Local enginesCodex / Claude Code Cloud enginesCodex Cloud / Claude
Blue marks control, green marks execution, amber marks authority or a gate, and gray marks records.

Sources · MCP server · Projects and Store · Dispatch · Approval registry

4. How it works

Task graph and lifecycle

In the example graph, tests and documentation both depend on implementation. Each task moves from todo through placement, claim and launch. Accepted work unlocks dependents and may be landed on a PR. todo placed claimed launched done landed failedBlocks branch DependentsCan start Example dependencies Implement Add tests Update docs
Local writer path, with optional PR landing. Cloud dispatch lands before accepting the task.

Run the graph with lazytools-code-bridge dispatch --project ID. A task can name its repository, dependency IDs, tier, placement, acceptance criteria and check commands. Plan validation rejects duplicate IDs, missing dependencies and cycles. A todo task becomes claimable when its dependencies are accepted, its hold is clear and current placement evidence matches its revision. The claim binds the attempt, executor and route to a token and lease. Launch records a job reference. Acceptance sets the board task to done, terminal failure sets it to failed, and a retry returns it to todo.

Sources · Plan fields and dependencies · Readiness, claims and completion · Job launch

Placement, quota and capacity

Tier and quota routing choose an engine, then placement requires either a local slot or a cloud environment and capacity. Work waits if admission cannot proceed. Task tierPreference + fallback Quota routerEngine, model and effort Local engine slot Cloud environment + limit Wait for eligibility or capacity

The router walks the tier’s model ladder, uses quota headroom and prefers writers on pace to finish the weekly window within budget. Admission also checks the applicable short and weekly windows. With fallback: wait, a busy preferred engine can hold the task when the only free alternatives project above 100%. fallback: allow can use an otherwise eligible over-pace engine. Each task can inherit or override the project preference and fallback.

Dispatch runs runnable tasks within available capacity: local engine slots and cloud slots (global and per provider). With auto placement, it uses a free local slot when available and otherwise places the task in the cloud. --parallel adds an optional project-wide cap; waiting tasks report the reason they cannot proceed, such as a full slot limit, quota window, or task dependency. Cloud placement needs a mapped Codex environment or configured Claude routine. Standalone run --where auto is a separate placement flow that can also choose cloud in configured busy windows. Cloud submission requires explicit opt-in.

Sources · Weekly pace and fallback · Routing and admission · Dispatch placement · Cloud capacity · Standalone auto placement

Delegation and authority

The owner credential configures a mode and preset that issue original cards. A worker receives narrower copies scoped to the job. Owner credentialOperator CLI Mode + presetOwner selects classes Original cardsIn private registry Scoped job copiesPath, branch, network Authority can narrow at each step. It takes the owner credential to widen it.

supervised is the default. Its four delegated classes cover local Git operations, checkout checks, pushes to the job branch and PR creation. total can delegate recognized classes outside the preset’s owner-only floor. Both solo-dev and with-production reserve unknown actions and payments or external posts for the owner. with-production, the default preset, also reserves production tasks, file deletion and pushes to the default branch.

The owner configures delegation using approver-credential autonomy. MCP has no setter, and jobs receive no owner secret. Card copies are nontransferable and constrained by the job, native grants and the action’s path, branch and network. Changing mode or preset replaces the originals and invalidates their copies. Copies are revoked at completion or cancellation and expire if recovery is impossible.

Sources · Credential storage · Modes and presets · Card issuance and narrowing · Action classification and scope

Approval tickets from request to decision

A gated action uses a matching card or waits on a ticket. Events surface the ticket to the lead or owner, whose decision is recorded. Gated action Card match? YesNo Card receiptAction can proceed Pending ticketPoll or notification Lead or ownerApprove or reject Recorded outcomeExpiry also denies

When a local writer requests a gated action, a valid scoped card can approve it immediately and produce a receipt. Otherwise the bridge persists a one-use ticket with the command, reason and expiry, and the worker waits. Dispatch surfaces the ticket. The lead can use bridge_pending, cursor polling or an MCP notification to find its ID.

bridge_approve and bridge_reject decide as the CEO. Every job is treated as CEO-launched. Approval needs a delegated class backed by live owner-issued cards, or the ticket stays pending for the credentialed owner. The CEO may reject a request or cancel a job with a reason. Decisions record actor, mode, class and reason. The autonomy report counts card use by class.

The governed Projects effect queue is separate. approvals_pending lists its requests, which bind the claim and exact action digest. The host checks scope, assignee and current grant, consumes an approved effect once and records its outcome. Project cards can cover reads and local commits. Production effects go to the owner.

Sources · Bridge tickets and card receipts · CEO decisions · Autonomy report · Projects effects

Acceptance, review and PR landing

Local dispatch checks and accepts a commit before optional landing. Cloud dispatch lands a PR before checking its pushed commit. The PR workflow reviews the current head. Local commit Run task checks Publish + accept Optional PR landing Cloud result Land to PR Check pushed SHA Accept task PR head Independent review Checks + verdict Merge-ready
Dispatch checks task acceptance. The separate PR navigator verifies merge readiness.

Local dispatch uses a per-task clone and can commit completed changes when the engine cannot write Git metadata. It requires a new commit and runs configured checks against it. Checks that move HEAD or edit tracked files invalidate the evidence. Dispatch publishes the accepted branch back to the source repository. With --land it then pushes that branch and opens or updates a PR. Cloud dispatch lands first and checks the pushed SHA in a fresh local clone. The bridge applies the Codex Cloud diff locally or verifies the result branch already pushed by Claude.

For routed --review-of jobs the opposite engine is preferred. If only the writer’s CLI is installed, the bridge can use a fresh same-provider conversation and records same-provider-fresh. If the opposite engine is installed but ineligible, human review is required. The PR navigator requires an independent verdict on the current head and green checks. Landing a job means putting it on a PR. Merging goes through the repository’s separate merge gate.

Sources · Local checks and landing · Cloud landing and review comments · Reviewer selection · PR navigator

Failures, retries and crash recovery

Infrastructure failures get bounded retries, budget failures wait for quota, policy rejections stop, and persistent check failures get bounded repair and one tier escalation. Classify failure Infrastructure Budget Policy Check Retry with backoff Wait for quota Stop on rejection Rerun / repair Next tier once

Classify and verify. Dispatch backs off on transient infrastructure errors, defers quota failures until a reset or retry time, and treats a rejected ticket as a policy failure. It reruns a failed check once on the unchanged checkout and records a pass on rerun as flaky. Persistent check failures get up to two repair attempts by default, then one fresh attempt at the next tier when available. Exhaustion fails the task. A cloud check failure can enter the same repair loop locally on the landed branch. The separate PR navigator escalates P0, P1, unknown severity or the review round cap to the owner.

Recover. The dispatcher renews 180-second leases by default, even during checks or landing. The claim records dispatcher instance, host, PID and process start time. A replacement with the same executor identity can take over after proving local process exit or PID reuse, or after expiry. It adopts a known job by its durable reference or claim-derived ID and settles it against recorded evidence. When no job can be found, dispatch waits for the applicable startup grace or recovery and checks for an in-flight submission before releasing the claim. A local crash retry can preserve work on an attempt branch, resume on the same engine, or start fresh if resume is refused.

Avoid repeat failures. Dispatch holds tasks whose declared touches globs intersect active work in the same repository. The governed queue can quarantine a repository, placement and environment after repeated infrastructure failures (three by default). Clearing it requires fresh eligible preflight evidence. With --knowledge-db, dispatch adds matching lessons to briefs and records failures such as a missing job, an engine crash or a rejected ticket.

Sources · Classification, verify loop and recovery · Adoption and resume · Leases and route quarantine · Overlap matching · Owner escalation

Orchestration MCP tools and events

MCP calls use the same CLI or service. An event reader reads stored jobs and tickets and returns cursor pages or best-effort ticket notifications. MCP client CLI / shared service Jobs and tickets Events + cursor Ticket notification

lazytools-orchestration-mcp uses the same CLI or service gates. Its read tools cover fleet views, capabilities, code maps, Projects, lessons and pr_watch_poll. --allow-unsafe adds code_bridge_submit, code_bridge_status and code_bridge_result, plus ticket decisions, cancellation, reviews, sessions, project writes and lesson recording. It also adds pr_navigate, bridge_publish and bridge_apply. The data providers and synchronous coding writes are excluded. The server starts with either CLI alone and loads engines only when needed.

bridge_events(cursor, timeout_s) reads recorded jobs and tickets and returns a new cursor. An empty cursor starts from now and includes open tickets. Reusing the returned cursor picks up intervening events, with a maximum wait of 60 seconds. The feed includes approvals, done, failed, interrupted, cancelled and landed. Per-session approval notifications are best effort on the unscoped orchestration server with writes enabled. Keep polling and de-duplicate by ticket ID. Cloud completion or landing appears after another caller records it. Dispatcher and PR watcher events have their own interfaces.

Sources · Provider list and flags · Bridge adapter · Fleet tools · PR tools · Lessons · Event computation · Notifications

5. Limits and residual risks

Sources · Projects boundaries · Local risks · Cloud boundary · Submission and reconciliation · Cloud preflight · Current MCP surface · Design requirements · Parity inventory