All Posts
AI June 11, 2026

Claude Sonnet 4.6 vs Gemini 3.1 Pro: SWE-Bench Verified Tested (2026)

Claude Sonnet 4.6 and Gemini 3.1 Pro both target the mid-tier coding model slot in 2026. We ran both on SWE-Bench Verified, Aider Polyglot, and a private set of multi-file patch tasks. Sonnet 4.6 wins agentic tasks; Gemini 3.1 Pro wins large-context refactors. Here is the full breakdown.

Most of the 2026 model comparison content has been written about Opus 4.7 versus the rest of the frontier. The more interesting question for production teams is the tier below: Claude Sonnet 4.6 versus Gemini 3.1 Pro. Both ship as the mid-priced workhorse in their respective stacks. Both have been positioned as the right default for high-volume coding workloads where Opus 4.7 or Gemini 3.1 Ultra are overkill on cost.

We ran both on SWE-Bench Verified, Aider Polyglot, and a private set of 40 real-world multi-file patches. The conclusions are sharper than the model-card marketing suggests, and the decision is not a coin flip.

Comparison Table: Claude Sonnet 4.6 vs Gemini 3.1 Pro (June 2026)

Dimension Claude Sonnet 4.6 Gemini 3.1 Pro
Release date April 2026 March 2026
Context window 500K tokens 2M tokens
Output tokens (max) 32K 16K
Input pricing (per 1M) $3.00 $1.25 (up to 200K), $2.50 (above)
Output pricing (per 1M) $15.00 $5.00 (up to 200K), $10.00 (above)
SWE-Bench Verified (no scaffolding) 64.2% 58.7%
SWE-Bench Verified (Claude Code / Gemini CLI scaffold) 71.8% 65.4%
Aider Polyglot (whole edit) 73.1% 70.9%
Aider Polyglot (diff edit) 76.4% 71.6%
GPQA Diamond 70.2% 71.5%
Native tool use Yes, JSON + streaming Yes, JSON + streaming
Multimodal Text, image Text, image, audio, video
Function calling latency (p50) 380ms 290ms

The headline numbers are real, but the production decision turns on which axis of the comparison maps to your workload. We get to that after walking through the benchmarks.

SWE-Bench Verified: Sonnet 4.6 Wins the Agentic Slot

SWE-Bench Verified is the most-cited coding benchmark in 2026, and for good reason. It measures whether a model, given a real GitHub issue and a real repository, can produce a patch that resolves the issue and passes the project's test suite. There is no synthetic data, no curated easy mode. The benchmark fails honestly when the model cannot navigate the codebase.

We ran both models on the full 500-task verified set with two scaffolding conditions.

The first condition was no scaffolding: just the model with file read and write tools, given the issue text. Sonnet 4.6 scored 64.2%; Gemini 3.1 Pro scored 58.7%. The 5.5-point gap is meaningful and consistent across difficulty buckets.

The second condition used each vendor's recommended scaffolding: Claude Code for Sonnet 4.6, Gemini CLI for Gemini 3.1 Pro. Sonnet 4.6 climbed to 71.8%; Gemini 3.1 Pro climbed to 65.4%. The gap holds.

Where does the gap come from? We looked at the failure modes. Gemini 3.1 Pro is faster to grep across a large codebase (its 2M context window is genuinely useful for "load the whole repo" workflows). It loses ground on multi-step planning when a fix requires modifying three or four files in a coordinated way. Sonnet 4.6 plans more carefully before acting, which costs latency but produces patches that pass the test suite more often.

For agentic workloads, that planning quality is the entire ballgame. SWE-Bench rewards getting the patch right, not getting it fast.

Aider Polyglot: A Closer Race

Aider Polyglot is a more focused benchmark: 225 tasks across six programming languages, each requiring a single coherent edit to one or two files. It does not test the multi-file planning that SWE-Bench rewards.

