Why the Same LLM Performs Differently Across Frameworks: Understanding the Harness Layer

    This article explains why an LLM can feel brilliant in one tool and mediocre in another even when the model weights, API protocol, and billing stay the same. It walks through the stack from the inside out—LLM, prompt, context, RAG, tools, agents, and the harness that ties them together—and shows how context assembly, retrieval quality, tool loops, and guardrails determine how much of a model's ceiling you actually get. A layered troubleshooting checklist is included for diagnosing format, consistency, factual, and cost issues.

    1. A Common Confusion: Same Model, Very Different Experience

    Most developers have run into this. In one chat interface, the model answers fluently and reasons clearly. Point a coding assistant at the same model’s endpoint with the same key, and it seems to lose its judgment, offering vague advice over and over. Switch to a different tool, and it suddenly “gets it”—reading the project structure and changing code according to convention.

    The model weights haven’t changed. The API protocol hasn’t changed. Billing hasn’t changed. What changed is the layer wrapped around the model, commonly called the harness. A popular abstraction in the industry sums it up:

    1. Agent ≈ LLM + Harness
    2. Prompt / Context / RAG / Tool are all parts the Harness works with
    3. The model sets the ceiling; the Harness decides how much of that ceiling you actually get

    This article connects LLM, prompt, context, RAG, tools, agents, and harness from the inside out, and closes with a layered design approach and a troubleshooting method.

    2. The Engine: What an LLM Actually Does

    A large language model is essentially a program that has read a huge amount of text and has exactly one skill: given a piece of text, predict what is most likely to come next, one token at a time.

    Wrapped as a network endpoint, the interaction is very plain: text in, text out. There is no “agent” inside the API, no tool chain, no database—only the model itself. Understanding this is the prerequisite for everything that follows.

    The model has three built-in characteristics, and nearly every engineering concept afterward is a patch for one of them:

    Built-in characteristic Plain explanation Common compensation
    Stateless Every call starts from amnesia; without resubmitting history you begin from zero Context assembly, memory
    Knowledge cutoff Only knows what it learned during training; unaware of internal company docs and real-time information RAG, web retrieval
    Text output only Cannot read local files, execute code, or call external systems Tools, agents

    These three are not a defect list but design constraints. The real engineering work is building an external nervous system within those constraints.

    3. Prompt: Compressing Intent into Executable Instructions

    The prompt is the input sent to the model, and it is the lowest-cost, fastest-payoff lever in the whole system. A usable prompt usually contains four kinds of information:

    • Role and goal: where the model stands and what problem it solves;
    • Constraints and boundaries: what it must not do and which conventions it must follow;
    • Input data: the material this specific task actually operates on;
    • Output contract: format, fields, length, examples.

    An illustrative structure:

    1. [Role] You are a senior backend engineer responsible for code review.
    2. [Task] Based on the spec below, identify defects in the patch and suggest fixes.
    3. [Constraints] Discuss only reproducible issues; mark uncertain conclusions as "to be confirmed".
    4. [Input] <spec>...</spec> <patch>...</patch>
    5. [Output] JSON: {"issues":[{"file":"","line":0,"severity":"","reason":""}]}

    Three practical points. First, spelling out the output contract works far better than repeatedly telling the model to “be careful.” Second, few-shot examples suit stable patterns; they are not a place to stuff large amounts of long text. Third, a prompt is not one-off copy but an engineering asset that needs version control and regression evaluation.

    4. Context: Attention Is the Real Scarce Resource

    Context is everything actually submitted to the model in a given call. It is not the same as “chat history”—it is a working site assembled on the spot by the harness, typically containing system instructions, prior conversation, retrieved fragments, tool results, and the current input.

    Two constraints matter. The context window is limited. And the model is not equally sensitive to every position in the context: content that is too long or too noisy significantly dilutes the weight of critical information. So the core move in context engineering is selection, not accumulation:

    • Layering: separate stable system instructions from dynamic data so they can be cached and reused;
    • Compression: summarize history and structurally extract from long documents;
    • Ordering: place the most critical constraints and data where they are used effectively;
    • Isolation: keep external content clearly separated from instructions to reduce the risk of being led astray by text inside it;
    • Eviction: set expiry and quotas for tool results so stale information doesn’t pollute current judgment.

    When the same model behaves very differently in two tools, the difference usually lives in this layer: one sends only the current file, while the other sends the spec, dependency relationships, past decisions, and failure records.

    5. RAG: Turning External Knowledge into Citable Context

    RAG (retrieval-augmented generation) addresses the knowledge cutoff and missing private knowledge. The standard pipeline is: document parsing → chunking → embedding and indexing → retrieval → reranking → assembly into context → generation with source attribution.

    Points that are easy to overlook in practice:

    1. The chunking strategy determines retrieval quality; chunk by semantics and structure rather than by a fixed length;
    2. Hybrid retrieval (keyword + vector) is usually more stable than a single method;
    3. Reranking and threshold filtering noticeably reduce “seemingly relevant but actually irrelevant” noise;
    4. Source citations must be preserved so conclusions are traceable and verifiable;
    5. Evaluate each stage separately: retrieval hit rate, fragment usability, and answer accuracy are independent metrics.

    RAG is not a cure-all. It is good at “if it can be found, there is evidence to rely on,” and poor at global reasoning across documents—that kind of task needs structured knowledge organization instead.

    6. Tools and Agents: From Talking to Doing

    A tool is a mechanism that lets the model emit a structured call intent, have an external program execute it, and return the result. One tool call closes a loop: the model issues a request → the runtime validates arguments → execution → results are written back into the context → the model continues reasoning.

    Design essentials: tool descriptions should be as precise as API documentation; arguments should be validated with a strongly typed schema; permissions should be minimal, with write operations requiring a second confirmation; execution results need length truncation and error normalization; leave handling logic for idempotency and timeouts.

    An agent puts reasoning–action–observation into a loop, letting the model advance a task autonomously within a limited number of steps. The payoff is handling multi-step problems that need feedback and correction; the cost is higher latency, higher spend, and more uncertainty. That is why a reliable agent always has guardrails: a maximum step count and budget cap, retry and fallback strategies, human confirmation at key points, and traceable execution logs across the whole run.

    7. Harness: Assembling Parts into a Deliverable Product

    The harness is everything in the runtime outside the model: request orchestration, context assembly, retrieval, tool registration and dispatch, state and memory management, streaming output, error handling, observability and evaluation, and cost and quota control.

    A comparison shows its value. Two coding tools connect to the same model. Tool A sends only the code near the current cursor. Tool B first parses the project structure, retrieves relevant specs and past decisions, validates patches by type, and retries with compiler errors attached on failure. The model is identical, yet output quality is not in the same league—the entire difference comes from the harness.

    On the cloud, capabilities are typically split into general-purpose categories used in combination: object storage holds raw documents and artifacts, a message queue decouples asynchronous tasks, a container platform hosts the runtime and tool sandboxes, logging plus monitoring and alerting provide observability, and key management centrally holds credentials. The benefit of this layering is that each layer can be replaced and rolled out gradually on its own.

    8. Practical Checklist: Troubleshoot Layer by Layer When Results Are Off

    • Unstable output format → fix the prompt’s output contract and examples first;
    • Contradictions or forgotten agreements → check context assembly and history compression;
    • Factual errors or missing citations → check retrieval recall and source attribution;
    • Cannot operate on the real environment → check tool registration, argument validation, and permissions;
    • Multi-step tasks drifting midway → tighten agent step limits, add validation and fallback;
    • Abnormal cost or latency → look at context length, loop count, and cache hit rate.

    The conclusion is straightforward: the model is the engine; the harness is the transmission, chassis, and steering wheel. To improve results, don’t rush to swap models—make context selection, retrieval quality, closed tool loops, and guardrails solid, and the same model will perform close to its ceiling.