Skip to content

Steering: inject instructions into a running task #51

@chanakyav

Description

@chanakyav

Summary

Add the ability to inject new instructions into a running task — either by restarting with a modified prompt or by queuing guidance for the next iteration while the task continues running.

Motivation

Once a task is running, there's no way to adjust its direction without losing progress:

  • restart reuses the original prompt — no way to change instructions
  • resume --pr creates a new task, only enters the review-fix loop (can't re-run IMPLEMENT), and loses iteration history, fix summaries, and context carry-forward
  • Stopping a task in WAIT_REVIEW (10+ min wait) throws away that wait — the review arrives but the task is dead

Users want to steer when they see the PR diff mid-run and realize "ignore style nits" or "merge main before the next fix" or "switch approach for the database migration."

Two Approaches

Approach A: restart --prompt (simpler)

Add a --prompt flag to autopilot restart that overrides the stored prompt when restarting a stopped task.

Flow:

autopilot stop abc12345
autopilot restart abc12345 --prompt "Keep the current approach but ignore style nits, focus on logic bugs"

Implementation:

  • Add --prompt arg to cmd_restart() parser
  • If provided, update_task(task_id, prompt=new_prompt) before restarting
  • Orchestrator picks up the new prompt naturally (it reads self.task["prompt"] fresh)

Pros:

  • Dead simple — ~10 lines of real code
  • Familiar mental model (stop, adjust, restart)
  • No new concepts or commands
  • Prompt is visible in the DB/logs

Cons:

  • Requires stopping first — interrupts WAIT_REVIEW/WAIT_CI, wasting that polling time
  • Loses the "append guidance" semantic — you're replacing the whole prompt (or need to concatenate manually)
  • Doesn't help if you want to inject one-time instructions for just the next FIX cycle

Approach B: Steering file (richer)

Add autopilot steer <id> "message" that queues instructions for the next agent invocation without interrupting the current state.

Flow:

# Task is in WAIT_REVIEW — don't want to interrupt the wait
autopilot steer abc12345 "Ignore the style nits in the review, focus only on the logic bugs"

# Next time the orchestrator invokes copilot -p (FIX phase), it prepends this text
# The file is consumed (one-shot) after use

Implementation:

  • autopilot steer <id> "message" writes to ~/.autopilot-loop/sessions/<id>/steer.txt
  • Before each _run_agent_with_retry() call, orchestrator checks for steer.txt
  • If present: prepend contents to the prompt as a ## User Guidance section, delete the file
  • Optional: TUI keybinding (s on selected task) opens $EDITOR or inline input

Pros:

  • Non-disruptive — doesn't interrupt WAIT_REVIEW or WAIT_CI
  • One-shot semantic is clean — guidance applies to the next cycle only
  • Works from TUI (keybinding s) for a smooth interactive experience
  • Preserves full context continuity (iteration history, fix summaries)

Cons:

  • New command to learn
  • File-based IPC (simple but slightly more plumbing)
  • Narrow high-value window: only useful when the task is idle between iterations
  • If the task is mid-agent (IMPLEMENT, FIX), the steer won't apply until the next cycle

Recommendation

Start with Approach A (restart --prompt) — it covers ~80% of the need with minimal code. Add Approach B (steering file) later if users report that interrupting WAIT states is a real pain point.

They're not mutually exclusive — both could coexist.

Files Touched

Approach A:

  • src/autopilot_loop/cli.py — add --prompt to cmd_restart() parser and logic
  • tests/test_cli.py — test restart with new prompt

Approach B (if pursued):

  • src/autopilot_loop/cli.py — new cmd_steer() + parser
  • src/autopilot_loop/orchestrator.py — check for steer file in _run_agent_with_retry()
  • src/autopilot_loop/dashboard.py — TUI keybinding (optional)
  • tests/test_cli.py, tests/test_orchestrator.py — steer tests

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions