Skip to content

feat(workers): add optional Metis local-first lookup for the solver role - #489

Merged
SaJaToGu merged 2 commits into
devfrom
feat/metis-local-first-solver-adapter
Jul 21, 2026
Merged

feat(workers): add optional Metis local-first lookup for the solver role#489
SaJaToGu merged 2 commits into
devfrom
feat/metis-local-first-solver-adapter

Conversation

@SaJaToGu

Copy link
Copy Markdown
Owner

Summary

  • New 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.
  • Reuses the existing 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-side context: metis/mcp/server.py's find_execution_options now live-pings each candidate's Ollama endpoint (see SaJaToGu/metis, commit 3d811ea), so a stale/offline worker is never returned.

Not included (follow-up)

  • Not yet wired into solve_issues.py's main() 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's args.model is 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.

SaJaToGu and others added 2 commits July 20, 2026 20:08
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>
@SaJaToGu
SaJaToGu merged commit 39de1cc into dev Jul 21, 2026
1 of 2 checks passed
@SaJaToGu
SaJaToGu deleted the feat/metis-local-first-solver-adapter branch July 21, 2026 05:41
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