Skip to content

Add per-slice MCP controls (restart_slice, etc.) for #2137 slice scheduling #2199

Open

Description

@jwbron

Problem

Today's MCP retry/restart surface operates at phase granularity:

  • restart_phase(task_id, phase) — restarts an entire phase (refine / plan / implement / pr).
  • restart_agent(task_id, agent_role) — restarts a single agent within whatever phase is active.

When #2137 lands, the implement phase will fan out into a DAG of independent slices, each running its own BRC consensus on its own branch. The phase-granularity tools no longer fit the runtime shape:

  • restart_phase('implement') would tear down all slices and respawn from scratch — wasteful when only one slice failed.
  • restart_agent(role) is ambiguous when the same role exists in multiple concurrently-running slices ("which slice's coder do you mean?").

Operators will routinely need to restart a single failing slice without disturbing siblings, and to inspect or restart a specific agent within a specific slice.

Proposed verbs

  • restart_slice(task_id, slice_id) — tear down the slice's containers, reset its BRC tracker, respawn its agent team. Siblings continue unaffected.
  • restart_agent(task_id, agent_role, slice_id=None) — extend the existing verb with an optional slice_id. When omitted on a sliced phase, return a structured error listing the candidate slices instead of guessing.
  • get_slice_status(task_id, slice_id) — per-slice status snapshot (consensus state, agents, recent messages, blocking_agents). Equivalent to get_status but scoped.
  • list_slices(task_id) — list all slices in the active implement phase with their states and DAG positions. Useful for operators to find the right slice_id.

Why this is a follow-up to #2137

#2137's implementation is already constrained to a single PR (per the refine-phase user input). Bundling per-slice MCP controls into that PR pushes it past the manageable size. The slice scheduler in #2137 should expose the internal hooks (the orchestrator must already know how to teardown / respawn / query a slice in isolation — it's how the run loop works), but the MCP verb surface can be a clean separate PR landing immediately after.

The hooks #2137 needs to expose internally:

  • A way to address a single slice by ID at the orchestrator level (the slice scheduler already needs this).
  • A teardown-and-respawn primitive for a slice (the slice scheduler already needs this for retries).
  • A status snapshot for a single slice (the orchestrator already needs this for HITL escalations).

Once those exist, this issue is a thin MCP-routes layer on top.

Files involved (forward-looking)

  • orchestrator/routes/mcp.py — add the four verbs as MCP tool registrations.
  • orchestrator/routes/pipelines.py — expose REST endpoints for the MCP verbs to call.
  • orchestrator/slice_scheduler.py (added by Independent implement phases #2137) — internal hooks for teardown/respawn/snapshot per slice.
  • docs/reference/mcp-tools.md — document the four new verbs.

Acceptance criteria

  • restart_slice works on a sliced implement phase: kills the target slice's containers, resets its BRC tracker, respawns its team. Unrelated siblings are unaffected (verified by integration test).
  • restart_agent with slice_id restarts a single agent within a single slice. Without slice_id on a sliced phase, returns a structured error listing candidates.
  • get_slice_status returns the same shape as get_status but scoped to one slice.
  • list_slices returns slice IDs, states (pending, running, complete, failed, blocked), DAG parents/children, and blocking-agent info.
  • Existing restart_phase, restart_agent (without slice_id), and get_status continue to work for non-sliced phases (refine, plan, pr) and during the migration window.

Out of scope

  • The slice scheduler itself — lands in Independent implement phases #2137.
  • cancel_slice (operator-driven slice cancellation) — separate concern; can be a third issue if needed.
  • Per-slice retry policy — belongs to the orchestrator's retry logic, not the MCP surface.

Related

Activity

  1. added
    sdlc-candidate
    on Apr 29, 2026
  2. added
    p2
    on May 5, 2026
  3. added a commit that references this issue on May 6, 2026
  4. jwbron commented on May 27, 2026

    @jwbron
    OwnerAuthor

    Speculative hooks for this issue are being preserved in #2777's cleanup

    Cross-referencing from #2777 (sliced implementation phase cleanup, in active
    SDLC pipeline as of 2026-05-27). One of #2777's open questions (cq-3) was
    whether to delete or preserve the speculative #2199 hooks in
    orchestrator/slice_scheduler.py. The operator decided to preserve them
    with dead-code markers + a doc-pointer to this issue
    rather than delete,
    on the read that #2199 is on the near-term roadmap and re-adding from
    scratch would lose the design intent.

    Hooks preserved for #2199

    These are already public on SliceScheduler (orchestrator/slice_scheduler.py)
    and unit-tested in orchestrator/tests/test_slice_scheduler.py, but not
    called by the production run loop
    . They were wired anticipating this
    issue. After #2777's cleanup lands, each will carry a # noqa: ARG002 /
    dead-code marker and a comment pointing here:

    poll_cascades (slice_scheduler.py:380) is the only one in this group
    that's already live (called at pipelines.py:15322 and 15860) and is not
    in this list — it stays unchanged.

    What #2199 will need to do

    To activate these, #2199 will need to:

    1. Wire record_cycle into the run loop — call it from the slice loop
      on each retry cycle. The cap config in env_config.py is already in
      place; the run loop just needs to call record_cycle(slice_id) at the
      right point and respect the bool return for "cap tripped" → escalate
      via hitl_escalator.
    2. Pass an hitl_escalator to the SliceScheduler constructor — at
      pipelines.py:15090 change SliceScheduler(contract) to
      SliceScheduler(contract, hitl_escalator=...) with a callback that
      surfaces the escalation through the orchestrator's HITL machinery.
    3. Plumb teardown_slice / respawn_slice through the new
      restart_slice MCP verb (per this issue's acceptance criteria).
    4. Verify the dead-code markers can come off — once the production
      loop calls these, drop the # noqa: ARG002 and the doc-pointer
      comments.

    Coordination

    If #2199 starts before #2777 lands, coordinate on the dead-code-marker
    shape so the eventual marker removal is a small diff. Otherwise, no
    ordering constraint — both can proceed in parallel.

    For context on the #2777 cleanup itself, see #2793 (refiner+reviewer_refine
    prompt scope) and #2794 (operator override channel) — both surfaced
    during the #2777 pipeline runs.

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

    p2sdlc-candidate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions