feat(agents): automatic model fallback when Ollama Cloud is exhausted
ci / lint (pull_request) Successful in 13s
ci / lint (pull_request) Successful in 13s
Keep ollama-cloud/* as primary. Each agent may declare fallback in agents.json (xai-oc/grok-*). On quota/auth/provider failure, run-agent switches once to the fallback and continues retries. - agents.json: fallback fields for pm/junior/senior/qa/intern - route.sh: emit fallback to GITHUB_OUTPUT - agent.yml: pass FALLBACK env into run-agent - install-opencode.sh: register primary+fallback models in provider maps - run-agent.sh: failover on quota/credit/429/capacity-class errors
This commit is contained in:
@@ -54,9 +54,11 @@ PERM=$(jq -nc --argjson s "$SKILLS" '
|
||||
# 1.17.13 — renaming the key to `xai-oc` avoids the collision entirely. See issue #118.
|
||||
# See issue #31.
|
||||
AGENTS_JSON="${SCRIPTS:-$(dirname -- "$0")}/agents.json"
|
||||
CLOUD_MODELS=$(jq -r '[.[] | .model | select(startswith("ollama-cloud/")) | sub("^ollama-cloud/";"")] | map({(.):{}}) | add // {}' "$AGENTS_JSON")
|
||||
LOCAL_MODELS=$(jq -r '[.[] | .model | select(startswith("ollama/")) | sub("^ollama/";"")] | map({(.):{}}) | add // {"ornith:35b":{}}' "$AGENTS_JSON")
|
||||
XAI_MODELS=$(jq -r '[.[] | .model | select(startswith("xai-oc/")) | sub("^xai-oc/";"")] | map({(.):{}}) | add // {}' "$AGENTS_JSON")
|
||||
# Include primary `.model` AND optional `.fallback` so failover models are always registered
|
||||
# in opencode provider maps (issue: Ollama Cloud quota → xAI).
|
||||
CLOUD_MODELS=$(jq -r '[.[] | (.model, .fallback) | select(type=="string" and startswith("ollama-cloud/")) | sub("^ollama-cloud/";"")] | unique | map({(.):{}}) | add // {}' "$AGENTS_JSON")
|
||||
LOCAL_MODELS=$(jq -r '[.[] | (.model, .fallback) | select(type=="string" and startswith("ollama/")) | sub("^ollama/";"")] | unique | map({(.):{}}) | add // {"ornith:35b":{}}' "$AGENTS_JSON")
|
||||
XAI_MODELS=$(jq -r '[.[] | (.model, .fallback) | select(type=="string" and startswith("xai-oc/")) | sub("^xai-oc/";"")] | unique | map({(.):{}}) | add // {}' "$AGENTS_JSON")
|
||||
jq -n --argjson mcp "$MCP" --argjson perm "$PERM" --argjson cloud "$CLOUD_MODELS" --argjson local "$LOCAL_MODELS" --argjson xai "$XAI_MODELS" --arg url "$OLLAMA_URL" --arg ckey "$OLLAMA_CLOUD_API_KEY" --arg xkey "$XAI_API_KEY" '{
|
||||
provider: {
|
||||
ollama: {npm:"@ai-sdk/openai-compatible", options:{baseURL:($url+"/v1")}, models:$local},
|
||||
|
||||
Reference in New Issue
Block a user