跪拜 Guibai
← All articles
AI Programming

The Bare LLM API Is a Stateless Function; an Agent Harness Gives It Memory, Hands, and a Loop

By 浪遏 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

The gap between a powerful model and a useful coding agent is entirely engineering, not model capability. Understanding the harness as a system of decoupled organs lets teams build agents that survive real-world chaos, swap providers without rewrites, and enforce constraints like keeping source code local while still using the strongest cloud models.

Summary

Calling an LLM API directly gives you a pure function: text in, text out. It cannot remember previous turns, cannot read files or run commands, and stops after one response. These three limitations prevent it from completing any real multi-step task like fixing a bug. The engineering system that patches these gaps is called a Harness. It stores conversation history to simulate memory, provides tools the model can invoke to take real action, and wraps everything in an Agent Loop that cycles through think-act-observe until a goal is met. The model is the engine; the harness is the chassis, transmission, and steering that let it drive. A production harness like the catbuddy project splits these responsibilities into six decoupled organs—heart, hands/feet, eyes, memory, resilience, and advanced capabilities—each responsible only to its interfaces, so changes stay locked inside one module.

Takeaways
A bare LLM API call is a stateless text-completion function with three inherent limitations: no memory, no ability to execute actions, and no self-advancement.
Multi-turn conversation is an illusion maintained by re-feeding the entire history on every call.
An Agent Harness patches these gaps with stored history, a tool-execution layer, and an Agent Loop that cycles through think-act-observe until the task is done.
The core of any agent is a while-loop that calls the model, executes any tool requests, feeds results back, and repeats until the model signals completion.
catbuddy's harness splits responsibilities into six decoupled organs: heart (loop), hands/feet (tools), eyes (context), memory, resilience, and advanced capabilities.
Each organ depends only on interfaces, not implementations, so swapping a model provider or adding a tool requires no changes to the rest of the system.
A local-first constraint—source code never leaves the machine—forces design trade-offs like a file-agnostic Gateway, local JSONL storage, and workspace sandboxing.
Conclusions

Stronger models increase the burden on the harness, not decrease it, because they invite longer, riskier tasks that demand more robust loops, context management, and error recovery.

The local-first architecture—using your own API key to cloud models while keeping all file operations local—is an under-explored middle path between pure-cloud tools and weak local models.

Decoupling organs by interface rather than implementation is what lets a harness both run in production and absorb new features without cascading breakage.

Concepts & terms
Agent Harness
The engineering system wrapped around a large language model that transforms one-shot text completion into continuous, task-completing agent behavior. It comprises memory management, tool execution, and an agent loop.
Agent Loop
A while-loop that repeatedly calls the model, executes any tool requests the model emits, feeds the results back into the conversation history, and continues until the model signals task completion. It is the core mechanism that turns a stateless function into a self-advancing agent.
Local-First Agent
An architecture where the agent process runs on the user's machine and performs all file operations locally, while using the user's own API key to call cloud models for reasoning. Source code never passes through a third-party server.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