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
- Lead / CEO. A CLI lead or an agent using MCP shapes the plan and briefs, follows jobs and PRs, and decides tickets within the owner’s delegation. The separate LazyCEO application can use the shared Projects Store and supplies its own messaging, specialist lifecycle and acceptance policy.
- LazyTools. Projects holds the board and task receipts. The dispatcher selects, claims, launches and settles tasks. The code bridge owns job records, execution, approvals and the PR workflow. The dedicated orchestration MCP server exposes these services to clients.
- LazyBridge. The framework supplies the Store and durable blackboard, engine adapters, approvals, and supporting primitives such as receipts and lessons.
- Workers and reviewers. Local writers run Codex or Claude Code in a task checkout. Codex Cloud and Claude cloud sessions start from a GitHub branch of the target repository. A separate reviewer judges the resulting commit or PR head.
- Owner. The human operator controls the credential and delegation policy, decides owner-routed requests, and handles escalations that need human judgment.
Sources · Repository boundaries · Dispatcher and workers · Owner credential · LazyBridge primitives
3. Architecture
Sources · MCP server · Projects and Store · Dispatch · Approval registry
4. How it works
Task graph and lifecycle
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
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
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
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 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
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
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
- Coverage. The graph dispatcher handles writer tasks. Review and contract tasks need another caller. The current MCP tool list leaves graph dispatch on the CLI. One-pass dispatch tools and a supervised continuous runner are design requirements.
- State and capacity. The governed queue requires a file-backed Store. Callers must point to the same file to share state. The project owner label is for coordination. Some project updates span keys, and in-process callbacks can fail after a write has committed. Quota is an estimate, and declared path globs can miss a real conflict.
- Local execution. Approval parsing is conservative and covers only actions visible to the bridge. Native sandbox policy, repository configuration and executables matter. Git helpers or hooks can run repository code, and readable credentials inside a checkout can be exposed. Legacy launch has unverified runtime confinement. The ordinary bridge repository lock uses PID-only liveness and can race during stale lock reclamation.
- Cloud and delivery. Cloud workers see the remote checkout and provider environment. They lack local files and data, and their tool calls are outside the local command gate. Landing can fail on a moved base, and an ambiguous provider submission may need reconciliation. The event cursor is integrity-checked but unsigned, grows with retained jobs, and covers recorded events.
Sources · Projects boundaries · Local risks · Cloud boundary · Submission and reconciliation · Cloud preflight · Current MCP surface · Design requirements · Parity inventory