Back to News
Advertisement
aadchurch about 3 hours ago 53 commentsRead Article on github.com

ES version is available. Content is displayed in original English for accuracy.

We built a model router that plugs into coding agents (e.g. Claude Code, Codex, Cursor, etc.) and intelligently sends requests to the best model to serve them. Here's a quick demo of running it locally: https://www.youtube.com/watch?v=isKhAyivtfM.

At Weave, we write most of our code with AI, and it's been getting more expensive. This came to a head when Opus 4.7 was released and, thanks to its tokenizer changes, our costs shot up. We knew we didn't need Opus for everything but we didn't want to lose out on the intelligence for the cases where you really need it. So we decided to build a model router to handle this for us.

The Weave Router acts as an Anthropic/OpenAI endpoint specifically for coding agents. It looks at every inference request and intelligently (more on that in a sec) decides what model to send it to, handling all the translations required along the way. So it can use faster/cheaper models (e.g. DeepSeek v4, GLM 5.2, Kimi K2.6) when possible, and frontier models (Opus 4.8 & GPT 5.5 (& Fable whenever it's back)) when necessary.

How do we know what model to route to? We trained an RL model on tens of thousands (so far!) of agent traces. We reward the routing model when it selects an LLM that successfully completes the given task.

Here's an example: if you ask the router to plan a complex change, it will (probably) route that request to Opus 4.8. Subagents exploring the codebase to gather context will be routed to more suitable models (e.g. DeepSeek V4 Flash). Then when you have the plan ready to implement, it will be (most likely) be handed to a quicker model (e.g. GLM 5.2) to carry it out.

We've been using this internally for the last month or so. We've saved 40% on tokens vs. what we otherwise would have paid, with no noticeable differences in quality or velocity.

The router is source-available under Elastic License 2.0, so you can self-host it. Or if you prefer, you can also use our hosted version: weaverouter.com.

I'll be here to answer any questions you may have!

Advertisement

⚡ Community Insights

Discussion Sentiment

73% Positive

Analyzed from 1725 words in the discussion.

Trending Topics

#model#cache#models#claude#more#routing#using#usage#router#another

Discussion (53 Comments)Read Original on HackerNews

jakozaurabout 1 hour ago
It's rather hard to do at the proxy level with agentic coding, such as Claude Code or similar. These are long-chained sessions of tool use that heavily rely on prompt caching. Changing mid-flight is costly.

It looks like much more context is required to decide on the best model (e.g., summarizing logs might use a cheap model, whereas you likely want Opus/Mythos/GPT 5.6 to debug multithreading logic). In an agentic system, a decision about the model may be embedded in the decision to orchestrate the model.

adchurch40 minutes ago
Yep cache awareness is super important, mentioned this in another thread here: (https://news.ycombinator.com/item?id=48689448)

But intuitively I think it makes sense that a model can learn what model to route things to if it has all the relevant info, and experimentally it works pretty well in our experience

GodelNumbering23 minutes ago
This would not work in the way that shows any significant genuine benefit IMO. Caching and optimum routing of a single request are at odds with each other. Higher the distinct model count in a conversation, more cache misses you accept.

Based on what OP said elsewhere in the discussion "threshold to switch to another model will be higher" means that essentially you reduce the workflow into two models at most. The two model primitive, one planner and one executor, is already sufficient for such a use case.

For lower than 2 models, it's just a simple single model cache-preserving conversation which arguably doesn't need another layer. For larger than 2 models, you are likely paying a large aggregate cache penalty that negates most of the gains

adchurch18 minutes ago
When we started building this we did it as an experiment and we thought the same thing might be true (cache misses would make the whole thing pointless). This turned out not to be true! I think there are 3 reasons intuitively:

1. Small models can carry out a good number of requests e2e 2. Small model for part of a request + cache miss < big model for entire request in many cases 3. Subagents

For our own usage we've saved 40% so far (that is of course including costs of uncached requests when switching models)

GodelNumbering6 minutes ago
This assumes a perfect problem routing though. Determining the complexity class of an arbitrary problem is generally undecidable or extremely hard (Rice's theorem implication). So, in real use cases, you need to amortize all cases where the problem got routed to the wrong model and recovery had to be performed)

For example, if my task was "refactor this component to decouple all messy nesting", the problem router can't possibly know what is being referred to. This works for clear cut and dry problems but not for ambiguous problems. Most of the real world problems carry a lot of ambiguity.

g00kabout 2 hours ago
Man, I'm not so sure if I'd use something like this because the way I prompt already changes based upon what model I am using. I'm not convinced it would route to the right model based on my diction or whatever.
adchurchabout 2 hours ago
Yeah that's a really interesting point, tbh I think the more relevant variable here is the harness you're using rather than the specific model? i.e. GPT 5.5 in the Claude harness behaves a lot more like Claude than Codex if that makes sense.

Hard to quantify this ofc but that's what I've felt vibes wise from using this for the last month.

devmor25 minutes ago
I have the same general feeling as well. Like you, I can’t prove it’s not just personal feeling - but e.x. Opus via Copilot CLI behaves entirely different than Opus via Claude Code, which behaves differently than Opus via OpenCode or Pi.
alansaberabout 2 hours ago
Yep this was always the reason to avoid "auto" mode in cursor.
stpedgwdgfhgddabout 2 hours ago
The thing I do not get with these routers is that you will have more cache misses (5min ttl). And if there is one thing i’ve learned; using the cache is crucial.

How does this router translate to $$$ when developing?

adchurchabout 2 hours ago
You're right and that's why we built the router to be cache aware! Once it starts using one model, the threshold to switch to another model will be higher because the additional cost of the cache miss needs to be worth the cost savings or quality increase.

This is the key thing that other routers we've seen miss: they're stateless so for a coding agent use case you end up spending more money due to all the cache misses.

alansaberabout 2 hours ago
That is interesting, sounds like in practice you only end up routing between 2 models
echelonabout 1 hour ago
Or not routing at all.

In practice you just pick one and stick with it until the API stops or you hit performance issues.

adchurchabout 1 hour ago
I'd say that a typical main agent loop has 1-3 models (obviously very situationally dependent), but when you have subagents those can get routed independently since they have a fresh context window, so there are a lot more degrees of freedom there.
mthoms40 minutes ago
This is a key point. I don't know if you can still edit your submission, but I think this would be helpful to mention up front. I'm looking forward to testing this.
peterbell_nycabout 1 hour ago
I auto tune my prompts to a locked model version based on production data used as evals with holdback data. I think the use case for this would be one off interactive prompts? For now I just run those all against an Opus 4.8 MAX and I'm sure I could downtune, although for interactive my opening prompt isn't always reflective of my overall goals for the multi turn session.

I'm just trying to figure out why on the fly routing would beat testing and tuning and locking models and versions for each class of call, with evals and auto tunes running to explore more possible models for commonly run classes of prompt over time . . .

reliablereason22 minutes ago
Wont this kill the kv cache?

Also i am pretty sure neither open ai or anthropic leets you seed the agents own tokens.

adchurch17 minutes ago
Very important consideration, addressed it in another thread (https://news.ycombinator.com/item?id=48689448). tl;dr we built this to be cache aware for exactly this reason
spqwabout 2 hours ago
This + making sure common requests are saved as reusable skills and scripts would probably save a large part of my token usage

As prices increase we will see more of these tools to optimise and make the best use of token budget

adchurchabout 1 hour ago
100%, from what we've seen, for a lot of big companies that 1. don't have subsidized usage and 2. are pushing AI adoption hard, figuring out token costs is P0 or P1 for their eng leadership
SoftTalkerabout 1 hour ago
So you're saying that since adopting AI/LLM tech many companies have their top engineering priority being optimizing the costs of that rather than ... addressing actual business needs?
adchurch43 minutes ago
I guess delivering business value is always #1, I just meant it's the biggest problem they're trying to solve. Here's a recent example that was public: https://fortune.com/2026/05/26/uber-coo-ai-spending-tokens-c...
k9294about 1 hour ago
What about request caching? If you swap to a cheaper model mid execution it might cost more that to make multiple requests to the already cached provider?
adchurchabout 1 hour ago
Yep 100%, mentioned this in another thread (https://news.ycombinator.com/item?id=48689448) but tl;dr we build the router to be cache aware
alansaberabout 2 hours ago
"We reward the routing model when it selects an LLM that achieves the task successfully" sounds pretty oversimplified
adchurchabout 1 hour ago
Indeed it is :) I skipped over talking about all the RL machinery, network design, reward function design, state representations, etc. because really the intuition is that we tell the model when it accomplishes its goal, and then it learns over time how to get better at making the right decisions in order to accomplish its goal.

Happy to talk about this in some more depth if there's anything specific you're curious about!

gautam_ioabout 2 hours ago
This is cool!

Will this use my Claude Pro/Max subscription? Or will it always use the API billing "pay as you go"?

adchurchabout 1 hour ago
Yep it uses the Claude sub if possible and falls back to API billing only if you don't have a Claude sub or it's out of usage! Same deal for Codex
suyashabout 1 hour ago
I would rather just use OpenCode - leverage AI models, even can host locally or paid ones with ease.
adchurchabout 1 hour ago
We integrate with OpenCode too! OpenCode provides the harness, then the router selects the right model for the task.

We haven't yet set up local model routing though, that's really interesting - have you had any success using local models for coding tasks? Tbh I haven't heard many success stories from using local models yet

Advertisement
_pdp_about 2 hours ago
Cool.. but I still don't get how this is going to save money. It seems to me that it might actually burn more money just because the whole system now seems to be coming from different LLMs.

Also, small LLMs are prone to stop before completion, throw errors and produce loops. Is this factored in the design of the tool? I am not sure.

edit: spellcheck

adchurchabout 2 hours ago
It saves money because some agent sessions can be entirely handled by a smaller model (also relevant: subagents use fresh context windows so a subagent with a simple task can be routed to a smaller model even if the main agent needs a frontier model).

Totally right about small LLMs btw, that's why we trained this on real agent sessions where we forced it to use different models. If the routing model sees small models can't handle a certain type of task then they won't be assigned. (Also as a fallback we have some guardrails that will have a bigger model come in to "rescue" a smaller model if it gets stuck)

arendtioabout 2 hours ago
What is the difference from Cursors 'auto' mode?
adchurchabout 2 hours ago
Fun fact: Cursor's "auto" mode is just Composer (or at least it was last time I checked). So it's different in the sense that it actually does route to more than 1 model
debarshriabout 2 hours ago
It is funny. We are building something similar.
adchurchabout 2 hours ago
Oh cool, feel free to reach out to me at andrew@workweave.ai if you ever want to share notes! We've learned a lot in the process of building this so far :)
mkageniusabout 1 hour ago
We have created Murmur[1] which kind of works with your existing subscription (having API key is not mandatory). You can just tag @copilot @codex from claude code to delegate work to them. (it can also do it on its own too btw)

1. https://github.com/instavm/murmur - Murmur

adchurchabout 1 hour ago
Very interesting - curious how you've used it yourself so far? I can imagine one use case would be having e.g. GPT 5.5 review Opus 4.8's work?
mkagenius28 minutes ago
Useful in splitting a big task - some parts are easy so give it to say Gemini. Some are harder so give it to gpt 5.5 and so on.

Also the throughput kind of increases since providers are different.

emilio_srg2about 2 hours ago
but this means you work with API pricing rather than subscription pricing. Isn’t it better to use claude or codex CLI etc directly in terms of cost?
adchurchabout 2 hours ago
If you have a Claude/Codex subscription then we use that (and account for the subsidized price accordingly when making routing decisions) instead of API billing. So you get the best of both worlds: subsidized usage for frontier models + save by using open/smaller models when it's genuinely better.

In practice, lots of ppl are using this to make their Claude sub limits go further!

emilio_srg2about 1 hour ago
I see but didn’t they severely limited the usage allowed with `claude -p`
adchurchabout 1 hour ago
But we're not routing via `claude -p`, if you have sub usage available + it's the right choice to route to a Claude model, then the router is approximately a transparent passthrough. So it gets billed like normal `claude` usage rather than `claude -p`.
slopinthebagabout 1 hour ago
> At Weave, we write ~all our code with AI

This is probably not a very effective way of marketing imo. At least, it turns me completely off.

adchurch32 minutes ago
Fair enough, not meant to be marketing just a statement of fact. Would have turned me off too 18 months ago but times change...
ai_slop_haterabout 2 hours ago
Isn't this more expensive than always using the same model, since, as I understand, by routing to different models you give up on cache?
adchurchabout 2 hours ago
If you statelessly route each new request: yes it does end up being more expensive!

So our routing is cache-aware. It will have a much higher threshold to switch from one model to another if there's already some cache for the first model. Experimentally this solves the problem (like I said we've saved 40% ourselves vs. what we would have otherwise paid).

iluvcommunismabout 1 hour ago
This is basically what I need, a router. I’m tired of changing intelligence & speed levels manually.
adchurchabout 1 hour ago
Nice, let me know any feedback you have from trying it out!
bijowo1676about 1 hour ago
How come data privacy and confidentiality is not an issue with services like these?

Do people voluntarily use these proxies/routers, knowing their prompts, outputs and code will be seen by other people ?

I get it might be ok for personal projects, but for anything that makes money and is a part of business... this must be big no-no ?

victorbjorklund43 minutes ago
It is a router that runs locally.
adchurch34 minutes ago
It's a real concern! We take this stuff super seriously (https://trust.mycroft.io/weave) and tbh most of our customers opt for the hosted version because it's much simpler on their end + they're already trusting us with a bunch of sensitive data.

But of course since the source is available you can also run it locally or self host