feat: swappable AI provider system (claude, codex, ollama)#8
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pkg/provider/) so sweeper can use different AI backends instead of being hardcoded to Claudepatch -p1--provider,--model,--api-base--vm) validated to only work with CLI providersNew files
pkg/provider/provider.gopkg/provider/registry.gopkg/provider/claude.gopkg/provider/codex.gopkg/provider/ollama.gopkg/worker/codex.gopkg/worker/ollama.goTest plan
go build ./...compiles cleanlygo test ./...all tests pass (including new provider, prompt, and diff extraction tests)sweeper run --provider claude— identical behavior to current defaultsweeper run --provider codex— uses codex CLI (requires codex installed)sweeper run --provider ollama --model qwen2.5-coder:7b— uses local Ollamasweeper run --provider ollama --vm— returns error (API providers incompatible with VM)