Skip to content

feat: swappable AI provider system (claude, codex, ollama)#8

Merged
bdougie merged 3 commits intomainfrom
feat/swappable-ai-providers
Mar 17, 2026
Merged

feat: swappable AI provider system (claude, codex, ollama)#8
bdougie merged 3 commits intomainfrom
feat/swappable-ai-providers

Conversation

@bdougie
Copy link
Copy Markdown
Contributor

@bdougie bdougie commented Mar 17, 2026

Summary

  • Adds a provider registry (pkg/provider/) so sweeper can use different AI backends instead of being hardcoded to Claude
  • Two provider categories: CLI (claude, codex) with built-in file tools, and API (ollama) where sweeper includes file content in prompts and applies returned unified diffs via patch -p1
  • New CLI flags: --provider, --model, --api-base
  • VM isolation (--vm) validated to only work with CLI providers
  • Documentation updated: README, SKILL.md, skills README

New files

File Purpose
pkg/provider/provider.go Kind enum, Provider struct, Config
pkg/provider/registry.go Register/Get/Available registry
pkg/provider/claude.go Claude self-registration
pkg/provider/codex.go Codex self-registration
pkg/provider/ollama.go Ollama self-registration
pkg/worker/codex.go Codex CLI executor
pkg/worker/ollama.go Ollama HTTP executor + diff extraction + patch

Test plan

  • go build ./... compiles cleanly
  • go test ./... all tests pass (including new provider, prompt, and diff extraction tests)
  • Coverage check passes (90.2%)
  • sweeper run --provider claude — identical behavior to current default
  • sweeper run --provider codex — uses codex CLI (requires codex installed)
  • sweeper run --provider ollama --model qwen2.5-coder:7b — uses local Ollama
  • sweeper run --provider ollama --vm — returns error (API providers incompatible with VM)

bdougie added 3 commits March 17, 2026 10:19
Introduce a provider registry so sweeper can use different AI backends
instead of being hardcoded to Claude. Well-scoped subagent tasks like
lint fixes can now run on smaller/cheaper models via Ollama or use
alternative CLI harnesses like Codex.

Two provider categories:
- CLI (claude, codex): have built-in file tools, sweeper sends prompts
- API (ollama): text-in/text-out, sweeper includes file content in
  prompts and applies returned unified diffs via patch

New flags: --provider, --model, --api-base
VM isolation validated to only work with CLI providers.
1. Remove unused allowedTools param from NewCodexExecutor — codex CLI
   has no tool restriction mechanism
2. Add 100KB size cap to readFileContent to prevent blowing up API
   token limits on large files
3. Extract availableLocked() to avoid reentrant RLock in registry
4. Validate --provider early in cmd/run.go so typos error instead of
   silently falling back to claude; agent.New logs a warning on fallback
5. Remove duplicate agentPreamble from ollama system message — prompt
   builders already include it
6. Remove --no-backup-if-mismatch from patch invocation (macOS
   incompatible); add comment about path assumptions
7. Replace custom contains() helper with strings.Contains in agent tests
1. extractDiff: fall back to plain ``` blocks when model omits the
   "diff" language tag — matches blocks starting with "diff " or "--- "
2. parseMinimal: skip go compiler package headers (": # testproject")
   that were being parsed as lint issues and sent to the model
3. normalizeIssuePaths: resolve linter output paths relative to the
   target dir so "../../../tmp/project/main.go" and "./main.go" merge
   into a single fix task instead of splitting into two
@bdougie bdougie merged commit 45202ba into main Mar 17, 2026
6 checks passed
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