Building an efficient harness for advanced enterprise work

This post details the re-architecture of Glean's agent harness to use 100% programmatic tool-calling via a Python runtime and tools SDK within an agent sandbox. This shift replaces standard tool calls with code execution, enabling complex orchestration (filtering, looping, branching) within a single script. Key design decisions include using the shell as the only directly exposed tool, exposing other capabilities via the tools SDK, and implementing a sandbox filesystem for intermediate outputs. Tool outputs are truncated in context, with full outputs written to disk. The harness uses search and progressive disclosure to manage tool discovery and context, appending search results to the end of the conversation to preserve prefix cache efficiency. This approach reduced token usage by 24% compared to the previous hybrid model.
More from the Agent Orchestration Platform trail
- AI Agents for Financial Compliance: How Enterprise AI Is Solving the Regulatory Reporting Challenge
- From enterprise search to enterprise context: what AI agents actually need
- Scale AI usage without runaway spend with Glean’s AI usage controls
- Glean Agents can now work independently, build faster, and stay governed at scale
- Glean expands horizontal, agent platform with open agent interoperability, dozens of personal and business agents, and comprehensive AI security