Adding a 'Repair Layer' to Open-Source Models: How DeepSeek Can Outperform Claude Opus

A deterministic repair layer fixes Tool Calling failures in open-source LLMs, making DeepSeek rival Claude Opus.
Ahmad Awais discovered that open-source models like DeepSeek appear slow or unreliable not due to limited capability, but because of systemic Tool Calling failures rooted in distillation training biases. His solution — a deterministic repair layer paired with repair hints — fixes malformed tool call parameters on the fly and guides models to self-correct, dramatically improving stability and enabling DeepSeek to rival frontier closed-source models.
The Misunderstood Problem: It's Not the Model — It's Tool Calling
In a recent AI frontier interview, independent developer and prolific open-source contributor Ahmad Awais (creator of Command Code) shared a counterintuitive insight: many complaints about open-source LLMs being "unreliable, slow, or dumb" don't actually stem from model capability — the real culprit is systemic failures in Tool Calling.
Tool calling is the core mechanism through which modern LLMs interact with the outside world. It allows a model to "pause" generation mid-conversation, invoke predefined external functions (like file system operations, network requests, or code execution), and then incorporate the results back into its reasoning context. OpenAI introduced the Function Calling standard in June 2023 with GPT-3.5/4, and Anthropic, Google, and others soon followed — though implementation details vary across providers. The reliability of tool calling directly determines an agent's practical value. An agent that can't consistently call tools will constantly "freeze up" in real workflows, no matter how capable the underlying model is.
Ahmad's background carries serious weight: 13 years active in the WordPress core community, former VP of DevRel at RapidAPI, early access to GPT-3 in July 2020 (over a year before GitHub Copilot launched), and over 300 open-source projects shipped. Drawing on real inference data involving billions of tokens processed daily, he identified a deterministic pattern he calls "Tool Confusion."
"I figured out why DeepSeek can outperform Claude Opus — the problem was never the model itself."
What makes this finding valuable: it can be deterministically fixed, the method is fully open-source, and any coding agent framework can adopt it directly.
What Is "Tool Confusion"?
DeepSeek's "Stubborn Alpha" Personality
Ahmad uses a vivid analogy to describe DeepSeek V4 Pro's behavior: it has an "alpha male energy" — it is convinced that everything it outputs is correct.
When the model initiates a tool call (say, listing a directory, reading a file, or running a shell command) and sends an incorrect parameter schema, the system returns a Zod validation error. A sufficiently self-aware LLM should read the error and self-correct. DeepSeek doesn't — it stubbornly repeats the exact same broken call, averaging 6 such dead loops per billion tokens, each stalling for about 50 seconds.
A quick note on Zod's role here: Zod is the most popular runtime data validation library in the JavaScript/TypeScript ecosystem, widely used to verify that structured LLM outputs conform to expected schemas. In agent frameworks, developers typically use Zod to define parameter formats for each tool (e.g., "path must be a string, offset must be a number"). When a model passes non-conforming arguments, Zod throws detailed error messages. However, feeding raw Zod errors back to the model is often ineffective — the error format is designed for human engineers, not for a model's "way of thinking." Ahmad's repair layer is essentially a translation-plus-fault-tolerance layer sitting between Zod errors and the model.
Ahmad suspects a subtle root cause: many open-source models are trained via distillation from "stronger models." In knowledge distillation, a student model (smaller) learns from a teacher model's (larger) output distribution rather than from raw human data. While efficient, this causes the student to inherit the teacher's "confidence bias" — since the teacher rarely makes errors in its training data, the student learns the implicit prior that "my outputs are probably correct." Open-source models like DeepSeek rely heavily on distillation data from closed-source models like GPT-4 and Claude. This may be the fundamental reason they resist self-correction on tool call errors — the training paradigm tells them "everything you're told is right," so the model develops a fixed personality of "what I say is right too, don't correct me."
The Hidden Trap Inside Claude Code
Worse, many developers hack Claude Code — swapping out the base API endpoint and key to run open-source models through it. But Claude Code buries its errors behind Ctrl+O, making it impossible to see that 50+ tool call failures have occurred in a single session. Users just perceive "DeepSeek is slow," with no visibility into why.
"That aligns with their vested interests," Ahmad states plainly. "Claude Code was never designed for open-source models."
How the Repair Layer Works
Fix First, Explain Second
Ahmad's solution is a Repair Logic system. He compares it to database migration files — each error pattern maps to a repair file. Starting with 3,200 lines covering 4 repair types, it has grown to over 16,000 repair variants, covering hundreds of billions of tokens worth of failure data.
The core mechanism is elegantly simple: when a model sends malformed data (e.g., a JSON string instead of an array, or an empty object/null instead of an array), the system doesn't just throw the error back. Instead, it:
- Deterministically repairs it — transforms the malformed data into the correct format and returns the result immediately;
- Appends a Repair Hint — tells the model, "You should have sent this format, but I've already handled it for you."

