The Agent Stack and the Harness Concept

An AI agent is defined as a large language model (the reasoning core) plus a harness (the surrounding infrastructure). Because the model's weights are frozen and nondeterministic, the developer's primary leverage lies in the harness. Harness engineering is the practice of building the memory, tools, and perception layers that wrap the model to ensure consistent, repeatable outcomes.

The Seven Layers of an Agent Harness

To build a robust agent, developers should structure their harness around seven distinct layers:

  1. Storage Layer: Determines where data and memory physically reside.
  2. Memory Engineering: Handles encoding, search, and retrieval mechanisms.
  3. Semantic Layer: Manages institutional knowledge and the specific vocabulary the agent assumes as its "Umwelt" (perceptual lens).
  4. Agent Loops: The logic governing how the agent iterates on tasks.
  5. Context Engineering: Techniques to keep the context window salient and relevant.
  6. Gateway/MCP Layer: Connects the agent to external tools and data sources.
  7. Skill/Workflow Promotion: The process of distilling successful task executions into reusable workflows.

Memory: Files vs. Databases

There is a persistent tension between using files (which match model instincts and POSIX standards) and databases (which offer ACID consistency).

  • Files: Easy to append and manipulate, but lack transactional consistency. When multiple agents work on the same file, they risk trampling each other. The solution is to use work trees—allowing agents to branch their progress and merge only upon completion.
  • Databases: Provide ACID compliance, high availability, and efficient vector search.
  • The Hybrid Approach: The most effective systems use a hybrid model. Short-term, ephemeral data (like active to-do lists) can live in files, while long-term, structured data (user preferences, successful workflows) should be promoted to a database.

Skill Promotion and Continual Improvement

Agent memory is not just about storage; it is about refinement. A key concept is "skill promotion": when a complex task is solved, the workflow should be distilled into a reusable template. This allows the system to improve over time, ensuring that a task that originally took four hours becomes faster and more reliable in future iterations.

Key Takeaways

  • Control the Harness, Not the Model: Accept that the LLM is a black box. Focus your engineering effort on the data and memory layers surrounding it.
  • Use Work Trees for Concurrency: If your agents operate on files, implement work trees to avoid data corruption and race conditions.
  • Adopt a Converged Database: Avoid the overhead of managing multiple databases for vectors, JSON, and relational data. Use a single engine to simplify security and data synchronization.
  • Implement Hysteresis: Use a hysteresis variable to define how much patience the harness should extend to a model before abandoning a task or switching strategies.
  • Prioritize Context Salience: Actively manage the context window to keep only the most relevant information, preventing context rot and quadratic attention overhead.