An agent harness is the code and configuration around a language model that runs the agent: its control loop, tools, context assembly, retries, state and permissions. To debug a failed run, compare what a tool returned with what the harness actually sent to the model.
In a recorded test, an on-call agent read a 4,116-character runbook and answered, "The on-call runbook does not include an explicit rollback command." Section 6 contained that command. A planted harness bug cut every tool result at 3,000 characters; section 6 started at character 3,118. The walkthrough below uses the Laminar debugger to inspect that boundary and replay the failed run with one change. It demonstrates a delivery defect, not a general ranking of models.
What is an agent harness?
LangChain's Vivek Trivedy defines the boundary broadly in "The Anatomy of an Agent Harness" (March 2026): agent = model + harness. The harness includes the system prompt and everything that controls what reaches the model or happens after its response.
| Part | What it controls |
|---|---|
| Agent loop | When to call the model, stop or enforce a step cap |
| Tool execution | Available tools, schemas and result formatting |
| Context assembly | History, documents and tool output included in each request |
| Compaction | What gets summarized or dropped |
| Retries and errors | Which failures retry and what the model sees afterward |
| State | What persists across steps, sessions and subagents |
| Permissions | Allowed actions and how denials are reported |
Anthropic describes the Claude Agent SDK as a general-purpose agent harness. A small loop that calls a model and executes its tool requests also qualifies under this broad definition.
Agent harness vs agent framework
The terminology varies. Paragon calls a framework the toolkit and a harness the configured system built with it. Arize draws a narrower boundary: frameworks compose agent logic, while harnesses operationalize it through tracing, retries, policies and evaluation integration. Its article explicitly excludes LangChain and LangGraph from the harness category.
For debugging, name the component rather than arguing over the label. Identify who assembled the request, executed the tool and handled the result. Those boundaries remain inspectable regardless of the framework.
Agent harness vs evaluation harness
An evaluation harness runs trials and scores them, as Harbor does for Terminal-Bench. A runtime harness runs the agent itself. They meet when an evaluation invokes your agent, which is why Laminar documents making agent evaluations match production. A failed trial can reflect a defect in either harness, as well as poor model behavior.
Is my agent failing because of the model or the harness?
Start at the earliest suspicious decision and inspect its exact request. Did the model receive the evidence and instructions needed for that step?
Use the answer to choose a hypothesis:
- Required information was missing or altered. Inspect how it was selected, retrieved and transformed. Missing information alone does not prove a harness bug: the model might have requested the wrong document, or the source might lack the answer.
- The information was present and clear. Investigate the model's response to that request. Check conflicting instructions before testing a prompt or model change.
- The information was present but buried or contradictory. Test context assembly as well as model behavior. Both can contribute.
Prompts belong to the harness under the broad definition. Here, attribution separates request construction and execution defects from the model's behavior given a particular request. It does not assign every failure exclusively to one side.
Laminar's taxonomy of agent failures includes answers that contradict tool results. Our fixture looks like that from the outside: the tool returned a command, and the answer denied its existence. Inspecting the model input reveals the delivery defect. That does not make the answer's wording correct; it identifies a specific upstream failure to test.
Common harness failures and where to inspect them
The request is a useful starting point, but some faults require execution logs or comparisons across turns. These are inspection targets, not outcomes all measured in this experiment.
| Suspected fault | Evidence to inspect |
|---|---|
| Truncated tool output | Compare the tool span's output with the next request's tool message |
| Compaction dropped a constraint | Compare the summary with the original instruction |
| Swallowed tool error | Compare the tool exception with the message delivered afterward |
| Wrong tool schema | Inspect the tool definitions sent with the request |
| Stale retry state | Compare observations and tool-call IDs before and after retry |
| Bad template | Look for literal placeholders such as {max_words} |
| Step cap | Check whether execution stopped before another model turn |
Laminar's debugger end-to-end guide demonstrates the template case: a missing f-string prefix sends {max_words}, and the model asks which limit to use. For compaction, inspect what survived the summary. Anthropic's long-running-agent guidance notes that compaction does not always pass clear instructions to the next agent.
How to debug an agent harness: a worked example
This test agent answers questions from a runbook fixture. Its deployment commands are fixture content, not instructions for your infrastructure. Laminar's OpenAI instrumentation records model requests and responses; @observe records the tool. The planted bug sits outside that tool span: run_tool silently cuts its result.
import json
import os
from dotenv import load_dotenv
from openai import OpenAI
from lmnr import Laminar, observe
load_dotenv()
Laminar.initialize()
client = OpenAI()
MODEL = os.getenv("DEMO_MODEL", "gpt-5-mini")
MAX_TOOL_CHARS = int(os.getenv("MAX_TOOL_CHARS", "3000"))
TOOLS = [{
"type": "function",
"function": {
"name": "read_runbook",
"description": "Read the on-call runbook for a service.",
"parameters": {
"type": "object",
"properties": {"service": {"type": "string"}},
"required": ["service"],
},
},
}]
@observe(span_type="TOOL")
def read_runbook(service: str) -> str:
with open("runbooks/payments-api.md") as f:
return f.read()
def run_tool(name: str, args: dict) -> str:
result = read_runbook(**args)
return result[:MAX_TOOL_CHARS]
@observe(name="oncall_agent")
def run_agent(question: str, max_steps: int = 6) -> str:
messages = [
{"role": "system", "content": "You are an on-call assistant. Use the tools to answer "
"from the runbook. Quote exact commands."},
{"role": "user", "content": question},
]
for _ in range(max_steps):
response = client.chat.completions.create(model=MODEL, messages=messages, tools=TOOLS)
message = response.choices[0].message
messages.append(message.model_dump(exclude_none=True))
if not message.tool_calls:
return message.content
for call in message.tool_calls:
output = run_tool(call.function.name, json.loads(call.function.arguments))
messages.append({"role": "tool", "tool_call_id": call.id, "content": output})
return "step limit reached"
if __name__ == "__main__":
print("ANSWER:", run_agent(
"payments-api is returning 502s after today's deploy. What is the exact rollback command?"
))
Section 6 specifies deployctl rollback payments-api --to previous --with-migrations --reason "<incident link>". It warns against kubectl rollout undo because that skips the migration rollback.
The tests ran on December 3, 2026, against a local Laminar instance with lmnr 0.9.4 and openai 3.63.0.
Enable debug mode to record the run for replay:
LMNR_DEBUG=true python agent.py 2>&1 | tee run.log
grep 'LMNR_DEBUG_RUN' run.log
The trace and span IDs below belong to this test recording. Substitute IDs from your own run when applying the workflow.
1. Find the first suspicious step
Open the trace in transcript view. This recording contains four LLM calls and three read_runbook calls. The first model response requests the correct runbook. After receiving it, the model requests it again, then a third time, before answering that no explicit rollback command exists.
Repeated reads are a clue, not proof of a model failure. Start with the second LLM call: it is the first request that should contain the answer-bearing document.
2. Read the exact LLM input
Select that span and inspect its input. The tool message stops inside section 5: ...find the leaking pods in the "pool in use" panel a. Section 6 never arrives.
The read_runbook span nevertheless contains the full document. Truncation happens after the observed function returns. Checking only the tool span would conceal the defect.
For a longer trace, search every model input through the SQL editor:
SELECT name, span_type, length(input) AS input_chars,
position(input, 'deployctl rollback') AS in_input,
position(output, 'deployctl rollback') AS in_output
FROM spans
WHERE trace_id = 'd4bba9aa-24be-ab32-88d3-ffdcacc35a8b'
AND span_type IN ('LLM', 'TOOL')
ORDER BY start_time
This query returned in_input = 0 for every LLM span and in_output = 3568 for every tool span. The latter is a position in the recorded JSON output, not the runbook's character offset. Together with the inspected request and truncation code, this establishes that the harness discarded the answer before delivery.
3. Replay with only the harness change
Test whether restoring that information changes the answer. The debugger can serve recorded LLM responses up to a chosen boundary, then continue live. Cache the first response so its decision to read the runbook stays fixed:
LMNR_DEBUG=true \
LMNR_DEBUG_REPLAY_TRACE_ID=d4bba9aa-24be-ab32-88d3-ffdcacc35a8b \
LMNR_DEBUG_CACHE_UNTIL=f7fe3685ef0951e2 \
MAX_TOOL_CHARS=20000 \
python agent.py
LMNR_DEBUG_CACHE_UNTIL identifies the last LLM response to serve from cache, inclusive. The tool executes live. In this example, the new limit applies afterward in run_tool; the next LLM call receives the changed result and runs live.
The experiment included unchanged controls and replays with the limit raised:
| Replay from the same cached first call | Correct rollback command |
|---|---|
| No change (gpt-5-mini, 3,000-char limit) | 0 of 5 |
| Tool output limit raised to 20,000 chars | 5 of 5 |
Four controls denied that the runbook contained a rollback command. The fifth invented a command and offered the forbidden kubectl rollout undo alternative. Every raised-limit replay read the runbook once and returned the correct command, including --with-migrations.
These are counts from one fixture, not estimated production success rates. Each replay produces a new trace in the same debugger session, allowing you to compare requests and responses alongside the original.
4. Test a model change at the same boundary
Additional replays changed the model used for live calls:
| Replay | Correct rollback command |
|---|---|
| gpt-5, 3,000-char limit | 0 of 3 |
| gpt-5-nano, 20,000-char limit | 3 of 3 |
All inherited the first response from the recorded gpt-5-mini run. In the tested SDK, model name is not part of the cache key. These therefore test continuations from a fixed tool-selection decision, not fresh end-to-end runs of each model.
With truncated input, one gpt-5 continuation proposed kubectl rollout undo; another omitted --with-migrations; the third reported no exact command. Changing the model did not recover the required answer in these three runs.
The gpt-5-nano results used complete input, so this table cannot rank the models. The stronger evidence for the harness diagnosis remains the matched gpt-5-mini experiment: the model stayed fixed while delivery changed.
5. Replace the silent cutoff with readable pages
Raising the limit only moves the cutoff. A longer document can still lose its answer.
A marker-only experiment kept the 3,000-character limit and appended [truncated: showing 3000 of 4116 characters]. All three replays crashed. The model attempted unsupported arguments, including _cursor, _include_truncated and __name. Passing them directly into read_runbook(**args) raised TypeError.
That exposes two problems: the model invented arguments, and the harness let invalid arguments terminate the loop. A truncation notice also needs a supported retrieval path.
The tested paged version changed the tool function to:
@observe(span_type="TOOL")
def read_runbook(service: str, offset: int = 0) -> str:
with open("runbooks/payments-api.md") as f:
text = f.read()
page = text[offset : offset + MAX_TOOL_CHARS]
end = offset + len(page)
if end < len(text):
page += (f"\n[truncated: showing characters {offset}-{end} of {len(text)}. "
f"Call read_runbook with offset={end} to read more.]")
return page
The complete change also added offset to the tool schema and made run_tool return read_runbook(**args) without another cut. All three replays read offset=0, then offset=3000, and returned the correct command.
The first response remained cached despite the schema change. This tests paging after the recorded initial choice; a fresh run is still needed to test tool selection with the new schema. Argument validation and error handling also remain separate work.
No evaluation was run for this example. As a next step, test other document lengths and answer locations through an evaluation. With LMNR_DEBUG=true, its per-score averages appear in the debugger session alongside the replays.
When the evidence points toward model behavior
If the exact request contains the needed evidence and usable tool definitions, inspect the response against those requirements. An incorrect answer now supports a different hypothesis than an answer produced without the source text.
Repeat the continuation to see whether the failure recurs. A handful of repetitions does not eliminate sampling uncertainty. Then test one change at a time: keep the request fixed for a model comparison, or keep the model fixed for a prompt change. Repeated improvement supports that intervention on the tested cases; it does not prove the rest of the harness is flawless.
Choose the replay boundary carefully. The cached prefix preserves old decisions. If the suspected defect affected an earlier response, move the boundary earlier or make a fresh recording. This matters for system-prompt changes: a cache hit preserves responses generated under the old instructions.
The ownership boundary can remain shared. Anthropic reported failures involving browser-native alert modals that Claude could not see through the Puppeteer MCP. Inspecting that observation path is useful even when model limitations also contribute. Likewise, clearly present information can become difficult to use in a long context. Test the request construction and the model response rather than assigning blame from the final answer alone.
FAQ
Does replay caching support my provider?
Response caching supports the OpenAI, Anthropic, Google GenAI and LiteLLM integrations in Python, and the AI SDK in TypeScript with models wrapped using wrapLanguageModel. Recording, transcripts and replay work with every Laminar integration, but unsupported caching integrations run every model call live. That removes the fixed-prefix control used here. See debugger caching.
What changes invalidate a cached response?
The cache uses the recorded trace ID and a hash of input messages. In the tested Python SDK, the first system message is excluded; model name and tool definitions are also outside the hash. Changing a user message or tool result causes a miss, after which the remaining calls run live. A cache hit therefore does not establish that the entire request configuration is unchanged.
The setup reference lists accepted boundary identifiers, including full UUIDs, 16-character OpenTelemetry IDs and hex suffixes. Use the last unaffected LLM response as your boundary.
Is Claude Code an agent harness?
Yes, under the broad runtime definition. It packages a model with tools and execution controls rather than leaving you to write the loop. With packaged agents, your ability to inspect or change those controls varies. Start by establishing which request details your instrumentation captures; Claude Code observability covers tracing its sessions and tool calls.
What is harness engineering?
Harness engineering designs the environment and feedback mechanisms around an agent. OpenAI's February 2026 Codex account includes repository documentation, guardrails and enforceable constraints, extending beyond the runtime loop. The practical question is what capability or information the agent lacks and how to make it accessible during execution.
Can I detect these symptoms across production traces?
A Signal pairs a plain-language instruction with a JSON schema to produce structured events for monitoring and alerts. A candidate instruction could flag answers claiming that a requested document lacks information. That detects a symptom, not its cause. Validate the detector on your traces, then inspect each flagged run's model input before attributing the failure.