Ahmad uses a brilliant analogy: "It's like teaching someone to drive — when they're about to crash into another car, you save their life first, then explain what they should have done."
The results are immediate: once a result is returned with a repair hint, the third tool call typically self-corrects. The model suddenly "gets smart," understanding what it's supposed to do.
Intelligent Default Inference
The repair layer also performs intelligent inference. For example, if the model wants to read a file but hasn't specified an offset (read the first 100 lines or the last 100?), the system proactively decides: "This is the first read — give it the first 100 lines." The model quickly realizes "actually I need the last 100 lines of the log file," avoiding that 50+ failure loop entirely.
From One Model to a Universal Pattern
Ahmad initially thought this was a DeepSeek-specific issue. But after reviewing 30 days of logs, he found Kimi was doing the exact same thing — and then fixed the same issue in MiniMax. This shows that "Tool Confusion" is a universal pattern across open-source models, not an isolated case — likely a systemic bias stemming from the widespread use of distillation training paradigms across the open-source model community.

How powerful is the fix? Ahmad gives this example: DeepSeek V4 Flash, which was nearly unusable before, can directly compete with flagship models after the repair layer is applied. Investor and GitHub co-founder Tom Preston-Werner reportedly asked: "What did you do? Why is DeepSeek V4 Flash suddenly so stable?"
There's also an interesting hidden effect of permission modes: when confirmation dialogs are enabled (every action requires yes/yes/yes), models actually perform worse; when permissions are fully bypassed, models explore more freely, show greater creativity, and can run much longer. One user ran a single DeepSeek session on Command Code for over 12 hours, consuming 70 billion tokens — only possible because tool errors were so rare the model could sustain deep, continuous reasoning.
The Same Philosophy: Fixing "Design Slop"
From Tool Calling to Design Slop
Ahmad's most surprising discovery is that this "deterministic repair" philosophy transfers directly to design. Every LLM has a "Design Slop" tendency — the most telling symptom being that ubiquitous indigo-purple gradient aesthetic (he specifically calls it indigo slop, not just "purple").

After conversations with several top designers, Ahmad found that designers can tell in 1.5 seconds whether a page was AI-generated or human-designed. And the differences they identify are, again, a set of deterministically fixable patterns. The team ultimately compiled:
- 24 reference documents
- 10 "Design Smells"
- 7 Design Patterns
Intent-First and OK LCH
Two key insights stand out:
First: Intent-First. When you ask a model to "design a dashboard," it doesn't think about the underlying intent — it just dumps three cards side by side. But give it a framework — "What type of interface is this? A dashboard is a monitor surface" — and it designs significantly better.
Second: The OK LCH color space. OK LCH (Oklab Lightness-Chroma-Hue) is a perceptually uniform color space proposed by graphics engineer Björn Ottosson in 2020, natively supported by mainstream browsers since 2022 (CSS Color Level 4 standard). Compared to traditional HSL, OK LCH's key advantage is "perceptual uniformity" — when you adjust the lightness value in OK LCH, the perceived change in brightness is linear. HSL's lightness adjustments, by contrast, produce visually inconsistent results depending on hue (yellow looks much brighter than blue at the same L value in HSL, for instance). This is precisely why LLMs struggle to precisely control color palettes in HSL: the "color rules" the model learned are perceptually distorted. OK LCH provides a mathematically "honest" framework that lets models control color palettes with much greater precision.
"This isn't a capability gap — it's a contract gap," Ahmad concludes. "Users will always just say 'fix my design, make it look better.' If you give the model a framework for how a great designer thinks, you can fix 90% of design slop."
Taste: Automatically Learning Your Coding Preferences
Beyond the repair layer, Command Code's other core feature is Taste — a model architecture Ahmad calls "meta neuro-symbolic."
It works by automatically learning your preferences within each code repository. For instance, it observes that you prefer pnpm for installing dependencies but use npm global link for local CLI linking; or that you always start version numbers at 0.0.1. These recurring micro-decisions are automatically recorded into "taste files" (similar to skill files, but more concise).

