MemoryLake
Back to all articles
NewsAugust 5, 2026·9 min read

How to Switch Between AI Models Without Losing Your Context (2026)

Switching the model behind your coding agent used to be a weekend project. As of this week it's a command.

On August 4, 2026, OpenRouter shipped `ori`, a CLI that installs with a single line and gives Claude Code, Codex, OpenCode, and Hermes an optimized configuration out of the box. The same day, Google Cloud put unified model routing into public preview on API Gateway, so a virtual model name can be mapped to a backend and OpenAI-compatible requests get transcoded automatically. Between the two, the friction that used to keep teams on one model is mostly gone.

What hasn't changed: the model is the only thing that moves. Your project context stays behind. Swap the backend and you have handed the same repository to someone who has never seen it — competent, fast, and starting from nothing. This guide explains why that happens, what people do about it, and how to make context the one thing that doesn't reset when you change models.

What shipped, and what it actually enables

ori installs with curl -fsSL https://openrouter.ai/labs/ori/install.sh | bash. You log in with OpenRouter credentials and run your harness through it. OpenRouter is candid about the problem it solves: "When using a gateway like OpenRouter, to get the same out-of-the-box experience with Claude Code as you get using Anthropic's first-party harness, there's a lot of environment variables you need to set." The CLI also adapts to what you're running — "In ori claude, we detect your --model flag and switch the settings to be most optimal for the model you're using."

Alongside it, OpenRouter's Claude Code cookbook documents redirecting the CLI to an Anthropic-compatible endpoint with three environment variables. Once that's in place you can keep using Claude models billed through credits, or replace the Opus, Sonnet, and Haiku "slots" with cheaper open models — GLM-5.2, DeepSeek V4, Qwen3-Coder, Kimi.

Google's gateway approach targets the same behaviour from the infrastructure side: configure virtual model names in an OpenAPI 3.x spec, point them at backends including Gemini, Claude, and OpenAI's OSS-GPT models, and route traffic without hardcoding endpoints or running your own proxy.

Pricing is pushing in the same direction. OpenAI's own team has publicly said the 80% price cut on GPT-5.6 Luna is permanent rather than promotional, and industry analysis in the same week noted it landed days after Anthropic's Fable 5 arrived at $50 per million output tokens. Treat the specific numbers as of early August 2026 and check current pricing before you plan around them — but the direction is not in doubt: model choice is becoming a per-task decision, and the tooling now assumes you'll make it often.

Why switching models resets your context

Models don't carry state between calls

Every request is self-contained. Whatever the model appears to "know" about your project arrived in that request's context window and leaves with it. Cursor's own documentation states the general case plainly: "Large language models don't retain memory between completions." Nothing about routing changes that — a gateway forwards requests, it doesn't accumulate knowledge.

Each vendor's memory features are theirs alone

The tools you use have real memory features now, and they're genuinely useful. They're also each locked to their own product: Claude's memory entries, ChatGPT's synthesized cross-chat memory, Codex's local memory files, an IDE's rules directory. Route a request to a different backend and none of that follows, because it was never part of the request in the first place.

Your harness config is not your context

This is the mistake ori makes easy to make. When the environment variables, model slots, and reasoning settings are all handled for you, switching feels complete — the tool starts, the model responds, everything looks configured. What actually moved was the plumbing. The accumulated knowledge of your codebase, the decisions, the dead ends, the reason that one module looks wrong but must stay that way, moved nowhere.

Cheap models make the problem more visible, not less

The economic case for routing is real: send routine work to a cheap model, reserve the expensive one for hard problems. But a cheap model with no context produces work you have to correct, and correcting it costs the human time you were trying to save. The savings only materialize when the cheaper model starts with the same understanding the expensive one had.

What people try

Re-pasting the briefing. A block of project context at the top of every session. It works and it's universal, which is why almost everyone does it. It also costs tokens on every single call, and it's a summary — the specifics erode each time someone rewrites it shorter.

Instruction files. AGENTS.md, .cursor/rules, CLAUDE.md, .trae/rules. These are the right tool for rules that should always apply, and most harnesses read them regardless of which model is behind them, which makes them the most portable option available. They aren't a knowledge store: nobody wants to hand-maintain a 900-line preamble that grows every week, and rules loaded on every request are rules you pay for on every request.

Keeping one model for everything. The simplest fix — avoid switching. It also means paying premium rates for trivial work and not using the model that's actually best at a given task.

Per-tool memory features. Turn on memory everywhere and hope. You end up with several partial pictures that drift apart, and you find out they've diverged at the worst moment. This is the same failure that shows up whenever multiple agents work without shared memory.

Retrieval over the repo. Useful, and better than nothing. Retrieval finds text that resembles the query; it doesn't hold the decision you made in June or the approach you already rejected, which is why retrieval on its own isn't memory.

The Fix: Keep Context in a Layer the Router Can't Touch

