liveBook · Manning

Agent harness

As explained in Context Engineering

A harness is a surrounding system of guides, tools, constraints, and feedback loops that shapes an AI agent's behavior within an environment.

An agent harness is the software layer around an LLM that enables it to act as an agent. It assembles prompts and context, exposes and executes tools, maintains memory and execution state, and decides how results return to the model. section 1.2.3 section 1.7

The model performs reasoning and generation; the harness connects it to resources such as files, databases, browsers, command-line interfaces, and APIs. Together they support an iterative loop of reasoning, acting, and observing rather than a single prompt-response exchange. section 1.2.3

A function-calling cycle shows how the harness manages the boundary between model reasoning and tool execution:

  • Assemble the user prompt, system instructions, active state, and tool definitions for the model. section 4.2
  • Receive a structured tool call containing a call identifier, function name, and typed arguments; validate and execute the requested function. section 4.2
  • Append the call and its output to the message history, matched by identifier, and call the model again to generate a response grounded in the result. section 4.2
Figure 4.2 Function calling workflow: tool definitions and the user prompt enter the context window, a first model call returns a tool call, the tool executor runs it, and a second model call turns the tool output into the final answer
function calling v9

The workflow traces context assembly, tool execution, and the second model call. section 4.2

Call identifiers let the harness correlate requests and responses, including parallel tool calls within a turn. Each tool interaction requires at least two model calls and expands the active context, so long loops can quickly consume context-window capacity. section 4.2

How Context Engineering covers it

How deep it goes
Defines the harness and traces a function-calling exchange through context assembly, validation, execution, and response generation.
Examples
Traces a structured function call to an external service and its return to the model.
What you can do after
Understand how to trace a harness-managed tool interaction and recognize its context-window cost.
How it connects
Connects context management and orchestration with function calling, memory, and execution state.

Also explained in

Compare how 4 books explain agent harness →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Context Engineering. The section links point to the parts of the book it draws on.