LLM Harnesses Explained: Why the Same Model Performs Differently Across Applications
The same large language model can produce very different results across applications because model inference is only one part of the system. This article explains how prompts, context, retrieval, tools, agents, and the surrounding harness affect task performance. It also outlines how to diagnose failures, compare systems fairly, and build a controlled execution loop with verifiable results.
1. Why Do Results Change When the Model Stays the Same?
Many developers have experienced this: a model explains code accurately in a web chat, but repeatedly misses constraints when integrated into a coding tool. In another application, it completes similar tasks successfully.
This does not necessarily mean the model’s capabilities have changed. What users experience is usually the output of a complete system, not an isolated inference call:
Task outcome = model reasoning capability + input quality + tool execution capability + workflow control and verification.
This is an analytical framework, not a mathematical formula. The model provides reasoning and generation capabilities. The surrounding system prepares information, coordinates steps, executes operations, and checks results. Different system designs can therefore produce noticeably different outcomes with the same model.
Before examining the surrounding system, however, confirm that “the same model” really is the same. An identical endpoint or access credential does not guarantee the same model version, inference configuration, or server-side processing. Output length limits, sampling settings, conversation truncation, and server-side routing can all affect results.
Troubleshooting should distinguish between two categories:
- Model-call differences: The actual model version, request parameters, or server-side processing differ.
- Runtime-system differences: The information supplied to the model, available tools, execution workflow, or feedback mechanisms differ.
This article focuses on the second category: the harness, or runtime framework built around the model.
2. The LLM Provides Capabilities, Not a Complete Application
A large language model, or LLM, generates output by progressively predicting subsequent tokens from the input it receives. Tokens are the basic units of text processed by a model; they do not necessarily correspond to individual words or characters.
Training gives this mechanism capabilities such as language understanding, code generation, question answering, and some forms of reasoning. But there remains an engineering gap between generating plausible content and reliably completing a business task.
Conversation Memory Usually Requires External Management
In typical stateless inference calls, the model does not automatically inherit the full history of previous requests. The application must organize relevant conversation history, task state, and user constraints into the current input.
Some services provide persistent sessions, but this generally means the service layer maintains state. It should not be interpreted as the model’s parameters continuously remembering the user.
Knowledge in Model Parameters Does Not Cover Live or Private Information
Knowledge acquired during training is not a live database. It does not inherently include internal company documents, the current code repository, or the latest business rules.
A fluent answer can still contain plausible but incorrect claims when evidence is missing. Business facts need to be supplied through context, retrieval, or tools rather than inferred from the model’s ability to write convincingly.
Proposing an Operation Is Not Executing It
A model can request actions such as reading a file, querying a record, or running a test. The actual execution usually happens in an external program.
These are three distinct steps:
- The model determines which operation is needed.
- The harness validates and executes the operation.
- The result is returned to the model to support its next decision.
Modern model interfaces may also support multimodal input, structured output, or tool-calling protocols. They should not all be described as text-only interfaces. Even so, the surrounding system must connect those interface capabilities to real application functions.
3. Prompts and Context: What to Do and What Information to Use
“Prompt” and “context” are often used interchangeably. They overlap, but emphasize different aspects of model input.
Prompts Define Tasks, Constraints, and Output Requirements
A prompt primarily tells the model:
- What task to complete.
- Which rules to follow.
- When to ask for clarification or stop.
- How to format the final output.
For a code-editing task, a prompt might say:
Fix the specified function’s handling of empty input. Preserve the public interface and do not modify unrelated files. Identify the cause first, then make the smallest necessary change and explain the validation results. If you cannot run tests, state that explicitly.
This is more useful than “fix this code” because it defines the task boundaries and acceptance criteria.
However, prompts are not security controls. “Do not access sensitive data” cannot replace access restrictions. Likewise, “all tests must pass” does not guarantee that tests were actually run.
Context Is the Information Available for the Current Inference
Context typically includes prompts, conversation history, file contents, retrieved passages, tool results, and task state.
A useful distinction is:
A prompt emphasizes instructions; context encompasses the information available to the model for the current inference.
The same model is likely to perform differently when it receives only “fix the login failure” versus receiving that request alongside error logs, relevant functions, interface contracts, and reproduction steps.
More context is not always better. Irrelevant material consumes the context window, increases cost, and can distract from important evidence. Outdated documentation and conflicting rules can also make it difficult to determine which information applies.
Context Engineering Means Selecting, Organizing, and Updating Information
Effective context management should consider:
- Relevance: Does the information directly support the current decision?
- Validity: Is it current, and does it match the version being used?
- Source: Is it a user instruction, a trusted system rule, or external material?
- Completeness: Are decisive constraints or key pieces of evidence missing?
- Budget: What must remain in context, and what can be summarized or removed?
For long-running tasks, the harness should continually update state, recording completed steps, failure causes, hypotheses awaiting validation, and next steps. Summaries can reduce input size, but critical facts, error messages, and invariant constraints should not be compressed away indiscriminately.
4. RAG: Retrieve Evidence Before Generating an Answer
Retrieval-augmented generation, or RAG, retrieves relevant material from external sources before or during generation and supplies it to the model as context.
A typical workflow is:
User question → retrieval query → candidate documents → ranking and filtering → context assembly → answer generation
Its value is not that it permanently teaches the model company knowledge. It gives the current answer access to applicable evidence.
The Retrieved Sources Define the Basis of the Answer
Sources may include technical documentation, business policies, historical support tickets, code snippets, or knowledge-base entries.
Documents should be divided into appropriate chunks while preserving titles, sources, versions, update timestamps, and access-control attributes. Chunks that are too small can lose meaning; chunks that are too large can introduce excessive irrelevant content.
Retrieval Is More Than Similarity Matching
Vector search is useful for finding semantically related material. Exact identifiers such as function names, error codes, and configuration keys often also require keyword search.
In practice, multiple retrieval methods can be combined, followed by ranking of the candidates. Success should be measured by whether the system found the evidence needed to answer the question, not by how many results it returned.
Retrieved Content Is Not Automatically Reliable
Documents may be outdated, contradictory, or inapplicable to the current environment. The harness should provide their sources and scope of applicability alongside the content, and allow the model to express uncertainty when evidence is insufficient.
Permission filtering must be enforced in retrieval and data-access layers. A system should not give unauthorized content to the model and then rely on a prompt to prevent disclosure.
Retrieved material is also external data. Text within it such as “ignore the rules” or “perform this action” must not automatically become a system instruction. Maintaining that boundary is important for defending against prompt injection.
5. Tools: Connecting Reasoning to the Real Environment
A tool is an external capability the model can access through the harness, such as reading files, searching code, querying business data, running tests, or submitting changes.
Tool interface quality directly affects whether the model can act correctly.
Tools Need Clear Capability Boundaries
A tool should clearly define its purpose, inputs, outputs, failure conditions, and side effects. Ambiguous names or descriptions can cause the model to invoke it at the wrong time or misinterpret its output.
For example, a file-reading tool should return content with the necessary location identifiers. A test-running tool should return execution status, exit information, and a failure summary—not merely “executed.”
Tool Calls Must Be Validated
The following illustrative pseudocode shows the workflow; it does not represent a specific interface:
proposal = model.generate(context)if proposal.requests_action:validate_arguments(proposal.action)authorize(proposal.action, current_identity)if has_high_risk_side_effect(proposal.action):request_human_confirmation()result = execute_with_limits(proposal.action)context.append(result)
An action request generated by the model is only a proposal. Deterministic application code should handle argument validation, permission checks, resource limits, and execution decisions.
Write Operations Require Additional Controls
Reading information and modifying an environment carry different risks. Operations such as deleting files, updating records, or sending notifications should have approval, auditing, and recovery mechanisms appropriate to their risk.
Automatic retries must also account for idempotency. A network timeout does not prove that an operation failed to complete. Blind retries can produce duplicate writes or duplicate messages.
6. Agents: Systems That Keep Acting Toward a Goal
An agent generally refers to a system that selects subsequent actions toward a goal using feedback from its environment. It may include a model, state, tools, planning, and an execution loop.
A typical cycle is:
Understand the goal → gather information → choose an action → execute a tool → observe the result → adjust the next action → verify completion
Tool use alone does not establish that a system is agentic. The more important question is whether it can change its next action based on execution results.
Agents and Fixed Workflows Serve Different Needs
A fixed workflow follows an execution path defined in advance by application code. It suits tasks with clear rules, stable steps, and demanding audit requirements.
An agent lets the model dynamically choose parts of the path. This is more suitable for uncertain environments and exploratory tasks, but it also introduces greater risk of unproductive attempts, rising costs, and behavior drifting beyond the intended scope.
The two approaches can be combined. A system can use fixed workflows to control critical checkpoints while allowing the model to choose retrieval methods or analysis paths within defined boundaries.
Agents Need Explicit Stopping Conditions
“Keep thinking until the task is complete” is not a reliable execution strategy. The harness should define:
- What evidence demonstrates completion.
- The maximum number of actions allowed.
- Time and cost budgets.
- When the user must provide more information.
- Which failures require human intervention.
The objective is not unlimited activity. It is a verifiable result within defined constraints.
7. The Harness: Organizing Capabilities into a Runtime System
“Harness” has different meanings in different technical contexts. Here, it means the runtime framework surrounding the model, responsible for information preparation, state maintenance, tool orchestration, feedback handling, security controls, and result verification.
The expression “Agent = LLM + Harness” can be a useful simplification, but it is not a strict definition. A harness can support non-agentic, fixed workflows, while a complete agent also involves goals, an environment, and an action-selection strategy.
A typical structure looks like this:
User task↓Harness├─ Instruction and context assembly├─ Retrieval and state management├─ Model request adaptation├─ Tool validation and execution├─ Permissions, budgets, and auditing└─ Result verification and termination control↕Large language model
Common reasons the same model performs differently across applications include:
- One application supplies relevant files; another supplies only the current snippet.
- One preserves complete error feedback; another truncates it.
- One can run tests; another can only generate recommendations.
- One iterates after failures; another stops after a single response.
- One has reliable permission and state management; another relies on vague prompts.
“The model sets the capability ceiling, while the harness determines how much of it is realized” is a useful intuition, but not a strict law. Tools, external knowledge, and iterative verification can substantially extend the capabilities of the overall system. Its limits are not identical to those of a single model response.
8. A Code-Fix Example: Where the Difference Comes From
Consider the task: “Fix a function that handles empty input incorrectly.”
A Simple Model Call
The system sends the user’s description and part of the code to the model. It ends as soon as the model generates a suggested change.
This approach lacks call-site context, existing tests, interface constraints, and execution feedback. A patch may look reasonable while changing expected behavior or failing to address the actual issue.
A Complete Execution Workflow
A more reliable process is:
- Confirm the issue description, reproduction conditions, and acceptance criteria.
- Locate the target function and relevant call sites.
- Read the corresponding tests and interface constraints.
- Form a testable hypothesis about the cause.
- Generate the smallest change within the permitted scope.
- Run relevant tests and collect results.
- Revise the change based on failures, or stop when the budget is exhausted.
- Report the changes, validation evidence, and remaining risks.
The improvement comes not from a longer prompt, but from evidence gathering and execution feedback. Rather than guessing from a single input, the model can validate its reasoning in the environment.
Passing tests still does not establish absolute correctness. Depending on the task’s risk, validation should also include diff review, edge-case checks, and any necessary human review.
9. How to Diagnose Model Problems Versus Harness Problems
Evaluation should use layered metrics rather than focusing on how fluent an answer sounds.
Input and Retrieval
Inspect the actual context received by the model. Check whether critical files, task constraints, and error information were present.
For retrieval systems, distinguish between failing to find evidence and finding it but failing to use it correctly.
Decisions and Execution
Record whether the system selected the right tools, supplied valid arguments, executed successfully, and responded appropriately to failures.
Results
Evaluate correctness against the task definition. For question answering, check factual support. For coding tasks, check behavior and modification scope. For write operations, check whether the resulting state matches expectations.
Operational Cost
Track latency, model calls, tool calls, context consumption, retries, and the rate of human intervention. A high completion rate may still be unsuitable for production if it requires uncontrolled costs.
To compare harnesses fairly, keep the model version, request configuration, data permissions, tool conditions, and budgets as consistent as possible. Use the same tasks with explicit acceptance criteria. Repeat stochastic workflows and report variability.
Ablation experiments can also help: remove retrieval, test feedback, or state summaries individually and observe how quality changes. This reveals which components actually contribute to better results.
10. Implementation Priorities: Build a Controlled Loop Before Expanding Autonomy
A practical implementation sequence is:
First, define acceptance criteria. Replace “a good answer” with checkable requirements for facts, behavior, and output.
Second, establish information sources. Identify the documents, files, and runtime state the model needs. Address missing information before adding complexity.
Third, build a minimal execution loop. Start with a small set of clearly bounded tools that support execution, feedback, and verification.
Fourth, enforce security boundaries. The system itself must enforce permissions, sensitive-data handling, approval for write operations, and resource limits.
Fifth, improve observability. Retain the necessary request records, tool events, version information, and results, with appropriate redaction and access controls.
Sixth, increase autonomous decision-making gradually. Expand tool access, action counts, or coordination complexity only after the basic workflow is stable.
The concepts fit together along a clear line: the LLM generates and reasons; the prompt describes the task and constraints; context supplies the information visible for the current inference; RAG adds external evidence; tools connect the system to real operations; an agent selects actions toward a goal; and the harness organizes these components into a runnable, controllable, and verifiable system.
Application performance depends on more than how capable the model is. It also depends on whether the system gives it the right information, tools, and constraints—and uses real feedback to determine whether the task is complete.