Key design principles:
- Transparent and visible: These files live in your Git repository — not hidden inside the model — so every PR can be reviewed;
- KL divergence-based deduplication: KL divergence (Kullback-Leibler Divergence) is an information-theoretic measure of the difference between two probability distributions. The system uses it to evaluate how much a user preference differs from the model's "baseline knowledge." If the KL divergence is low, the model already "knows" this preference (it's a common programming convention) and it doesn't need to be written to a Taste file, wasting context window space. Only high-KL preferences — truly personalized, non-generic habits — are worth recording. This reflects a refined context management philosophy: the context window is a scarce resource and should only be filled with information the model "doesn't know" but "needs to know";
- Portable:
npx taste pullfetches it, and any coding agent can use it directly.
In a study with 70+ developers, those using Taste showed a measurable reduction in manual corrections and edits. A popular community workflow has also emerged: use a high-quality model like Claude Opus or GPT to build the taste file first, then use cheaper open-source models to continue development based on it — getting high-quality output at low cost.
Going Open Source: Being the "Apple of Coding Agents"
Toward the end of the interview, Ahmad revealed the roadmap: Command Code is going open source (he hopes to announce it at the AI Engineering conference). The project grew out of a viral Corona CLI he built during COVID in 2020, and has evolved over six years.
His product philosophy maps neatly onto three models in the industry:
- Windows: runs any model (e.g., OpenCode);
- Linux: hack everything yourself (e.g., Pi);
- Apple: only the best models (open and closed), but fully hackable.
Command Code chose the Apple path: not a "1,500-model free-for-all," but a curated selection of the best models while remaining fully modifiable. Notably, WordPress co-founder Matt Mullenweg became an angel investor after hearing about the open-source plans.
Closing Thoughts: A Universal Methodology
Regardless of which coding agent you use, Ahmad's core insight is worth internalizing: many so-called "model capability problems" are fundamentally "contract problems" between the framework and the model. The combination of deterministic repair + repair hints doesn't just fix tool call failures — it generalizes to UI design, secure code review, and beyond. The universality of this finding lies in what it reveals: between model capability and application output, there exists a systematically optimizable "middleware" layer that has been largely overlooked.
As Ahmad puts it: "You don't have to use Command Code. You can take this thinking and apply it to any coding framework — as long as we're all moving forward."
Key Takeaways
Related articles

Disaster and Glory of the Apollo Program: The History We Must Revisit Before Returning to the Moon
From the fatal Apollo 1 fire to Apollo 8's daring lunar orbit to Apollo 11's successful landing—revisiting the disasters, fears, and compromises of the Apollo program and their lessons for today's return to the Moon.

Netflix Trust Exercise Turns Into Firing Trap: Where Are the Boundaries of Corporate Trust?
A Netflix employee was fired after sharing private info in a trust exercise. We analyze the risks of corporate trust exercises and how employees can protect themselves.

AMD CDNA5 Architecture Deep Dive: Technical Evolution and the AI Computing Competition Landscape
Deep analysis of AMD's CDNA5 architecture covering Chiplet packaging upgrades, HBM memory evolution, and low-precision compute optimization, examining how AMD challenges NVIDIA's AI chip dominance.