@tonygentilcore: https://x.com/tonygentilcore/status/2075234683202531403
Summary
Glean's engineering blog details their new agent harness using 100% programmatic tool calling via code execution, which reduces token usage by 24% compared to standard tool calling. The harness manages context with tool truncation and a sandbox filesystem for long-running complex workflows.
View Cached Full Text
Cached at: 07/10/26, 02:11 PM
Building an efficient harness for advanced enterprise work
Agent harnesses are often discussed as a way to help agents take on longer-running, more complex work. @Glean’s agent harness accomplishes this in multiple ways, primarily through context management that lets agents reason effectively across tools, data, and workflows. The harness also supports trace learning, helping agent systems self-improve based on past sessions. Routing allows specialist models to take on the work they’re best suited to handle, so agents achieve high quality outcomes at lower costs.
But harness design isn’t just about making agents more capable. It’s also critical to token efficiency. In this post, we walk through how we moved our harness to orchestrate tools for every query using code, and how this approach proved more efficient, even for simple queries. Compared to our previous approach, it reduced token usage by 24%. We’ll also examine the key design decisions along the way that made those results possible.
Agent harnesses scale best with 100% programmatic tool-calling
The defining feature of Glean’s agent harness is 100% programmatic tool calling. Instead of issuing standard tool calls directly, the model writes code in the agent sandbox, calling Glean capabilities through the Python runtime and tools SDK. Code is a better execution primitive than standard tool calls because orchestration, filtering, looping, and branching can all happen within a single script execution instead of being scattered across multiple LLM round-trips.
In a standard tool-calling loop, every tool input and output gets serialized and deserialized back into the context window. The model calls a tool, the result lands in context, the model reads it and calls the next tool. For a workflow touching dozens of documents across multiple systems, that pattern adds token waste, latency, and reasoning overhead that has nothing to do with the actual task logic.
Our first attempt at programmatic tool-calling was a hybrid approach. Standard tool-calling handled simple, single-step operations, while programmatic tool-calling handled multi-tool work. But requiring the model to decide which mode to use on every turn introduced its own overhead, which ate into the efficiency gains we were trying to achieve. It turns out models are just as good at writing a short script for a single tool call as they are at making a standard tool call.
So we removed standard tool-calling entirely. The shell is now the only tool exposed to the model directly, letting the agent write and run scripts in the sandbox for anything it needs to call. Every other capability, including search, write tools, skills, is exposed through Glean’s tools SDK.
Tool truncation links context with the sandbox filesystem
A coding harness like this needs a sandbox filesystem to hold tool outputs, intermediate steps, data, and reasoning. That output stays on disk between turns instead of flooding model context, which is reserved for high-signal reasoning, decisions, and truncated tool results. Keeping only the most informative parts of a workflow in the context window helps the harness avoid context rot and stay reliable through long-running work that requires complex reasoning over large amounts of data.
Every harness has to decide how much of a tool’s output the model actually sees. If everything stays in context, performance degrades as context accumulates and the model loses attention. If everything gets summarized, the model can lose key information it needs. Over-summarizing has a hidden cost too: since the model doesn’t know the structure of a given tool’s output ahead of time, it can burn tokens just figuring out how to read data from the filesystem.
In Glean’s coding harness, each tool call returns a truncated preview, writes the full output to a file, and tells the model exactly how much content is sitting on disk. The model reads the file directly when it needs more detail, and skips that cost when it doesn’t. This works because once the model sees the structure of a result and a few representative rows or entries, it can infer the rest without needing the entire payload in context. The model just needs to know where the useful output lives and how to get it.
Search and progressive disclosure keep context lean
The coding harness can execute complex workflows with tools at scale, but preloading hundreds of enterprise skills and tools into the context window dilutes attention, decreases reliability, and inflates cost. So we built the harness on a combination of search and progressive disclosure instead.
The harness starts with a minimal set of core tools in the system instructions. This includes just two search tools: one for enterprise context and one for tools and skills. These core tools let the agent find every other resource it needs. When the agent finds a tool or skill through search, it doesn’t see the full content right away. It just sees a lightweight name and description, then reads the full schema or complete set of references only when the task actually calls for it through progressive disclosure.
Search and progressive disclosure are both necessary because they solve different problems. Progressive disclosure lets an agent use a complex resource effectively by reading only the parts of a skill or schema relevant to the task at hand, rather than getting distracted by the rest. But progressive disclosure only helps once the agent knows which resource to use. Search points the agent to the right tool or skill, so when it does dive deeper, it can be confident it’s looking in the right place.
Re-architecting the harness around a core set of search tools introduced its own challenges. Each search surfaces new tools and skills that the model needs to consider, which means the instruction set the model is reasoning over can grow across each turn. If that context were inserted into earlier turns, it would invalidate the prefix cache, the initial portion of a conversation whose attention states LLMs can reuse instead of recomputing. To avoid this, Glean appends search results to the end of the conversation. That lets the model act on newly surfaced tools and skills without invalidating the prefix cache, making responses faster and more cost-effective.
Why coding harnesses fit long-running enterprise work
The move to a coding harness reflects a bigger shift in enterprise AI. Work increasingly means orchestration and automation across dozens of SaaS systems, not just text-based conversation. Cross-system workflows require precise logic and state management, and code satisfies those requirements more directly than tool calls based on natural language.
Coding harnesses are also becoming the most effective model-agnostic option for agentic execution. Frontier models from every leading lab already excel at agentic coding, and open models are catching up fast. Because a wide range of models can drive Glean’s harness, improvements in LLM coding ability translate directly into better agent execution without requiring a redesign. Agent builders can swap models in and out freely as their needs and requirements change.
A coding harness doesn’t just let agents call more tools. It lets them use tools, context, and skills with far greater efficiency and reliability, even at the scale of the 1000+ tools needed to automate an entire enterprise. Paired with a core set of high-precision search tools, Glean’s coding harness becomes the foundation for powerful work agents that complete advanced enterprise workflows with 24% fewer tokens.
Similar Articles
@trq212: https://x.com/trq212/status/2061907337154367865
Claude Code releases dynamic workflows, enabling Claude to create custom harnesses for tasks like research, security analysis, agent teams, and code review, all natively within the tool.
@mfpiccolo: https://x.com/mfpiccolo/status/2060069083878408689
The article argues that current agent harness frameworks like LangChain and CrewAI bundle independent concerns into a monolithic block, leading to inflexibility. It introduces the iii engine, where each responsibility is a separate, swappable worker connected via a shared bus and a single trigger primitive, allowing developers to compose their own harness by swapping workers rather than forking a framework.
@akshay_pachaar: https://x.com/akshay_pachaar/status/2053166970166772052
The article discusses a shift in AI agent tool usage from the 'MCP vs CLI' debate to 'Code Mode,' where agents write code to dynamically import tools, significantly reducing context window usage. It highlights Anthropic's approach and Cloudflare's implementation, demonstrating a 98.7% reduction in token consumption for specific tasks.
@sethkarten: https://x.com/sethkarten/status/2072034978112889328
Continual Harness is a reset-free, self-improving agentic harness that achieves 20.54% on ARC-AGI-3 at a cost of $774 by storing memories, reusing skills, and refining its prompt, outperforming prior baselines like Hermes and OpenClaw with greater efficiency.
@jasonzhou1993: I gave my coding agent a map across 3 of my repos: - Reduce ~50% token - a grep hook so every grep call has much richer…
Jason Zhou shares a technique to give coding agents a map across repos, reducing token usage by ~50% and enabling richer grep and call chain tracing. He also releases a Claude Code plugin marketplace called AI Builder Club Skills for setting up codebase harness and compounding agent loops.