Skip to content

✨ feat: advisor phase — frontier model plans the sweep, workers execute it - #24

Merged
bdougie merged 10 commits into
mainfrom
issue-21-advisor-phase
Jul 4, 2026
Merged

bdougie merged 10 commits into
mainfrom
issue-21-advisor-phase

Conversation

@bdougie

@bdougie bdougie commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #21

What

Optional advisor phase: when configured, a frontier model plans each sweep round — task ordering, per-file difficulty, strategy hints, worker-tier suggestions — and cheaper worker models execute the fixes.

sweeper run --advisor-model claude-opus-4-8 --provider ollama --model qwen2.5-coder:7b
[advisor]
name = "claude"
model = "claude-opus-4-8"

Design

  • New leaf package pkg/advisor: BuildPrompt (lint output + history summaries — never file contents), Advise (one-shot executor call with 5m timeout), ParsePlan (fence/prose-tolerant JSON extraction), Apply (overlays plan on mechanical grouping: drops hallucinated files, appends omitted ones, first-wins dedupe), ResolveStrategy (retry/exploration hints honored only when history exists).
  • Agent runs advise() once per round before dispatch; any failure falls back to the mechanical GroupByFile plan with a warning and keeps sweeping.
  • Zero behavior change when unconfigured — advisor executor is nil and the round loop is identical to main.
  • Advisor requires a CLI-kind provider (claude/codex); ollama (KindAPI) and unknown providers warn + disable. Also disabled under --vm (VM executor can't select models yet) and skipped under --dry-run (keeps dry runs free).
  • Every advisor call emits an advisor_plan telemetry event (round, provider, model, duration, files_input, success, files_planned/error).
  • Tier hints are parsed and carried but not routed — routing is Per-role model config and model escalation ladder on stagnation #22.

Verification

  • 40+ new tests across pkg/advisor (23), pkg/config (4), pkg/agent (8+), all TDD (watched fail first). Full suite green.
  • Multi-agent review: per-task spec+quality review on all 8 tasks, plus a whole-branch final review; both Important findings from the final review (advisor escaping --vm isolation; --dry-run making a real model call) fixed in f4e2f30 with tests.
  • End-to-end with fake CLIs logging their args:
    • --advisor-model test-opus --model test-haiku → advisor invoked with --model test-opus + planning prompt (no file contents), worker with --model test-haiku + fix prompt; advisor_plan {"success":true, files_input:1, files_planned:1}; per-model fix_attempt attribution
    • no advisor flags → exactly one claude call, zero advisor_plan events (default unchanged)
    • garbage advisor output → Warning: advisor failed ... using mechanical plan, "success":false, still 1 fixed
    • --advisor-provider ollama → Warning: advisor requires a CLI provider, sweep proceeds mechanically
    • --advisor-model X --dry-run → zero model invocations

Follow-ups (non-blocking, from review)

bdougie added 10 commits July 4, 2026 10:44
The advisor executor was built from the provider registry unconditionally,
so it spawned claude on the host even under --vm, breaking VM isolation for
worker execution. It also ran before the --dry-run early-return, spending a
real model call (up to 5 min) on dry runs that previously made none.

Gate advisor resolution on cfg.VM (warn and disable, since the VM executor
doesn't support model selection yet) and gate the advise() call on
!cfg.DryRun so dry-run stays free of model calls.
@bdougie
bdougie merged commit 009a5f7 into main Jul 4, 2026
6 checks passed
@bdougie
bdougie deleted the issue-21-advisor-phase branch July 4, 2026 18:57
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.

Advisor phase: frontier model plans the sweep, workers execute it

1 participant