All Posts
AI Engineering July 11, 2026

Grok 4.5 vs Opus 4.8: Agentic Coding on SWE-Bench Pro and Terminal-Bench Tested (July 2026)

The headline is that Opus 4.8 wins SWE-Bench Pro and Grok 4.5 wins Terminal-Bench, but the score line is the least interesting part of this matchup. The number that should change how you route work is token efficiency: on the same SWE-Bench Pro tasks Grok 4.5 spent roughly a quarter of the output tokens Opus 4.8 did, at less than a third the output price. We break down where each model actually wins, why the benchmark split is real rather than noise, and how to think about cost per completed issue instead of leaderboard rank.

Grok 4.5 vs Opus 4.8: Agentic Coding on SWE-Bench Pro and Terminal-Bench Tested (July 2026)

If you run an agent that writes and fixes code all day, the question is not which model tops a leaderboard. It is which model closes more of your tickets per dollar, and the answer for Grok 4.5 versus Claude Opus 4.8 is genuinely split. One wins repository scale bug fixing, the other wins terminal driven agentic tasks, and the pricing gap between them is wide enough that the ranking on capability and the ranking on cost point at different models. Here are the reported numbers, then the reasoning that turns them into a routing decision.

Metric Grok 4.5 Opus 4.8
SWE-Bench Pro 64.7% 69.2%
Terminal-Bench 2.1 83.3% 78.9%
Avg output tokens per SWE-Bench Pro task ~15,954 ~67,020
Input price, per 1M tokens $2.00 $5.00
Output price, per 1M tokens $6.00 $25.00

Read the token row before the score rows. On the same SWE-Bench Pro suite where Opus 4.8 posts the higher pass rate, it also spent roughly 4.2 times the output tokens per task that Grok 4.5 did. Output tokens are the expensive half of an agent bill, and Grok prices them at less than a third of Opus. Multiply those two facts together and the cost per attempt gap is close to an order of magnitude, which is why the accuracy delta of a few points does not tell you who is cheaper to run.

The Benchmark Split Is Real, Not Noise

A four to five point swing in opposite directions on two coding benchmarks looks like variance until you look at what the benchmarks actually measure. SWE-Bench Pro asks a model to fix a real issue inside a large existing repository: read a sprawling codebase, localize the fault, and produce a patch that passes the hidden tests. It rewards deep code comprehension and the patience to trace a bug across many files. Opus 4.8 leading here, at 69.2 percent against Grok 4.5 at 64.7 percent, is consistent with its reputation for repository scale reasoning and its willingness to spend a lot of tokens exploring before it commits.

Terminal-Bench 2.1 measures something different. It scores a model acting as an agent in a shell: running commands, reading output, installing dependencies, recovering from errors, and driving a task to completion across many turns. That rewards fast, decisive tool use and tight loops more than it rewards long contemplative reasoning. Grok 4.5 winning here, at 83.3 percent against 78.9 percent, fits its design center of quick serving and low token spend per step.

So the split is not a coin flip. It is a signal about which kind of work each model is built for. If your agent mostly localizes and patches bugs in a mature codebase, Opus 4.8 has the edge on raw success. If your agent mostly drives a terminal, wiring up environments, running migrations, or orchestrating build and test loops, Grok 4.5 both wins the benchmark and costs far less to run. We saw a similar shape when we compared Sonnet 5 and Opus 4.8 on cost per issue, where the higher scoring model was not the cheaper one per closed ticket.

Why Token Efficiency Beats Pass Rate for Most Teams

The industry trained itself to read the pass rate column first because that is the number vendors put in the press release. For a team paying the bill, it is the wrong first screen. What you actually spend is a product of three things: the price per output token, the number of output tokens the model burns per attempt, and how many attempts it takes to close the issue.

Grok 4.5 wins two of those three decisively. At roughly 15,954 output tokens per SWE-Bench Pro task against about 67,020 for Opus 4.8, and at $6 per million output tokens against $25, its cost per attempt on this suite is dramatically lower. The one place Opus claws back is the third factor, attempts per closed issue, because a higher pass rate means fewer retries. Model that out honestly and the crossover depends entirely on your retry policy and how much a wrong patch costs you downstream.