If the model is now a swappable component, context has to stop living inside it. Put the knowledge in its own layer, and let whatever model you route to read from it — the same way ori lets whatever model you pick use the same harness.

MemoryLake is built for exactly that position in the stack: memory as its own layer, reachable over MCP or an API, independent of which model answered last time.

Step 1: Create an API key

Generate a key and make your first request in about 30 seconds.

Create a MemoryLake API key
Create a MemoryLake API key

Step 2: Upload your first memories

Load the material every model needs regardless of which one is on duty: architecture notes, API contracts, the decision log, runbooks, the conventions that aren't obvious from the code. Documents, images, and other files all go to the same place.

Upload your first memories to MemoryLake
Upload your first memories to MemoryLake

Step 3: Connect your AI & agents

Give Claude, Codex, OpenClaw, and other agents access over MCP. For anything you reach through a gateway rather than a native MCP client, retrieve the relevant memories through the API and include them in the request your router forwards. The route changes; what the model knows about your project doesn't.

Connect your AI and agents via MCP
Connect your AI and agents via MCP

What this changes in practice

The first effect is that routing decisions become purely economic. Right now, choosing a cheaper model has a hidden cost — the context re-establishment tax — which is why teams quietly stay on the expensive model even for work that doesn't need it. Remove that tax and "which model for this task" is answerable on price and capability alone, which is the premise the whole routing ecosystem is built on.

The second is that model releases stop being disruptive. There have been six or seven frontier releases worth switching to in the last few months. If evaluating a new one means rebuilding its understanding of your codebase, you evaluate it on toy problems and learn nothing useful. If context is shared, you point it at the same memory and get a real comparison in an afternoon.

The third is consistency across a mixed fleet. If a cheap model handles your test scaffolding and a frontier model handles architecture, they should be working from the same understanding of the system. Otherwise the cheap model's output contradicts the expensive model's design, and someone has to notice.

Best practices for a multi-model setup

Keep rules and knowledge in different places

Instruction files travel well between harnesses and models — use them for rules that must always apply. Put the growing body of project knowledge in a memory layer instead, so you're not paying for a giant preamble on every request and not hand-editing a file that changes weekly.

Write down why you routed, not just where

"Test generation goes to the cheap model" is a decision that gets silently reversed by whoever is on call at 2am. "Test generation goes to the cheap model because the frontier model's advantage there measured under 3% on our suite" survives, and it tells the next person what to re-measure.

Re-verify facts when you re-route

Model capabilities, context limits, and prices are moving monthly, and the specifics in this article are as of early August 2026. Before you commit a routing policy, check the current numbers at the source. The general lesson from every model switch so far — whether that was Opus 5, DeepSeek V4, or GPT-5.6 — is that the benchmark you care about is your own codebase.

Conclusion

The tooling caught up this week. ori makes running Claude Code, Codex, OpenCode, or Hermes against any model a one-line install, and gateway-level routing makes the same true at the infrastructure layer. Model choice is now a per-task decision, and the friction that made switching rare is mostly gone.

The thing that didn't get solved is the thing that matters most day to day. Models don't retain state between calls, per-vendor memory features don't cross vendors, and a perfectly configured harness still hands your repo to a stranger. Until project knowledge lives in a layer that sits outside the models you route between, every switch costs you the context you had — and the cheap model you switched to spends its savings on being wrong.

Frequently asked questions

Does switching AI models mean losing my chat history and memory?

Your history stays where it was created — in the tool that stores it. What you lose is the model's working understanding, because models don't retain state between calls and each vendor's memory feature is scoped to that vendor. A shared memory layer is what makes the context survive a switch.

What is the ori CLI and do I need it to switch models?

ori is OpenRouter's CLI, published August 4, 2026, that gives Claude Code, Codex, OpenCode, and Hermes an optimized OpenRouter configuration out of the box, and adapts settings to the model you pass via --model. You don't need it — the three-environment-variable route is documented too — but it removes most of the setup work.

Can I use cheaper models for routine work and keep quality up?

That's the main reason to route, and it works better when the cheap model starts with your project context rather than from zero. Without shared context, the corrections tend to eat the savings.

Do AGENTS.md and .cursor/rules solve this?

Partly, and they're the most portable option available since most harnesses read them regardless of model. They're built for rules, not for accumulated knowledge — a rules file that grows every week becomes a maintenance burden and a per-request cost.

Does a gateway like OpenRouter or Google Cloud API Gateway store my context?

No. A gateway routes and translates requests. It doesn't accumulate knowledge between them, so anything the model should know still has to be in the request or retrievable by the harness that builds it.

What's the fastest way to make context survive model switches?

Put it in a layer outside the models. Create an API key, upload the architecture notes, contracts, and decisions your work keeps referring back to, and connect your agents over MCP or the API. After that, switching backends changes cost and capability, not what the model knows about your codebase — which is also how you run one memory across several AI tools at once.