frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

Show HN: Smart model routing directly in Claude, Codex and Cursor

https://github.com/workweave/router
46•adchurch•1h ago
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!

Comments

stpedgwdgfhgdd•1h 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?

adchurch•41m 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.

alansaber•28m ago
That is interesting, sounds like in practice you only end up routing between 2 models
adchurch•26m 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.
_pdp_•59m 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

adchurch•38m 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)

arendtio•54m ago
What is the difference from Cursors 'auto' mode?
adchurch•37m 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
ai_slop_hater•46m 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?
adchurch•33m 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).

debarshri•39m ago
It is funny. We are building something similar.
adchurch•31m 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 :)
spqw•38m 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

adchurch•23m 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
g00k•33m 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.
alansaber•28m ago
Yep this was always the reason to avoid "auto" mode in cursor.
adchurch•28m 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.

emilio_srg2•32m 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?
adchurch•29m 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_srg2•19m ago
I see but didn’t they severely limited the usage allowed with `claude -p`
adchurch•17m 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`.
alansaber•29m ago
"We reward the routing model when it selects an LLM that achieves the task successfully" sounds pretty oversimplified
adchurch•14m 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_io•27m ago
This is cool!

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

adchurch•25m 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
slopinthebag•23m 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.

suyash•22m ago
I would rather just use OpenCode - leverage AI models, even can host locally or paid ones with ease.
adchurch•18m 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

k9294•18m 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?
adchurch•12m 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
mkagenius•11m 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

iluvcommunism•9m ago
This is basically what I need, a router. I’m tired of changing intelligence & speed levels manually.

Malware Insights: macOS Phexia Campaign

https://cookie.engineer/weblog/articles/malware-insights-macos-phexia-campaign.html
1•speckx•2m ago•0 comments

Show HN: AgentBrush – Your coding agent's missing tool: image generation

https://agentbrush.dev/
1•Yan4300•3m ago•0 comments

Ventora Expands Its AI Business Builder to Help Solo Founders

1•emmanol•4m ago•0 comments

Wildfires Are Getting Worse. Patrick Moore Says Otherwise

https://www.notesfromtheroad.com/roam/patrick-moore-wildfires-climate-change.html
1•speckx•9m ago•0 comments

Neural Image Compression with Gemini 3

https://bertolami.com/blog/cascade-neural-image-compression
3•wholenote•10m ago•0 comments

Show HN: I built a hardware quantum RNG and wired it into a Magic 8-Ball

https://dnhkng.github.io/posts/building-the-beam-universe-splitter/
3•dnhkng•10m ago•0 comments

How to Corrupt an SQLite Database File

https://www.sqlite.org/howtocorrupt.html
1•tosh•10m ago•0 comments

Chinese LineShine Supercomputer Debuts at No. 1 in TOP500

https://www.top500.org/news/lineshine-debuts-no-1-top500-enters-new-global-exascale-era/
1•adrian_b•12m ago•1 comments

Pre-Modern Armies for Worldbuilders, Part III: Paying for It

https://acoup.blog/2026/06/26/collections-pre-modern-armies-for-worldbuilders-part-iii-paying-for...
3•jfoucher•12m ago•0 comments

How to Tell We–and AI–Are Choosing the Good

https://deepsub.substack.com/p/how-to-tell-weand-aiare-choosing
1•dsubburam•12m ago•0 comments

Commander's Intent Statement

https://www.votito.com/methods/commanders-intent-statement/
1•adzicg•14m ago•0 comments

Show HN: JSON Viewer Extension for Chrome

https://chromewebstore.google.com/detail/json-viewer-formatter-for/adnplidpgphcdjnebagdiknfjeedhfjp
1•chernikovalexey•14m ago•0 comments

I'm building a Space Cadet Pinball Machine! [video]

https://www.youtube.com/watch?v=lHQ8c8i42VE
2•skibz•15m ago•0 comments

Bigger context windows are the wrong abstraction for coding agents

https://sigilix.ai/blog/bigger-context-windows-are-the-wrong-abstraction-for-coding-agents
2•damartj•15m ago•0 comments

Show HN: No one will beat my hiscore

https://puremint.co.uk/games/git-racer/
1•wonkyfruit•16m ago•0 comments

Webradio server – broadcasts audio source to clients

https://github.com/tau-org/tau-tower
2•modinfo•19m ago•0 comments

Hasp – Local Secret Broker

https://gethasp.com/
1•casca•20m ago•0 comments

Scaling Laws, Carefully

https://lilianweng.github.io/posts/2026-06-24-scaling-laws/
1•tehnub•20m ago•0 comments

Anthropic has hired an economist with interesting views on human survival

https://www.ft.com/content/bb04671c-4377-4231-96ef-0f8e57ed5d1b
1•Jimmc414•20m ago•2 comments

Open Air Chicago

https://www.chicago.gov/city/en/depts/cdph/supp_info/Environment/open-air-chicago.html
1•toomuchtodo•22m ago•1 comments

Human-bench: an eval for "human shaped" agents

https://www.human-bench.com/leaderboard
1•jam0xb797fd•26m ago•1 comments

Andromachi Papanikolaou

https://en.wikipedia.org/wiki/Andromachi_Papanikolaou
2•thunderbong•27m ago•0 comments

Show HN: Free IP API – Free, Fast and Reliable IP Geolocation API

https://freeipapi.com
2•543310•29m ago•0 comments

ActPlane: Programmable OS-Level Policy Enforcement for Agent Harnesses

https://arxiv.org/abs/2606.25189
1•matt_d•29m ago•0 comments

The Discoverable Evidence of AI-Assisted Software Porting

https://williamcotton.com/articles/the-discoverable-evidence-of-ai-assisted-software-porting
1•williamcotton•29m ago•0 comments

Stairwell in C# with Ultracontrapipe in a [video]

https://www.youtube.com/watch?v=23G5QDWqDUY
1•gregsadetsky•29m ago•0 comments

Show HN: A map of every UK railway, including stations that no longer exist

https://trainmap.co.uk/map.html
2•optionalltd•31m ago•0 comments

Please don't use an LLM to communicate with other human beings

https://florio.dev/dont-use-llm-communication/
5•speckx•32m ago•4 comments

Show HN: Vantage – Enrich your calendar invites with LinkedIn profile data

https://vantage.neuron.com
4•ramoq•33m ago•3 comments

Wirecutter Headlines During the Revolutionary War

https://www.mcsweeneys.net/articles/wirecutter-headlines-during-the-revolutionary-war
1•ohjeez•33m ago•0 comments