What Is an Agent Harness? How Glasslake Built Its Own

Learn what an agent harness does and how Glasslake uses model failover, run transcripts, and EU processing to keep AI agents reliable for SAP teams.
Connected blue nodes around a central white node on a dark blue background.

In this article

By Sanket Jain

An agent harness is the software that runs an AI agent around its model. It manages the loop between model calls, executes tools, records what happened, enforces limits, and decides when to stop.

At Glasslake, our AI agents help SAP implementation teams. We built our own harness so we could keep customer workflows running through provider outages, trace what each agent did, and control where model calls and code execution happen.

Why did Glasslake build its own agent harness?

For a year, we used a hosted harness that ran the agent loop, kept the session, and provided a sandbox. It helped us get started. As customers moved into production, we needed control over three decisions that the hosted service made for us.

  • What happens if a model goes down? We needed a backup configured for each agent, along with control over rate limits and retries.
  • How do we trace and manage a run? We needed a record of the whole turn, including tool calls, so we could debug failures, attribute costs, and change prompts without a code release.
  • Where does processing happen? Some customers needed model inference and sandbox execution to stay in the EU.

We compared five approaches across 26 criteria and chose a stack with replaceable components. Glasslake owns the decisions that affect reliability, cost, and customer data. Existing libraries and managed services handle the parts we can swap out.

We considered a graph-based framework with its own checkpoints and a fully custom set of model adapters. The first would have added a second layer for recovering runs alongside Temporal. The second would have meant maintaining integrations that existing libraries already handle. We kept workflow recovery in Temporal and separated the model adapters from the rest of the harness so we can change them independently.

How does the agent harness work?

Each user turn starts a durable workflow in Temporal. The agent loop runs on deepagents, and our model layer uses Pydantic AI to connect to providers through a common interface. Glasslake controls which models the agent can call, which tools it can use, and when it should stop. Postgres stores the transcript and configuration. An isolated sandbox runs code and handles files.

Glasslake agent harness connects client applications to model providers, customer tools, a code sandbox, and Postgres.
The model layer, tool dispatcher, and transcript give the harness control over each turn.

Every model call goes through an ordered list of models. Every tool call goes through a dispatcher that checks the agent’s allowlist. We record each step so we can see which model answered and what tools ran. Sub-agents get their own runs, which lets us track their costs and stop them individually.

Keeping the transcript in a format we control also makes failover possible mid-run. The next provider can pick up from the recorded messages and tool results. The same record helps us investigate a customer issue without piecing together separate logs from every provider.

A shared rate limiter checks every model call across our workers. The agent loop trims large tool results and compacts long conversations to keep them within the model’s context window. Each step records which model answered, so an increase in the share of calls served by a backup can alert us to a provider incident.

What can an AI agent access?

Every agent has a tool allowlist that the harness checks before execution. For example, if an agent requests a tool outside its allowlist, the dispatcher refuses the call before the tool runs. When an agent runs code, its sandbox session gets an isolated microVM with a disposable disk.

We also separate retrying a model call from replaying a whole turn. Each turn is configured for one workflow attempt because automatically rerunning the whole turn could repeat a tool action. We handle retries for operations that write to external systems at the tool level.

What happens when a model provider fails?

The harness switches to the next model when a call fails for a reason another model may be able to handle, such as throttling, a timeout, or a provider outage. Once a run switches, later calls in that run stay on the backup. The next run starts on the primary model again. A malformed request is surfaced because switching providers would leave the error unresolved.

During a 24-hour incident on our EU stack, calls to one model failed about 40% of the time. Every affected turn still completed using its configured backup. The first call to a backup can cost more because it needs to rebuild the prompt cache. We accept that cost to keep critical workflows running.

If a response stream breaks mid-answer, the harness first retries the same model and discards the partial text so the response doesn’t contain duplicate output. If no model in the chain can serve the request, the turn ends with a clear message.

How does the harness support EU data residency?

For sessions configured for EU processing, the harness routes model calls to EU endpoints and runs the sandbox in the same region as the agent workflow. The EU agent configuration uses the same prompts and tools. We tested all 51 model settings from a machine set to a US region and confirmed that every test call was served from Europe. The cloud logs showed all agent invocations in Frankfurt and none in the US region. Model requests can be served from more than one European region.

The transcript stays in Glasslake’s database under our access and retention controls. Models receive the input they need for each call. Our own transcript format lets us change model providers without moving the durable record of the run.

What does owning the harness cost?

We maintain the orchestration code and monitor provider incidents. We also own write safety. If a tool creates a ticket and the response is lost, retrying the call must avoid creating a duplicate. We are adding a unique key to each writing tool so that it can recognize a repeated request. In return, we can change a model chain without deploying code, trace a turn from request to result, and configure where a customer’s agent work runs.

Build with us

If you’re an engineer or researcher who wants to make AI agents more reliable in production, help us build systems that SAP implementation teams can depend on. Explore careers at Glasslake.

Contact us

Bring clarity to your next SAP transformation.

Tell us what you’re working on. We’ll show you how your team can accelerate with agentic AI.

Ask AI about Glasslake