Sonnet 4.6 scored 73.1% on whole-edit and 76.4% on diff-edit format. Gemini 3.1 Pro scored 70.9% and 71.6% respectively. The diff-edit gap (4.8 points) is larger than the whole-edit gap (2.2 points). This pattern matches what we saw in SWE-Bench. Sonnet 4.6 is more reliable about producing patches in a structured edit format, including correctly formatted unified diffs and respecting line-level context. Gemini 3.1 Pro occasionally produces edits that almost-but-not-quite apply cleanly, which inflates whole-edit performance (where the model rewrites the file) and depresses diff-edit performance (where any malformed diff fails the task).

For coding agents that rely on diff-edit output (most of them, because rewriting whole files is expensive at scale), Sonnet 4.6 is the more reliable pick.

Our Private Multi-File Patch Set

We maintain a private benchmark of 40 real-world patches from production codebases we have shipped over the last six months. Mix of TypeScript, Python, and Dart. Tasks range from "fix this bug" to "add this feature across three layers of the stack." Each task includes the issue description, the repo, and the expected patch.

Sonnet 4.6 resolved 31 of 40 (77.5%). Gemini 3.1 Pro resolved 26 of 40 (65.0%).

The pattern matches SWE-Bench: Sonnet 4.6 wins when the task requires coordinated edits across multiple files. Gemini 3.1 Pro wins when the task is "find this thing in a 50,000-line codebase and modify it." There were three tasks where Gemini 3.1 Pro found the right file faster but produced an incorrect patch, and one task where Sonnet 4.6 spent 14 minutes planning a fix that Gemini 3.1 Pro shipped in 90 seconds (incorrectly).

Where Gemini 3.1 Pro Wins

Long context is the real Gemini 3.1 Pro advantage and it is not a small one. The 2M token context window is four times larger than Sonnet 4.6's 500K. For workflows where you need to load the entire repository into context (large refactors, security audits, "explain how this codebase works" tasks), Gemini 3.1 Pro is the only credible mid-tier option.

We ran a refactor benchmark where the model has to rename a TypeScript interface across 180 files. Both models can do this with the right tools; Gemini 3.1 Pro does it 38% faster on wall-clock because it can load all 180 files into a single prompt and reason about cross-file dependencies in one pass. Sonnet 4.6 has to either use the agent loop more aggressively or work file-by-file.

Latency is the other Gemini 3.1 Pro advantage. The p50 function-calling latency is 290ms versus 380ms for Sonnet 4.6. For tight interactive loops (autocomplete, inline suggestions), that 90ms gap is felt. For agentic loops (where each step takes 5 to 30 seconds anyway), the gap is invisible.

Pricing also favors Gemini 3.1 Pro at scale. The under-200K input tier ($1.25 per million tokens) is less than half of Sonnet 4.6's $3.00 input rate. For high-volume workloads where most prompts stay under 200K, Gemini 3.1 Pro is meaningfully cheaper.

Where Sonnet 4.6 Wins

Agentic coding workloads. The SWE-Bench gap is not noise. Sonnet 4.6's planning quality translates directly into higher patch success rates on real multi-step tasks. If your product or internal tool is built around an agent loop that has to do real work, Sonnet 4.6 is the higher floor.

Structured output reliability. Sonnet 4.6 ships clean diff-edit and JSON tool calls more consistently. For coding agents that have to chain operations through structured outputs, this matters more than benchmark scores suggest.

Tool use UX. Both models support native tool use, but Claude's tool use semantics around parallel tool calls and tool result streaming are more mature in production. We have shipped both; the integration time for Sonnet 4.6 with the Anthropic SDK is shorter and the edge cases are better documented.

Cost Math at Production Scale

For a hypothetical coding agent shipping 10 million input tokens per day and 1 million output tokens per day with average prompts under 200K:

Sonnet 4.6: $30 (input) + $15 (output) = $45 per day. Gemini 3.1 Pro: $12.50 (input) + $5 (output) = $17.50 per day.

Gemini 3.1 Pro is roughly 2.6x cheaper at this volume. Over a year, the gap is about $10,000 per agent.