def cost_per_closed_issue(pass_rate, out_tokens, out_price_per_m, in_tokens, in_price_per_m):
    # expected attempts to close one issue, assuming independent retries
    attempts = 1 / pass_rate
    per_attempt = (out_tokens * out_price_per_m + in_tokens * in_price_per_m) / 1_000_000
    return round(attempts * per_attempt, 4)

# illustrative input token counts for a repo-scale task
grok = cost_per_closed_issue(0.647, 15_954, 6.00, 40_000, 2.00)
opus = cost_per_closed_issue(0.692, 67_020, 25.00, 40_000, 5.00)
print("Grok 4.5:", grok, "Opus 4.8:", opus)

Run that with your own token counts, not the illustrative input figure above, and the pattern holds across a wide range: Grok 4.5 comes out several times cheaper per closed issue on this workload even after paying for its slightly higher retry rate, because the token spend and output price advantages are so large. The assumption that retries are independent is generous to neither model and real pipelines cap attempts, but the direction holds regardless of those details. Pass rate matters most when a wrong answer is expensive to catch, for example an unattended agent merging its own patches. When a human reviews every diff, the cheaper model that needs one extra try is usually the better economic choice.

Where Each Model Earns Its Place

Reach for Opus 4.8 when correctness on the first pass carries real cost. Autonomous refactors across a large repository, security sensitive changes, or any loop where a bad patch propagates before a human sees it are worth the premium and the extra tokens. Its edge on SWE-Bench Pro is a proxy for exactly that deep, multi file comprehension, and the willingness to spend tokens exploring is a feature when the task genuinely needs it. We covered its behavior against another Anthropic model on Terminal-Bench in the Opus 4.8 versus Fable 5 comparison.

Reach for Grok 4.5 when volume and iteration speed dominate. High throughput agent fleets, terminal driven automation, CI and build orchestration, and any workload where you run thousands of cheap attempts and gate them behind tests will get more done per dollar on Grok. Its Terminal-Bench lead plus its token frugality make it the default for the wide, fast, tool heavy end of the spectrum. This is a continuation of the trajectory we noted in the earlier Grok versus Opus 4.8 matchup, where the cost story kept widening in xAI's favor even as Anthropic held the quality crown.

The most sophisticated answer is not to pick one. Route terminal and orchestration steps to Grok 4.5, escalate to Opus 4.8 only for the deep localization and patch steps where its pass rate earns the token premium, and gate everything behind your own tests. A tiered agent that spends premium tokens only on the hard middle of a task, not on the whole loop, will beat a single model deployment on both cost and quality.

When This Applies to Your Stack

If you are building or scaling a coding agent, do not standardize on a model from a benchmark headline. Pull a sample of your real tickets, run both models against them, and measure the only number that matters: fully verified cost per closed issue, including retries and human review time. You will almost certainly find that the capability leader and the cost leader are different models, and that the right architecture routes cheap high volume steps to one and hard reasoning steps to the other.

If your team wants that routing, token budget, and escalation logic designed and implemented against your own codebase and ticket mix rather than a vendor's benchmark, Contra Collective builds AI integration and agent engineering that holds margin as it scales. The models will keep leapfrogging each other; the discipline of measuring cost per completed task on your own work is what survives every release.

FAQ

Is Grok 4.5 or Opus 4.8 better for coding? Neither wins outright. Opus 4.8 leads SWE-Bench Pro at 69.2 percent versus 64.7 percent, which measures repository scale bug fixing, while Grok 4.5 leads Terminal-Bench 2.1 at 83.3 percent versus 78.9 percent, which measures shell driven agentic tasks. Match the model to the shape of your work.

Why is Grok 4.5 so much cheaper to run? Two reasons compound. It prices output tokens at $6 per million against Opus 4.8 at $25, and on SWE-Bench Pro it used roughly 15,954 output tokens per task against about 67,020 for Opus, a 4.2 times gap. Lower price per token multiplied by fewer tokens per task produces a very large cost difference per attempt.

