Skip to content

docs(orchestrate): pin the target workspace before spawning; kill agents before closing panes - #6

Open
tawman wants to merge 2 commits into
amirlehmam:masterfrom
tawman:feature/orch-workspace-pinning-docs
Open

docs(orchestrate): pin the target workspace before spawning; kill agents before closing panes#6
tawman wants to merge 2 commits into
amirlehmam:masterfrom
tawman:feature/orch-workspace-pinning-docs

Conversation

@tawman

@tawman tawman commented Jul 8, 2026

Copy link
Copy Markdown

Docs-only update to the orchestrate skill, from two failure modes hit in real multi-wave runs. No script changes — the wmux CLI already supports everything referenced.

1. Panes/agents spawn into the ACTIVE workspace, not the coordinator's

wmux layout grid anchors to the caller's WMUX_SURFACE_ID. In background or resumed coordinator sessions that env var is often stale (points at a dead surface), and the app then falls back to whatever workspace the user currently has active. spawn-agents.sh passes no --workspace either — so an entire orchestration grid plus its agents can materialize in an unrelated workspace the user is working in. Their --cwd still governs where they work, so the run succeeds, but it hijacks the user's screen and breaks pane-hygiene counting.

CLI facts the new text relies on (all already shipped): agent spawn, layout grid, list-panes, and agent list all accept --workspace <id>; list-workspaces returns { id, title, isActive, cwd } — and multiple workspaces can share a cwd, so the target must be resolved by id.

Changes:

  • Phase 6b — resolve the target workspace at orchestration start and record it in state.json's workspaceId field (which has existed in the schema all along but was never populated).
  • Phase 6d — pin before spawning: primary path is wmux select-workspace <id> right before spawn-agents.sh (works with the script unchanged); focus-preserving alternative is layout grid --workspace + per-agent agent spawn --pane. Also fixes the stale claim that the script creates panes via wmux split — it uses wmux layout grid (6d and 6e).
  • Phase 7 — scope agent list with --workspace (the default is ALL workspaces, so the listing can include the user's own agents from other sessions) and never kill an agent the orchestration didn't spawn.

2. Teardown order: agent kill BEFORE close-pane

Closing an agent's pane first leaves the agent registry stale — agent list keeps reporting the agent as running, agent kill then fails with "Agent not found" — and the launcher process tree (shell → node → claude) survives the pane close, invisibly burning CPU and tokens.

Changes:

  • Phase 7 wave transition — reap in order when closing finished agents' panes.
  • Phase 9 — the ordering rule, the stale-registry failure mode, and the recovery path (kill the process tree by pid; judge liveness by the process, not the registry status).

tawman added 2 commits July 8, 2026 11:57
…awning agents

wmux layout grid anchors to the caller's WMUX_SURFACE_ID; in background or
resumed coordinator sessions that env var is often stale (points at a dead
surface), and the app then falls back to whatever workspace the USER has
active. spawn-agents.sh passes no --workspace either, so a whole
orchestration grid + agents can land in an unrelated workspace the user is
working in (their --cwd still governs where they work, but it hijacks the
user's screen and breaks pane counting).

Docs-only change; the wmux CLI already supports everything referenced
(agent spawn / layout grid / list-panes / agent list all take --workspace,
and list-workspaces returns { id, title, isActive, cwd }):

- Phase 6b: resolve the target workspace at orchestration start via
  list-workspaces (multiple workspaces can share a cwd — resolve by id)
  and record it in state.json's workspaceId field, which has existed in
  the schema all along but was never populated.
- Phase 6d: pin before spawning — primary path is select-workspace right
  before spawn-agents.sh (OOTB-compatible); focus-preserving alternative
  is layout grid --workspace + per-agent agent spawn --pane. Also fix the
  stale claim that the script grids via 'wmux split' (it uses layout grid).
- Phase 7: scope agent list with --workspace (default is ALL workspaces,
  so the listing may include the user's own agents from other sessions);
  never kill an agent this orchestration didn't spawn.
… trees

Closing an agent's pane before killing the agent leaves the registry
stale — agent list keeps reporting the agent as running, agent kill then
fails with "Agent not found" — and the launcher process tree
(shell → node → claude) survives the pane close, invisibly burning CPU
and tokens.

- Phase 7 wave transition: if closing finished agents' panes to make
  room, reap in order (agent kill, then close-pane).
- Phase 9: state the ordering rule, the stale-registry failure mode, and
  the recovery path (kill the process TREE by pid from agent list —
  Windows: taskkill /F /T /PID — and judge liveness by the process, not
  the registry status).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant