Why the Same LLM API Delivers Different Results with a Different Harness
This article explains why switching tools around an unchanged large language model API can change output quality. It breaks down the core relationship Agent ≈ LLM + Harness, then walks through the engineering layers that shape model behavior: Prompt, Context, RAG, Tool, and Agent. You will see how each layer addresses the model's built-in limits, how a minimal Harness loop orchestrates them, and how layered tuning and observability help keep results stable.
1. Where the Problem Starts: The Model Is the Same, the Experience Is Not
Many developers have run into this scenario: the same business requirement, the same model version, and the same API parameters, yet simply moving the request from one tool to another produces noticeably different output quality—sometimes nonsense, sometimes a sudden moment of clarity. This is usually not the model “having a bad day.” It means the engineering structure wrapped around the model has changed.
The industry often describes this relationship with a simplified formula:
Agent ≈ LLM + Harness
Prompt, Context, RAG, and Tool are all “parts” in the hands of the Harness. In one sentence: the model sets the upper limit of capability, while the Harness determines how much of that capability is actually delivered.
2. LLM: A “Text Continuation Expert” That Has Read a Lot
A large language model (LLM) is essentially a program that has read massive amounts of text. It does only one thing: predict the most likely next token based on the input, continuing one token at a time.
Its interface is equally simple: text in, text out. There is no agent and no tool chain in the interface—only the model itself. For this reason, it has three “inherent limitations,” and almost every concept that follows is a patch for one of them:
| Inherent limitation | Plain explanation | What patches it |
|---|---|---|
| No memory | Every call starts from amnesia; without re-supplying history, it knows nothing | Context, Memory |
| Limited knowledge | It only knows what it learned during training, not enterprise documents or today’s news | RAG, web retrieval |
| Can only talk, cannot act | It can only output text; it cannot read files or run code | Tool, Agent |
3. Prompt: The First Layer of Engineering for Stating the Task Clearly
The Prompt is the input sent to the model, and it is the lowest-cost, fastest-payoff tuning entry point. A high-quality Prompt usually contains four elements: role and goal, input data, constraints and format, and failure handling.
You are a code review assistant.Input: a piece of code to be reviewed.Requirement: output JSON only, with fields risk_level, issues, suggestion.If information is insufficient, return risk_level="unknown" and explain the missing items.
The key is not “writing more,” but constraints that are verifiable and output that is parseable.
4. Context: The Model’s Only Working Memory
Because the model is stateless, “remembering” actually means sending the history again every time. Context engineering solves three things: what to include, how much to include, and how to compress.
- What to include: system instructions, recent conversation, retrieved snippets, tool results.
- How much: bounded by the context window, requiring trimming and ordering.
- How to compress: summarization, deduplication, and structuring into “task state.”
In practice, layering is recommended: keep stable instructions resident, inject dynamic data on demand, and use rolling summaries for long history. When Context gets messy, the model suffers “attention drift,” showing up as forgotten constraints and repeated mistakes.
5. RAG: Turning External Knowledge into Citable Context
RAG (retrieval-augmented generation) first retrieves relevant material, then stitches it into the Prompt. A typical pipeline is: chunk → vectorize → retrieve → rerank → assemble → generate → cite.
query → recall Top-K → rerank to Top-N → assemble as context → LLM generates answer with citations
The key points: chunk granularity should match the question-answer unit, retrieval should mix keywords and semantics, and the generation stage should enforce “no answer without evidence.” RAG is not a cure-all; it only patches “limited knowledge” and cannot patch “cannot execute.”
6. Tool and Agent: From Talking to Acting
A Tool lets the model use external capabilities through structured calls, such as querying a database, calling a message queue, reading and writing object storage, triggering container platform tasks, and viewing log services and monitoring alerts. An Agent turns “plan—call—observe—correct” into a loop.
{"tool":"search_docs","args":{"query":"refund policy","top_k":5}}
Engineering must set up: a tool whitelist, timeouts and retries, idempotency keys, least-privilege permissions, and result truncation. Otherwise the model may fall into an infinite loop or perform dangerous operations.
7. Harness: The Assembly Plant That Determines How Much Capability Is Delivered
The Harness is the engineering layer outside the model. It orchestrates the Prompt, maintains Context, schedules RAG, constrains Tools, parses output, handles exceptions, and runs evaluation. It is what makes the same model “feel like two different people” across different tools.
A minimal Harness main loop:
state = init_state()while not done(state):prompt = build_prompt(state) # instructions + history + retrieved snippetsout = llm_api(prompt) # text in, text outif out.wants_tool:out = run_tool(out) # controlled executionstate = update(state, out) # compression and consolidation
8. Layered Tuning and Observability
It is recommended to locate problems in the order “Prompt → Context → RAG → Tool → Harness orchestration,” instrumenting every layer: token usage, retrieval hit rate, tool success rate, and task completion rate. You can rely on general-purpose cloud capabilities (log services, monitoring alerts, object storage, message queues, container platforms) to build evaluation and regression, forming a closed loop.
9. Conclusion
The model is the engine; the Harness is the chassis, transmission, and steering wheel. To make the same LLM API deliver stable results, do not just swap the model—first make the shell engineering solid: a Prompt with clear constraints, a layered and controllable Context, evidence-based RAG, least-privilege Tools, and an observable, rollback-capable Harness orchestration.
