Operations

/cmux-agents

Spawn AI workers in cmux via MCP/repoGolem. Triggers: visible workers, terminal agents, orchestration, audits.

$ golems-cli skills install cmux-agents
Good
100% best pass rate
196 assertions
43 evals
1 workflow

Updated 5 days ago

Orchestration layer for AI agents in cmux panes. Low-level pane operations (splits, reads, sends) use cmux MCP tools — this skill handles the workflow on top.

Lead/Orchestrator Monitor Law

Monitor/cron/loop-payload rules → see cron-payload-discipline (canonical). cmux-agents owns the worker-engine lifecycle below; do not duplicate the canonical monitor law here.

ROLE GEOMETRY — leads/orchestrators land LEFT, workers land RIGHT (automatic)

Why this exists (2026-06-14): the cmux skill/MCP setup kept confusing agents about geometry — who goes where, and how to avoid hand-placing panes. The cmuxlayer layout policy (PR #156) now enforces a two-column invariant by ROLE, so you should stop hand-managing left/right and just pass the role.

  • Leads / orchestrators → LEFT column. Role orchestrator. Default inferred from a *Claude launcher title.
  • One lead pane per workspace. Additional leads, successor leads, and promoted coordinators must become tabs in the existing left orchestrator pane unless the user explicitly asks for a separate lead pane/workspace. A managed successor lead that creates a new left split or third column is successor_lead_wrong_pane / topology_three_or_more_columns; immediately move it into the existing lead pane, verify column_count:2, and keep the failure in the collab/report.
  • Workers (Codex/Cursor implement+gather) → RIGHT column. Role worker. Default inferred from *Codex / *Cursor titles.
  • Role is semantic, not decorative. Use role:"orchestrator" only for a lead/orc seat that coordinates, routes, verifies, and reports. Use role:"worker" for implementation, gathering, audit, or phase execution seats. A Codex lead can be an orchestrator; ordinary Codex/Cursor phase agents are workers.
  • Codex orchestrator is valid when managed. non_claude_orchestrator must not be treated as a health failure by itself. A Codex lead is production-valid when it has managed agent_id, role:"orchestrator", left-column placement, resumability/session health or explicit non-resumable health, and a Codex adapter guard (inbox:live, owned wait_for(done), or watcher:<pid/task-id>). The failure is an unmanaged/unmonitored Codex orchestrator, not "Codex is lead."
  • Promoted leads must be relaunched or registered as leads. Renaming a worker/right-pane surface to "LEAD" does not make it a lead. Any promoted lead must have a managed agent_id, role:"orchestrator", and left-column placement. If it lacks any of those, mark lead_unmanaged / role_topology_mismatch and recover/register or replace it with a managed lead before production work continues.
  • Default workspace is the parent agent workspace. If the caller does not explicitly pass workspace, managed spawn_agent should place the new worker in the parent/caller agent's workspace, not the human's currently focused workspace. Passing no workspace must not create or select a surprise workspace. If cmuxlayer must focus the parent workspace to make a terminal initialize, it must focus the parent workspace, create the pane, wait until the pane/surface is initialized and available, then restore the user's prior focus. If cmuxlayer violates this, move the surface back, resync, and report a health failure.
  • Pass the role, don't compute the column. spawn_agent, new_split({role}), and spawn_in_workspace place by role automatically. Once two columns exist, additional workers dock as TABS in the rightmost worker pane — never a third column.
  • Topology drift is a health failure. Unexpected three-column layouts, a worker in the lead column, an orchestrator that creates a surprising split, or a successor lead tab that lands outside the existing lead pane must be called out in the collab/status report and routed to cmuxlayer. Do not summarize the fleet as "fine" when geometry is visibly wrong.
  • spawn_in_workspace is the clean team stand-up: one call creates the workspace and lays out commanders-LEFT / workers-RIGHT atomically. Prefer it over a sequence of spawn_agent calls when standing up a multi-agent team.
  • Auto-focus is handled for you (PR #156). Workspace-targeted splits focus the target before splitting and restore your focus after render. You no longer hand-run focus-pane around every split — but focus:true is still REQUIRED on role-based new_split (role placement rejects focus:false).
  • Engine routing rules → see agent-routing (canonical). cmux-agents only maps the chosen role to pane placement.

Default Lifecycle (2026-04-19)

Visible worker peers now use the agent-based cmux MCP tools by default:

  1. mcp__cmux__spawn_agent({repo, cli, prompt, workspace?, parent_agent_id?})
  2. Capture the returned agent_id immediately and write it into your collab / AGENT_REGISTRY.
  3. mcp__cmux__wait_for({agent_id, target_state, timeout_ms}) for lifecycle gates. For autonomous file-backed workers, pass report_path and done_marker with target_state:"done" so cmux can promote terminal report evidence instead of hanging on stale registry state.
  4. mcp__cmux__send_to({agent_id, text, press_enter}) (or dispatch_to_agent) for follow-ups.
  5. mcp__cmux__get_agent_state({agent_id}) for a combined registry + parsed-screen snapshot.
  6. mcp__cmux__inbox_check({agent_id}) for subscription/inbox health.
  7. mcp__cmux__list_agents(...) or mcp__cmux__my_agents(...) whenever topology changes.
  8. mcp__cmux__stop_agent({agent_id}) to stop or recycle a worker.

Reference agents by agent_id, not surface index. Surface IDs drift after crashes, respawns, and pane reuse; agent_id is the durable handle. Surface refs still matter for raw inspection (read_screen) and non-agent panes (new_surface, browser tabs), but not for the default worker lifecycle.

Existing Agent Reuse / Goal Supersession

Before spawning, run list_agents / my_agents when the user references an existing pane/agent or when the same repo/workspace/role lane may already exist.

  • Reuse the existing managed agent unless it is dead, unhealthy, or the user explicitly asks for a replacement.
  • Do not spawn a duplicate just to get a cleaner prompt.
  • If the current agent has a stale or too-narrow mission, supersede it with one explicit file-backed goal follow-up.
  • Preserve the user's full delegation intent in the goal file. Do not shrink a broad mission to the next local blocker unless the user asks for a narrow task.

Supersession pattern:

1. Write /abs/path/goal.md with full mission, constraints, success criteria, report path, DONE marker, and green/no-green decision.
2. Deliver the goal using the receiver's adapter syntax, not a universal `/goal` assumption:
   - Codex: `/goal Read and execute this goal file until complete: /abs/path/goal.md` only after verifying this Codex harness accepts `/goal`; otherwise use a plain file-contract message.
   - Cursor: use the current Cursor agent goal command only when verified; if it renders a duplicated footer/status prompt, verify from screen/file progress before sending again.
   - Gemini/Antigravity: plain file-contract instruction, e.g. `Read and execute this goal file until complete: /abs/path/goal.md`; do not prefix `/goal` unless that harness version explicitly documents it.
   - Claude: native goal/monitor flow when available.
3. Read the pane within 15 seconds and verify the harness accepted the
   supersession according to that harness's adapter contract.
4. Record goal_file, report path, DONE marker, delivery path, supersession
   evidence, and any command-state caveat in the collab Agent row.
5. Monitor the report file/DONE marker first; use pane reads only for delivery failure or health disputes.

If cmuxlayer exposes supersede_agent_goal, use it instead of a raw follow-up so registry task_summary and goal_file stay truthful.

Harness Command Semantics Map

Do not turn every live TUI surprise into a bespoke rule. For command-driven agent control, maintain an adapter-level command semantics map and derive specific rules from it. The map should cover Codex, Claude, Cursor, cmuxlayer, and repoGolem launchers for:

  • goal replace/resume and confirmation menus;
  • interrupt/pause/resume behavior;
  • monitor, watcher, inbox, and completion wake paths;
  • subagent/worker spawn and managed agent_id registration;
  • worker close/archive semantics;
  • MCP reconnect/restart and successor handoff;
  • manual launcher fallback and prompt submission verification.

When a command behaves unexpectedly, record the transcript as evidence, update the adapter map or an eval, and only add a local workaround when it is needed to unblock the current lane. Example evidence: Codex /goal replacement may stop at a confirmation menu or leave the old objective paused after interruption; the adapter rule is "verify the command reached the intended state," not "assume /goal sends are atomic."

Managed Health Gate

After every managed spawn, record a registry row with:

| Claimed Name | Agent ID | Surface | Workspace | Role | cli_session_id | Resumable | Inbox | Topology | Status |

Treat these as HEALTH FAILURE conditions, not warnings:

  • agent_id missing, unknown, or auto-* discovered instead of a managed id.
  • Lead/orchestrator pane has no managed agent_id, is an orphan/raw surface, or was produced by an interrupted spawn.
  • cli_session_id:null / non-resumable on a long-running or crash_recover:true agent.
  • inbox_check.monitor_alive:false, stale pending messages, or dispatch requiring a fallback nudge.
  • get_agent_state says ready/idle while the raw pane is working, wedged, or has unsubmitted text.
  • A boot prompt or task prompt is visibly typed in the agent composer but was not submitted. This is boot_prompt_typed_not_submitted; send Return only as an explicit recovery action, then record the delivery failure even if the worker later succeeds.
  • Role/topology mismatch: worker in lead column, lead placed as worker, unexpected third column, surprise workspace creation, or unexplained split drift.
  • Registry/surface mismatch: get_agent_state.workspace_id or surface route disagrees with list_surfaces after a move/resync.
  • Repo/cwd ambiguity: a pane running from a generic directory (for example ~/Gits) gets bad auto labels or repo ownership. Treat this as health evidence and relaunch from the intended repo through managed spawn.

If any fail, append the failure to the collab before continuing. Do not hide it behind a normal status line.

Lead Goal Contract

A lead/orchestrator goal is not a worker checklist. Its goal file must say:

  • Spawn/delegate Cursor gatherers, Codex implementers, or cmux workers as needed.
  • Maintain the collab Agent table and health gates.
  • Synthesize, verify, and decide; do not personally grind the whole lane except tiny glue or urgent unblockers.
  • Close workers after their reports/DONE markers or blocked handoffs are captured, unless the Agent row records KEPT_OPEN:<reason> with owner and next check for active review, successor orientation, live process state, or paired continuation. Unexplained completed panes are done_worker_left_open.

If a supposed lead receives a worker-style /goal that makes it execute the full lane directly, rewrite/supersede the goal before it starts burning lead context.

Workflows

/cmux-agents:prompt-audit