[Infra] Model fallback chain — resilient Ollama calls with model cascade #79
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Overview
Wrap all Ollama calls in a fallback chain so the system stays alive when the primary model is unavailable. No cloud APIs — local only.
Fallback Chain
hermes3)llama3.2GET /api/tagsIf all local models fail, return a graceful error instead of crashing.
Changes
server/ollama_client.py(NEW)Resilient Ollama HTTP client:
OllamaClient(base_url, models=["hermes3", "llama3.2"])async generate(prompt, system, json_mode) -> strasync list_models() -> list[str]— GET /api/tagsasync health() -> bool— GET /api/versionserver/research.pyReplace raw
httpxOllama calls withOllamaClient.server/bridge.pyExpose
OllamaClientinstance on the bridge for shared use.Add
system_statusmessage on model fallback events.Acceptance Criteria
Closes
Resolved in PR #81 (feat/automation-sprint). All tests passing.