feat(workers): add optional Metis local-first lookup for the solver role - #489
Merged
Conversation
Adds workers/metis_local_first.py, a fail-soft client for the Metis
cluster's read-only MCP server (github.com/SaJaToGu/metis). Before a
solver-role issue falls back to its configured cloud provider, callers
can ask Metis whether a home-lab worker currently has a live, reachable
Ollama endpoint for a matching capability (default: "local-llm").
Reuses the existing AiderAdapter(provider="ollama") as-is - no new
adapter class needed. build_ollama_run_config() returns
(model="ollama", model_name=<live tag>, {"OLLAMA_HOST": base_url}),
which is exactly the shape AiderAdapter._build_aider_env already
expects for the ollama provider.
Design decisions (from a grilling session, recorded in
metis/docs/ecosystem-coordination-2026-07-20.md):
- Metis standardizes worker serving on Ollama, not raw llama.cpp
llama-server, so this reuses AIS's existing local-model hook
instead of inventing a new protocol.
- find_execution_options on the Metis side live-pings each
candidate's Ollama endpoint rather than trusting static registry
data, so a stale/offline worker never gets returned as a candidate.
- Not wired into solve_issues.py's main() yet - that CLI's per-role
model resolution needs more investigation before a safe edit there.
This commit ships the standalone, tested client; wiring it into the
actual dispatch path is tracked as follow-up work.
Fails soft everywhere: unreachable Metis, missing mcp package, no
live candidate, or malformed response all return None so callers keep
working exactly as before if this optimization isn't available.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…patch Adds an opt-in --local-first flag that queries Metis for a live cluster Ollama worker before each solver-role issue, falling back to the CLI-specified --model on any miss (unreachable Metis, no candidate, ensemble mode, or dry-run). Extracts the override logic into resolve_local_first_dispatch() so it's unit-testable independent of main()'s CLI wiring. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
workers/metis_local_first.py: fail-soft client for Metis's read-only MCP server, asking whether a home-lab worker has a live, reachable Ollama endpoint before the solver role falls back to its configured cloud provider.AiderAdapter(provider="ollama")as-is:build_ollama_run_config()returns exactly the(model, model_name, config)shape that adapter already expects, so no new adapter class was needed.metis/mcp/server.py'sfind_execution_optionsnow live-pings each candidate's Ollama endpoint (see SaJaToGu/metis, commit3d811ea), so a stale/offline worker is never returned.Not included (follow-up)
solve_issues.py'smain()dispatch. That function's per-role model resolution needs more reading before a safe edit (role_routing.yaml's resolved config currently feeds budget tracking; the CLI'sargs.modelis a separate, user-supplied flag). Shipping the standalone, tested client first; wiring it into the actual run path is tracked separately.Test plan
python3 -m unittest tests.test_metis_local_first— 3 new tests against a real embedded FastMCP server (reachable candidate, no candidate, unreachable Metis), all pass without touching a real network Metis instance.python3 -m unittest tests.test_worker_adapters— 99 existing tests, unaffected.