The world is constantly evolving, and the rate of advancement in large language models is accelerating at an unprecedented pace. The average time between model updates has shrunk from 38 days in 2023 to just 8 days in 2026.[2] SWE-bench scores have climbed from 43% to 71% accuracy.[1] New harnesses and approaches ship all the time.
At that rate of innovation it stands to reason that the best approach is simply to always use the most recent model. Sometimes that is true. At scale, it is a trap.
What follows is an article-length version of the talk given at LLM Day NYC 2026. Watch the recording below.
The trap of the frontier
Gartner predicts that by the end of 2027, 40% of agentic projects will be canceled.[4] McKinsey’s 2026 State of AI survey found that 93% of enterprises are exceeding their budgets.[3] A Fortanix survey of regulated industries found that 59% of AI projects are being delayed due to security risks or concerns. One key trend runs through all of it: to actually deploy a solution to production, you have to think about cost, privacy, and access.
- Cost. While token costs have been coming down, the amount of tokens burnt and the complexity of workflows still result in significant costs to run them. Without proper monitoring these can easily outweigh the return on investment. It is important that you understand both the cost of your workload and the return. Saving on tokens brings the whole cost down and can be the difference between a successful project and a failed one.
- Privacy and sovereignty. The frontier is powerful, but it also means you are dependent on a third party to process your data. In some industries and spaces this creates significant compliance and operational risk — being able to own and control where your data lives and what processes it becomes imperative.
- Connectivity and latency. Some edge-deployed scenarios require local processing or have limited internet (think of an airplane). Relying on fully cloud-hosted solutions, which frontier models demand, can be a challenge.
An alternative
The good news is that frontier models are not the only thing in our toolbox for building modern generative solutions. Small language models (SLMs) and open-weight models are rapidly advancing in ways that make them work for a large majority of the tasks generative AI can automate. Historically these models lagged in accuracy or performance, or required so much hardware that they were not feasible. Recent advancements have changed that: accuracy lags have gone from 12 months to about 4 months,[1] issues with tool calls have been largely resolved, and new classes of consumer-grade hardware can run some powerful models. Between improvements in quality, distillation, and hardware, running an open-weight model or SLM is now a serious contender for production workloads.
How do we optimize?
Knowing we have several tools, the pragmatic question becomes: how do we start to optimize and build more cost-effective and performant solutions? To achieve this we apply a several-tier framework:
- Foundational — observability, evaluations, and benchmarks. Know what you want your agents to do, and how well they do it.
- Optimize the frontier. Tool-call management, compaction, and caching can dramatically improve performance and reduce costs at the frontier and beyond.
- Dynamic routing. Route between different sized models.
- Local models. Leverage local models where it makes sense.
- Fine-tuning. Fine-tune custom models for your specific domain needs.
Foundational — observability, evaluations, and benchmarks
In order to optimize something, you must understand what you are optimizing. Core to all software is having a clear framework and the capability to understand what your agents did, how well they did it, how changes affect performance, and finally how to know whether a change is good or bad.
- Observability. Understand and capture what the agent did, what model was used, and how it behaved — specifically metrics like turns, tool calls, accuracy, costs, and token spend or cache hits.
- Evaluations. Create golden sets of data that represent desired inputs and outputs.
- Benchmarks. Run evals through different harnesses and models to understand impact and determine the best current solution against accuracy, cost, speed, and complexity.
At ReFwd we actively leverage this model both to optimize our solutions and to generate code, balancing accuracy and performance. To improve our coding agents and tools we use our agent runtime Spens to capture harness and code data, send that to Langfuse for observability, and then create benchmarks derived from a BaxBench approach of accuracy and security. That gives us the ability to understand how well new models perform on which tasks, so we can optimize our workflow.
Improving the frontier — and everything else
The first set of improvements works for frontier models as well as for everything else. This is just improving the way you invoke LLMs to improve performance and reduce costs.
Technique 1 — cache hits
LLM inference is able to reduce cost by caching the internal state of the model during inference. Since LLMs are feedforward, every request has to feed each token in; the cache stores the internal state at a token and resumes from there, avoiding recomputation of the cached tokens on each turn. This means that moving variable data further down the history and keeping more static data first greatly improves the performance of LLMs. Recent studies have shown that, by leveraging caching correctly, you can reduce cost by up to 90% and improve performance by 85%.[7][8][9] It is important to note, though, that caches are not permanent — if you have tasks with long periods between inferences you may not see as large a gain, since the cache will invalidate.
Technique 2 — bulk processing
This one is fairly straightforward: for tasks that do not need real-time responses, consider using batch or bulk APIs. Token savings can be upwards of 50%.[5][10][11]
Technique 3 — dynamic tool calling
As your agent does more things and interacts with more services, the number of tool calls sent in context can grow — especially if you are using MCP for access to services. As this grows, accuracy and confusion can increase and costs go up, because there are more tool calls to process. For instance, the GitHub MCP endpoint can add upwards of 65,000 tokens to a call.
To reduce this context hit and improve tool selection, it can make sense for some workloads to add a filter step before the LLM invocation that reduces the tool calls sent to the model. There are several techniques that can achieve this:
Applying these techniques has shown that you can have up to 85% fewer tool tokens and +25 points in accuracy.[6]
Technique 4 — dynamic compaction
Relatedly, as your agent does more and more things, your context grows. As context grows, performance decreases — especially with smaller and flash models. For example, we have routinely seen deepseek-flash on large context get stuck in “hmm” and “let’s go” loops in its thinking. To avoid these challenges and reduce the amount of information you send to the agent, there are several things you can do to improve the context:
- Compact at checkpoints, where the agent has a tangible result, or in sliding windows.
- Dynamically select what context gets sent. This may hurt your cache hits, but it can greatly improve performance and reduce context size considerably.
Applying context techniques can reduce cost by upwards of 60% and improve accuracy.[12][13]
Dynamic routing — picking the right models for the right task
Now that we have some techniques to improve how much data we send to the LLM, the next step is to figure out which LLM, or agent, gets what requests and tasks. This is what dynamic routing is, and it works by evaluating the request and routing it to the best model for the job. It also lets you mix the various strengths of different model classes to create more powerful combined systems.
There are three major ways you can rationalize and implement routing.
Intent classification
This is the most obvious approach: look at what the user wants to do, match it to a task, and send it to the appropriate LLM or sub-agent. Several routing strategies can be employed:
- LLM as a judge. Have the LLM look at the request and determine the route.
- A classifier. If you have a good amount of data, you can generate a classifier to determine what to route to.
- Embedding models. Similar to tool calls, use embedding models to match requests to like requests and route.
- A System 1 model like Jev — also similar to tool calls.
Delegation / orchestration routing
This is where a parent agent, model, or system delegates a workload to a smaller model or agent. This is largely your planned or orchestration-style workflow: a planner breaks a task into parts and hands each part to a worker.
Escalation routing
This is the inverse of the delegation model: start with a smaller model, then either enable it to self-escalate, or watch metrics like tool-call errors, confused language, or loops and use those to escalate the call to a larger model.
A real-world example — delegation of Opus 5.5 and Qwen 3.8 27B outperforms either
Dynamic routing can be a powerful tool, because it also enables different model families to complement each other. As mentioned earlier, at ReFwd we actively evaluate coding models and different techniques. In a recent benchmark we discovered that a planner–sub-agent approach won with Opus 5.5 and Qwen 3.8 27B.
| Opus 5.5 | Qwen 3.8 27B | Hybrid model | |
|---|---|---|---|
| Completion | 0.90 | 0.84 | 0.95 |
| Security | 0.68 | 0.64 | 0.75 |
| Insecure | 25% | 24% | 21% |
| Cost | ~$15.23 | $9.15 | $12.04 |
Based on an internal, heavily modified BaxBench across Python [FastAPI, Flask] and JavaScript [Express, Koa] on the pi agent running in a Spens sandbox, over a horizon of 40 tasks with 3 samples each. Test ran October 26th.
Local models / hosting your own model
Moving up the complexity level, the next tier is hosting and running your own local models. This is not necessarily a cost reduction — cost shifts from tokens to hardware and maintenance — but it may be important for highly sensitive workflows, or where you want to distribute workloads across devices (think home assistant). There are challenges with local models, beyond hosting them, which is an article in its own right. Luckily, over the past several years techniques have emerged to mitigate them.
| Challenge | Approach | Result |
|---|---|---|
| Tool calls do not produce the right format | Constrained decoding | 100% adherence in format[14] |
| Not enough context | Leverage foundational techniques to reduce context and tools | 13.6% → 43.1% tool selection, ~50% fewer prompt tokens (RAG-MCP)[15] |
| Multi-turn drift | Agentic trajectory fine-tuning + environment guardrails | An 8B model hits 46.7% on τ-bench[16] |
Sources: Ubicloud, “Fixing Tool-Call Accuracy in vLLM”; RAG-MCP (arXiv 2505.03275); APIGen-MT / xLAM-2 (arXiv 2504.03601).
Case study: a local home assistant
In one of our roles we had to prototype a local home assistant to determine the accuracy feasibility of such a product. Our setup was a Jetson AGX (64 GB) running a Liquid AI model (LFM-2-24B-A2B) with Whisper for STT and a PII model (ai4privacy/llama-ai4privacy-multilingual-categorical-anonymiser-openpii). Leveraging context compaction and embedding-based tool selection with a CFG deployed on llama.cpp, we found that we had:
- 100% tool-call format adherence.
- PII redaction and sub-agent tool calling worked for all 427 of our test cases.
- Accuracy of the local agent was around 94% on our test cases, versus 98% for Sonnet 3.7.
Fine-tuned specialists
Finally, the most complex approach is fine-tuning specialist models. This requires a clear understanding of the tasks you want to achieve, and the ability to measure them. There are generally two approaches to fine-tuning.
Task-specific fine-tuning
This approach takes golden example data sets and fine-tunes against those samples. There are several ways to fine-tune, but most people start with LoRA / QLoRA (low-rank adaptation) or with reinforcement learning like GRPO. For more information on fine-tuning, see Unsloth.
Fine-tuning small, focused models can drastically improve performance. A recent paper, Domain-Adapted SLMs with Hybrid Post-Processing, took labeled data sets for routing in finance and was able to drastically improve performance. Based on 219 samples, and training only 2% of the weights of a Llama 3.1 8B model, it outperformed GPT-4o at 46–76% lower cost.[17]
Fine-tuning via student–teacher / distillation
Another approach to fine-tuning is distillation. Here a larger model that is already able to perform the task generates data to create training data for a fine-tuned smaller model. In effect, you replace the creation of a labeled training set with a teacher model. For a walkthrough, see this distillation example.
What can go wrong
We have covered several approaches and categories for improving performance and leveraging smaller models. It is important to note, however, that there are several gotchas that can derail these efforts:
- Cheaper per turn, 10× the turns. Smaller models are cheaper per turn, but they can take ten times as many turns in agentic workloads. Monitoring is key to understanding actual savings.
- Bad evals, bad UX. Without good evaluations and benchmarks, swapping models can negatively impact the experience.
- Hosting is complicated. Hosting your own model is complicated, and there are hidden costs around maintenance and monitoring.
In conclusion — only leveraging the frontier is a design flaw
| Foundational improvement | Dynamic routing | Local | Fine-tuned models | |
|---|---|---|---|---|
| Tactics | Cache optimization, batch processing, tool-call cleanup, context compaction | Intent routing, delegation routing, escalation routing | Constrained decoding, tool-call cleanup, context management | Task-specific FT and student–teacher |
| Good when | Always | You have clear benchmarks you can evaluate | You care about data privacy or distributed costs | You have narrow, specific tasks and good evals and benchmarks |
Powering all of this: evals, observability, and benchmarking.
Hopefully this article has shown that there are several approaches and techniques that both improve performance and reduce cost. Defaulting to, and staying with, a large frontier model is convenient — but it clearly cannot be the right approach. By understanding your tasks, benchmarking, and applying various strategies, you can achieve the right balance of cost, speed, and accuracy.
So next time you reach for Fable or Astra, remember: frontier by default is a design flaw.
Need help?
Need help deploying your own local models or scaling agentic workloads securely? Reach out to us at ReFwd — chat@refwd.ai.
References / further reading
- Stanford HAI. AI Index Report 2026. Stanford University, April 2026. — hai.stanford.edu/ai-index/2026-ai-index-report
- Segreto, Anthony. “The Release Clock.” Substack, 2026. — anthonysegreto.substack.com/p/the-release-clock
- McKinsey & Company (QuantumBlack). Enterprise AI FinOps Survey, May 2026; State of AI: Global Survey 2026. — mckinsey.com/capabilities/quantumblack/our-insights/the-state-of-ai
- Gartner, Inc. “Gartner Predicts Over 40% of Agentic AI Projects Will Be Canceled by End of 2027.” Press release, June 25, 2025. — gartner.com/en/newsroom/press-releases
- Anthropic. “Introducing the Message Batches API.” October 8, 2024. — anthropic.com/news/message-batches-api
- Anthropic Engineering. “Introducing Advanced Tool Use on the Claude Developer Platform.” November 2025. — anthropic.com/research/advanced-tool-use
- Plushcap (Matt Makai). “Prompt Caching with Claude.” August 14, 2024. — plushcap.com/content/anthropic/blog/anthropic-prompt-caching
- IntuitionLabs (Adrien Laurent). “LLM Prompt Caching: Cost Savings, Invalidation & Workload Design.” September 5, 2026. — intuitionlabs.ai/articles/llm-prompt-caching-cost-savings
- Introl. “Prompt Caching Infrastructure: LLM Cost & Latency Reduction Guide.” 2025. — introl.com/blog
- Willison, Simon. “Anthropic: Message Batches (beta).” October 8, 2024. — simonwillison.net/2024/Oct/8/anthropic-batch-mode
- Respan. “Anthropic Message Batches API: 50% Off Async Jobs.” 2026. — respan.ai/articles/anthropic-message-batches-api
- Blockchain.News (Ted Hisokawa). “Anthropic Enhances Claude Platform with Advanced Context Management Tools.” September 29, 2025. — blockchain.news
- Breeze in Busan (Tech Desk). “The Next Bottleneck in AI Coding Isn’t Code. It’s Context.” 2026. — breezeinflow.com
- Ubicloud. “Fixing Tool-Call Accuracy in vLLM.” Engineering blog, 2026. — ubicloud.com/blog/fixing-tool-call-accuracy-in-vllm
- Gan, T. & Sun, Q. “RAG-MCP: Mitigating Prompt Bloat in LLM Tool Selection via Retrieval-Augmented Generation.” arXiv:2505.03275, May 2025. — arxiv.org/abs/2505.03275
- Prabhakar, A., Liu, Z., Zhu, M., et al. “APIGen-MT: Agentic Pipeline for Multi-Turn Data Generation via Simulated Agent-Human Interplay.” arXiv:2504.03601, April 2025. — arxiv.org/abs/2504.03601
- “Domain-Adapted Small Language Models with Hybrid Post-Processing.” arXiv:2606.05781, June 2026. — arxiv.org/abs/2606.05781
