{
 "schema_version": 1,
 "generated": "2026-10-20",
 "id": "hkqr-my-free-code--keep-agent-sessions-running-with-model-fallbacks",
 "repo": "hkqr/my-free-code",
 "repo_url": "https://github.com/hkqr/my-free-code",
 "repo_slug": "hkqr-my-free-code",
 "title": "Keep agent sessions running when a provider fails",
 "page_title": "How to keep agent sessions running when a provider fails with My Free Code",
 "summary": "Set an ordered fallback list so a failed provider hands the request to the next model.",
 "who": "A developer whose coding agent stalls when one hosted provider has an outage or rate limit during a long task.",
 "problem": "A single provider failure stops the session, and the developer has to change configuration by hand to continue.",
 "outcome": "Requests fall through the configured FALLBACK_MODELS list when a provider fails before output, and the session keeps going.",
 "steps": [
  "Run `python -m venv .venv`, then `python -m pip install -r requirements.txt`, then `cp .env.example .env` as described in the setup section of the README.",
  "In .env, set MODEL_SONNET to your primary model and FALLBACK_MODELS to a comma-separated list such as groq/llama-3.3-70b-versatile,ollama/llama3.1.",
  "Add the API keys for each provider in the list to .env.",
  "Run `python -m my_free_code` and send a test request from Claude Code or another client.",
  "Check the gateway output for a failover event before relying on the chain for real work."
 ],
 "agent_prompt": "In the my-free-code repository, set MODEL_SONNET to <primary-model> and FALLBACK_MODELS to <fallback-model-1>,<fallback-model-2> in .env, then start the gateway with python -m my_free_code. Expected output: a test request completes using the primary model. Verify that the gateway falls through to the next model when the primary is made to fail before output.",
 "agents": [
  "any"
 ],
 "difficulty": "Intermediate",
 "time": "30 minutes",
 "basis": "readme",
 "caveat": "The README says fallback only applies before output is committed, so a stream that has already started will not switch providers.",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "python",
 "requirements": [
  "Python 3.11 or newer",
  "A clone of the my-free-code repository",
  "At least one provider API key for the MODEL values you choose, or a local model server such as Ollama, LM Studio, or llama.cpp",
  "Claude Code or another supported client installed and on PATH"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": false,
 "score": 0.9,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/hkqr-my-free-code/keep-agent-sessions-running-with-model-fallbacks/",
 "md": "https://dedupedai.com/use-cases/hkqr-my-free-code/keep-agent-sessions-running-with-model-fallbacks/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/hkqr-my-free-code--keep-agent-sessions-running-with-model-fallbacks.json",
 "api_version": "v1"
}