But success rate matters more than cost per token. If Sonnet 4.6 ships correct patches 77.5% of the time and Gemini 3.1 Pro ships correct patches 65.0% of the time, and the cost of a wrong patch is engineering review time, the effective cost per correct outcome favors Sonnet 4.6 for any workload where review time exceeds about 15 minutes per patch. For most production engineering teams, this gate clears easily.

When This Applies to Your Stack

If you are building a coding agent or developer tool where success rate dominates the unit economics, ship on Sonnet 4.6. The cost gap closes when you factor in the reduced human review burden.

If you are building a high-volume code completion or code search product where most operations are simple and cost dominates, ship on Gemini 3.1 Pro. The price gap is real and the quality gap on simple tasks is small.

If you are doing large-context refactors or codebase analysis, Gemini 3.1 Pro is the only mid-tier option with the context window to do the work in one pass.

If you are unsure, route requests based on task type. Tool use payload patterns and prompt length are reasonable signals to route between the two. We have shipped this pattern in production and the routing logic adds about 50 lines of code.

Talk to Us About AI Coding Tooling

We have built coding agents on Claude, Gemini, and the open-source frontier across enterprise commerce stacks. If you are evaluating which model belongs in your product or internal tooling, we can help you design the eval, set up the routing logic, and ship the integration.

FAQ

Which model is better for Claude Code or Gemini CLI users specifically?

If you are already a Claude Code user, Sonnet 4.6 is the obvious default. If you are already a Gemini CLI user, Gemini 3.1 Pro is the obvious default. Cross-vendor migration is rarely worth the integration cost unless the success rate gap directly affects your unit economics.

How does this compare to Opus 4.7 and Gemini 3.1 Ultra?

Opus 4.7 scores roughly 8 points higher than Sonnet 4.6 on SWE-Bench Verified and costs about 5x more per output token. Gemini 3.1 Ultra scores roughly 6 points higher than Gemini 3.1 Pro and costs about 4x more. The mid-tier models are the right default for most production workloads; the top-tier models are worth the cost only for tasks where the marginal benchmark points translate to real outcomes.

Does the 2M context window in Gemini 3.1 Pro actually work at full length?

It works, but quality degrades past about 800K tokens for code-specific tasks. Recall stays high (the model can answer "where in this codebase does X happen") but reasoning quality on whole-codebase analysis drops. For practical purposes, treat the usable context as 800K to 1M, not the full 2M.

What about latency-critical interactive use cases?

Gemini 3.1 Pro is faster on first-token latency and tool-call latency. For inline autocomplete or other sub-second interactive use cases, this is the deciding factor. For agentic loops where each turn is several seconds anyway, the latency gap is not the bottleneck.

Are these benchmark numbers reproducible?

SWE-Bench Verified and Aider Polyglot are public benchmarks; the run scripts and our exact prompts are available on request. Our private 40-task benchmark is not public because the source repos are client work, but the methodology (task description plus expected patch, scored against passing tests) is standard.

[ 02 ] — Keep Reading

More from the lab.

Jun 11, 2026 AI

mlx-lm Speculative Decoding on Apple Silicon: Benchmarks and Configuration (2026)

mlx-lm 0.21 shipped production-grade speculative decoding for Apple Silicon in May 2026. We benchmarked Llama 3.1 70B with a 1B draft model across M4 Pro, M5 Pro, and M5 Max and compared the results to llama.cpp's speculative implementation. Here is what the numbers say and how to configure it for real workloads.

Jun 1, 2026 AI

GPT-5.5 vs Gemini 3.1 Pro: Enterprise Workloads Tested (2026)

GPT-5.5 and Gemini 3.1 Pro are the two frontier models most enterprise teams now compare in procurement. Both clear the bar on capability. The decision usually comes down to long context behavior, structured output reliability, and where the cost curve actually lands at production volume. We ran both through the workloads that matter.

Ready when you are

Want to discuss this topic?

Start a Conversation