Does the higher pass rate make Opus 4.8 cheaper per closed issue? Only when retries are expensive. A higher pass rate means fewer attempts to close an issue, which offsets some of Grok's cost advantage, but the token and price gaps are large enough that Grok 4.5 still comes out cheaper per closed issue across most reasonable retry assumptions. Opus wins the economics only when a wrong first patch carries serious downstream cost.

Can I use both models in one agent? Yes, and for most teams it is the best answer. Route terminal, orchestration, and high volume steps to Grok 4.5, escalate to Opus 4.8 for deep localization and patch generation, and gate all output behind your test suite. A tiered design spends premium tokens only on the hard part of the task.

Are these benchmark numbers from real tests? The pass rates and token figures cited here are the reported SWE-Bench Pro and Terminal-Bench 2.1 results circulating at the time of writing. Treat them as a starting point and validate on your own tickets, because public benchmark performance and your workload can diverge sharply.

[ 02 ] — Keep Reading

More from the lab.

Aug 8, 2026 AI Engineering

Offline Batch Inference on an M5 Max: Maximizing Overnight Throughput for a Prompt Backlog (2026)

Most writing about local inference assumes a human is on the other end, watching tokens appear and judging the model by how fast the first one lands. Batch work is the opposite situation, and it is more common than the interactive framing suggests: you have a backlog of tens or hundreds of thousands of prompts, nobody is waiting on any single one, and the only thing that matters is how much of the pile you can clear before morning. Product descriptions for a catalog, classification over a support archive, embeddings and summaries for a corpus, synthetic data for a fine tune. In that regime latency is irrelevant and throughput is everything, and the settings that make a local server feel responsive to a person actively work against you, because they optimize for the wrong number. Running one prompt at a time on an M5 Max leaves most of the machine idle, since a single decode stream cannot saturate the memory bandwidth the chip has to offer. The job is to keep many sequences in flight so the expensive weight reads are amortized across all of them, and to arrange the backlog so the GPU never waits on padding, scheduling, or a slow tail. This post is about doing that deliberately: what actually bounds batch throughput on Apple Silicon, how far batching takes you before memory stops you, and the operational scaffolding that turns a fragile overnight run into one you can resume when it dies at 3am.

Aug 7, 2026 AI Engineering

Semantic Response Caching for a Local LLM Gateway on Apple Silicon: Cutting Redundant Inference on an M5 Max (2026)

Prompt caching skips the prefill on a repeated prefix, but it does nothing for two users who ask the same thing in different words. On a single Apple Silicon box, where every generation competes for the same unified memory, the cheapest token is the one you never generate. Semantic response caching sits in front of the model, embeds the incoming prompt, and if a past prompt was close enough in meaning it returns the stored answer without touching the GPU. The hard part is not the cache. It is deciding when two questions are actually the same question, because a threshold set too loose will confidently serve the wrong answer. This post builds the gateway, measures the hit rate on a real support workload, and sets the similarity threshold where a wrong answer costs more than a cache miss.

Aug 5, 2026 AI Engineering

Serving Concurrent Requests to a Local LLM on Apple Silicon: Admission Control and Backpressure on an M5 Max (2026)

The first time a local inference service meets real traffic, it does not slow down gracefully, it falls off a cliff. A single request against a 14B model on an M5 Max streams at eighty tokens a second and feels like a hosted API. Then a second user arrives, and a third, and a burst of eight lands at once, and suddenly latency has tripled, the machine is paging to disk, and one unlucky request gets an out of memory kill mid generation. Nothing in the model changed. What changed is that concurrency on a single Apple Silicon box is bounded by unified memory, not by raw compute, because every in flight request holds a slice of KV cache that lives in the same pool the model weights and the operating system are already using. Once the concurrent working set crosses the wired memory limit, the machine does the worst possible thing under load, which is to keep accepting work it cannot serve. The fix is not a bigger model server flag. It is admission control: decide how many requests the box can actually hold, queue a bounded number behind them, and reject the rest with honest backpressure instead of pretending. This post measures where the ceiling sits on a 128GB M5 Max, explains why it is a memory ceiling and not a throughput one, and lays out the gateway pattern that keeps a local service predictable when the traffic is not.

Ready when you are

Want to discuss this topic?

Start a Conversation