Building a General-Purpose Super Agent Harness: Architecture and Practice
This article examines how a vertical research agent evolved into a general-purpose Super Agent Harness, and why the runtime layer—not prompts or tool calls—determines what an agent system can actually accomplish. It explains the limits of vertical frameworks, outlines a three-layer architecture combining a lead agent, a pluggable middleware chain, and dynamically generated sub-agents, and lists the engineering essentials for production: budgets and termination conditions, idempotency, tiered context storage, human-in-the-loop checkpoints, evaluation loops, and sandbox-based security boundaries.
1. Starting from a Real Evolution Story
A pattern that keeps recurring in agent engineering is this: once a project originally scoped to a vertical use case is opened to a community, the ways people use it quickly exceed what its designers anticipated.
The typical path looks like this. A team first packages its capability as a “deep research” tool that automatically drafts a research plan, gathers information in parallel, cross-validates findings, and produces a structured report with citations. Users then start treating it as a general-purpose foundation: they build data processing pipelines, generate slide decks in bulk, assemble content production chains, and even connect it to internal systems for periodic inspections.
The team drew a key conclusion from this: what users actually depend on is not the “research” layer of business semantics, but the underlying runtime infrastructure that lets an agent get real work done. That led to a complete rewrite. The new version shares no code with the old one, and its positioning jumped from a single tool to a general-purpose Super Agent Harness.
The lesson for developers is clear. If an agent system consists of nothing but “prompts plus tool calls,” it will struggle to carry complex tasks. What really sets the ceiling is the runtime: the layer responsible for state management, context scheduling, tool sandboxing, subtask dispatch, result aggregation, and observability.
2. Why Abstract from a Vertical Framework to a General-Purpose Runtime
The value of a vertical framework is that it works out of the box, but the cost is that business assumptions get baked into the skeleton. Common coupling points include:
- The workflow is hard-coded into a three-stage “plan, retrieve, write” sequence that is hard to reuse outside research scenarios.
- The way context is organized is bound to a specific output format, such as report sections, which makes reuse expensive.
- The tool set and permission model are implicitly tied to particular business systems, so migration means a rewrite.
The abstraction goal of a general-purpose runtime is to hand “what to do” back to the upper-layer agent while consolidating “how to do it reliably” as a platform capability. You can self-check whether a design has genuinely completed the abstraction with three questions: Does changing the business objective require modifying the core orchestration code? Does adding a new class of tools require modifying the main flow? Can a failed subtask be retried locally without affecting the whole? If every answer is “yes, changes are required,” the abstraction is still only skin deep.
3. A Layered Architecture: Lead Agent + Middleware Chain + Dynamic Sub-Agents
A practical general-purpose runtime typically has three layers. The foundation relies on mature state-graph orchestration and model-invocation abstraction capabilities—the common industry approach is to build on graph-based orchestration frameworks that preserve state-machine-style controllable transitions—while the upper layer fills in ready-to-use runtime capabilities.
3.1 The Lead Agent: Decisions and Dispatch Only
The lead agent does not do the heavy work itself. Its responsibilities narrow down to understanding the objective, decomposing it into executable subtasks, selecting the appropriate sub-agents, and making trade-offs and converging at key points. Its context should stay “thin,” retaining only the objective, constraints, completed items, and open questions, so it does not get drowned in intermediate process details.
3.2 The Middleware Chain: Extracting Cross-Cutting Concerns from Business Logic
The middleware chain is a buffer layer between the runtime and business logic. It usually contains a dozen or so pluggable stages that execute in order along the request lifecycle. Typical responsibilities fall into a few groups:
- Context governance: history trimming, summary compression, retrieval result injection and deduplication.
- Tool governance: tool registration, parameter validation, permissions and quotas, timeouts and retries.
- Execution sandbox: code and commands run in an isolated environment with network and filesystem scope restricted.
- State persistence: checkpoint saving to support interruption recovery and human intervention.
- Observability: trace tracking, token and latency statistics, failure attribution.
- Output specification: unified structured output and citation traceability.
A schematic middleware interface can be abstracted as:
class Middleware:def before_model(self, ctx): ... # before the request enters the modeldef after_model(self, ctx): ... # after the model returnsdef before_tool(self, call): ... # before a tool call, for validation and quota checksdef after_tool(self, result): ... # after a tool returns, for truncation and annotation
The value of chaining is that ordering is configurable and behavior is pluggable: insert a logging middleware during debugging, swap in sampling and alerting middleware in production, all without changing business code.
3.3 Dynamic Sub-Agents: Generated from Task Topology, Not Hard-Coded
Sub-agents should not be a fixed enumeration. They should be generated dynamically by the lead agent at runtime according to task needs, with each instance carrying its own context, its own tool allowlist, and its own budget. The key to making the three layers work together is “narrow interfaces, broad implementations”: the lead agent and sub-agents exchange only objectives, constraints, and structured results, while the internal implementation of each sub-agent can be freely replaced.
4. Engineering Implementation Essentials
- Budgets and termination conditions: Set step, token, and duration limits for each subtask to avoid infinite loops that burn resources.
- Idempotency and re-entrancy: Design tool calls to be idempotent where possible, so failed retries produce no side effects.
- Tiered context storage: Keep short-term context in memory, write mid-term summaries and artifacts to object storage, and maintain retrieval indexes separately.
- Human-in-the-loop breakpoints: Insert confirmation nodes before high-risk actions, and rely on the checkpoint mechanism to guarantee rollback.
- Evaluation loop: Use a fixed task set to regression-test changes to prompts, middleware ordering, and tool descriptions, avoiding “fix one thing, break everything.”
- Security boundaries: Isolate the execution environment in a sandbox, grant credentials with least privilege, and keep an audit trail across the entire chain.
5. Conclusion
The move from vertical deep research to a general-purpose agent runtime is essentially about extracting “reliable execution mechanisms” from business semantics and turning them into a platform. The practical advice for developers is to first define the decision boundaries of the lead agent, then consolidate cross-cutting capabilities into pluggable middleware, and finally use dynamic sub-agents to handle parallelism and isolation needs. If you run on the cloud, you can combine a container platform to host sandboxes, object storage to hold artifacts, a message queue to decouple long-running tasks, and logging plus monitoring and alerting services to close the observability loop—gaining a sustainably evolvable agent foundation at relatively low rework cost.
