DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to keep agent sessions running when a provider fails with My Free Code

Set an ordered fallback list so a failed provider hands the request to the next model.

Short answer: 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; then 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. All steps.

Who it is forA developer whose coding agent stalls when one hosted provider has an outage or rate limit during a long task.

The problemA single provider failure stops the session, and the developer has to change configuration by hand to continue.

The outcomeRequests fall through the configured FALLBACK_MODELS list when a provider fails before output, and the session keeps going.

What you need first

  • 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

Steps

  1. 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.
  2. 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.
  3. Add the API keys for each provider in the list to .env.
  4. Run python -m my_free_code and send a test request from Claude Code or another client.
  5. Check the gateway output for a failover event before relying on the chain for real work.

Prompt for your agent

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.

Caveat. The README says fallback only applies before output is committed, so a stream that has already started will not switch providers.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for hkqr/my-free-code and "Keep agent sessions running when a provider fails"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer