AI Agent Architecture Design: Thin Harness, Fat Skills, and the Memory Loop
This article explains how to structure AI agents around three complementary layers: a thin, domain-agnostic harness that governs execution, fat skills that encapsulate domain work, and a memory layer that turns experience into a controlled feedback loop. It clarifies what "thin" and "fat" actually mean, why reusable skills do not guarantee deterministic output, what memory should store and how to keep it from degrading, and how the three layers form a verifiable loop. It also covers commonly overlooked engineering pitfalls and how to measure whether memory genuinely improves agent performance. Readers will learn practical criteria for drawing responsibility boundaries, designing skill contracts, governing memory, and keeping the system maintainable, auditable, and correctable as rules and environments change.
1. What “Thin Harness, Fat Skills” Actually Solves
A common starting point when building an agent is to concentrate all logic in a single runtime framework: task understanding, tool selection, business rules, error retries, user preferences, and output formatting are all handled by one ever-growing body of flow-control code.
This design is straightforward in a prototype, but problems surface as scenarios expand: adding a capability requires modifying the core flow, different business rules interfere with one another, the testing surface keeps widening, and eventually even a local change can trigger a chain of side effects.
“Thin Harness, Fat Skills” is first and foremost an engineering principle about separation of responsibilities:
- The harness is responsible for running tasks safely and in order.
- Skill modules are responsible for work with clear business semantics.
- Domain knowledge, operating steps, and validation rules should live as close as possible to the relevant skill, rather than piling up in the core scheduling logic.
Here “thin” does not mean the fewer lines of code the better, and “fat” does not mean the more skills the better. What actually needs to be controlled is the responsibility boundary: stable, general-purpose mechanisms stay in the framework, while frequently changing domain capabilities are encapsulated in skills.
If the framework is small but pushes permission checks, error handling, and state management onto each skill to implement on its own, the result is not good modularity but scattered, hard-to-govern duplicated logic.
2. The Harness: Stay Domain-Agnostic, but Do Not Abandon Runtime Governance
The harness can be understood as the agent’s runtime skeleton. It typically handles foundational capabilities such as task state, model invocation, skill execution, budget control, and exception recovery.
A sound harness should answer several questions:
- What stage is the current task in?
- Which capabilities can be invoked next?
- Does the invocation comply with permission and resource limits?
- After a failure, should it retry, degrade, or terminate?
- Does the final result meet the delivery conditions?
These questions exist across virtually all business scenarios, which makes them suitable for unified handling by the framework.
For example, an agent that reads documents and generates a report differs from one that queries business records and organizes anomalies in its concrete processing, yet both need timeout control, invocation logging, error classification, and result validation. If every skill reimplements these mechanisms, the system becomes hard to keep consistent.
The Criterion for “Thin” Is the Degree of Coupling
Whether a framework is “thin” enough cannot be judged by lines of code alone; it is better observed by asking:
- When adding a domain skill, do you need to modify the core execution loop?
- When updating a business rule, does it affect other domains?
- When a skill fails, can it be handled through a unified error convention?
- Can permission, logging, and budget policies be managed centrally?
A thin framework can therefore contain fairly complete governance capabilities; it simply should not hold too many concrete business details.
In particular, permission control, sensitive-data protection, and approval of high-risk operations must not be pushed outside the trusted execution boundary in the name of being “thin.” A skill may declare what permissions it needs, but whether those permissions are ultimately granted should be decided by an independent, trusted mechanism.
3. Skills: “Fat” Means Domain Encapsulation, Not Accumulated Quantity
A skill module is not necessarily just a function. Depending on the nature of the task, it can include operating instructions, input/output constraints, tool-usage methods, examples, validation rules, and any necessary supporting resources.
A mature skill should at minimum make the following explicit:
| Element | Question to answer |
|---|---|
| Applicability | Which tasks should invoke it, and which are unsuitable |
| Input constraints | Which fields are required, and which conditions must hold |
| Execution method | Which steps or tools accomplish the work |
| Output constraints | What structure is returned, and how uncertainty is expressed |
| Failure semantics | Which errors are retryable, and which require stopping |
| Side effects | Whether it modifies data or triggers external operations |
| Permission requirements | Which resources it needs to access |
| Version information | Which implementation version the current behavior corresponds to |
The point of a “fat skill” is to encapsulate the domain task completely enough. For example, “validate a business record” should not be merely a prompt asking the model to check carefully; it should specify the checking dimensions, how to handle missing fields, evidence requirements, and the return rules when a judgment cannot be made.
But skills also cannot expand without limit. A huge module that simultaneously handles retrieval, analysis, data modification, and user notification may simply be relocating a complex monolith.
A more reasonable basis for division is task cohesion and dependencies:
- Steps that are tightly related under the same goal can be encapsulated together.
- Capabilities that can be independently verified and independently authorized should be separated as much as possible.
- Skills compose through explicit inputs and outputs, not by relying on hidden state.
The “fatness” of a skill is therefore reflected in sufficient domain expression, complete contracts, and clear validation, not in blindly increasing the number of modules or the length of prompt text.
4. A Necessary Clarification: Reusable Skills Do Not Mean Absolutely Deterministic Output
When discussing skills, it is easy to interpret “the capability will not be lost” as “the same input always yields the same output.” These two propositions are not equivalent.
A skill definition can be persisted, but execution results may still be affected by many factors:
- Model generation is stochastic.
- Retrieved content and external data change.
- Service state, time, and permission context differ.
- The models, rules, or tools a skill depends on are updated.
Strong result reproducibility is possible only when inputs, dependencies, environment, and execution method are all appropriately constrained. For purely deterministic processing logic, the same input usually produces the same result; for skills involving model reasoning and dynamic queries, a more realistic goal is explainable behavior, verifiable results, and handleable failures.
Engineering reliability should not be bet entirely on “identical output,” but built on the following mechanisms:
- Use structured constraints to reduce ambiguity.
- Use business rules to check key results.
- Add idempotency protection for external write operations.
- Add human confirmation for high-risk actions.
- Record dependency versions and execution evidence to support issue tracing.
For read-only tasks, allowing some variation in expression is usually fine; for operations involving funds, permissions, or data modification, key actions must be handed to a constrained, auditable execution mechanism.
5. Why Framework and Skills Alone Are Not Enough to Accumulate Experience
The framework provides the execution mechanism and skills provide task capabilities, but neither naturally lets the system gain experience from usage.
If the same skill is invoked many times but the execution records are never analyzed, useful experience is never extracted, and later invocations do not use that experience, then the system is merely repeating tasks.
Three things need to be distinguished here:
- Preserving history: recording what happened.
- Forming memory: extracting information that may be useful in the future, and establishing retrieval and update mechanisms.
- Changing capability: altering the skill or model itself through version updates, rule adjustments, or training.
The three are related but are not the same thing.
Saving a complete conversation does not mean the system knows what content matters; retrieving a past failure does not mean it will adjust its behavior; using memory to improve one task is not the same as the model’s parameters having learned.
So beyond “thin harness, fat skills,” introducing a memory layer creates a controllable feedback channel for task execution. This is a complement to the architecture and does not mean every agent must be equipped with complex long-term memory.
For stateless data transformation or strict rule validation, framework plus skills may already be enough. For systems that collaborate over the long term and repeatedly handle similar problems, the benefits of memory are more evident.
6. What the Memory Layer Should Store, and How to Keep It From Piling Up
Effective memory is not an infinitely growing repository of history, but a set of states that have purpose, evidence, and a lifecycle.
1. Working Memory: Serving the Current Task
Working memory records the current goal, completed steps, intermediate results, and open problems, used to prevent the flow from breaking.
After a task ends, much of this content can be cleared directly. Its value lies in supporting execution continuity, not in long-term retention.
2. Preference Memory: Influencing Interaction Style
For example, a user explicitly wants a report to list conclusions first, then the supporting evidence.
Such information can influence presentation, but it should not override factual accuracy, permission limits, or safety requirements. A one-time request to “answer briefly” cannot automatically be inferred as a permanent preference.
3. Episodic Memory: Retaining Key Events and Evidence
For example, the reason a task failed was that the source data lacked a required field, not that the processing steps were wrong.
This kind of memory should include task context, time, evidence source, and applicable conditions; otherwise, when a similar problem arises next time, an old conclusion may be wrongly applied.
4. Procedural Experience: Distilling Reusable Handling Advice
For example, before processing a certain type of record, check field completeness first, then aggregate.
Such experience can help with planning, but it should be validated. A single success may be coincidental and cannot be directly elevated into a default rule.
Memory Must Allow Correction and Expiration
Business rules, user preferences, and data environments all change. Long-term memory should carry update time, applicable scope, confidence, source, and expiration conditions.
Common governance methods include expiration cleanup, duplicate merging, conflict marking, and user-initiated deletion. However, data subject to audit or compliance retention requirements should follow the corresponding retention policies and cannot be deleted purely based on access frequency.
The engineering meaning of “forgetting” is to reduce the influence of irrelevant or outdated information on decisions, not to unconditionally wipe history.
7. How the Three Layers Form a Verifiable Loop
A practical execution loop can be described as:
task input → permission and scope check → retrieve relevant memory → select skill → execute and validate → deliver result → extract candidate experience → review and update memory.
There are two important boundaries here.
First, retrieved memory is only supporting information and cannot automatically acquire the status of an execution instruction. Historical text may contain wrong conclusions or malicious instructions and must be distinguished from trusted rules.
Second, experience produced after a task ends is only a candidate and cannot be written to long-term memory just because the model produced a summary.
The following is illustrative pseudocode, not a specific product interface:
function handle_task(task, actor):scope = authorize(actor, task)context = retrieve_memory(task, scope)plan = create_plan(task,available_skills(scope),context)result = execute_with_limits(plan, scope)verdict = validate_result(task, result)save_execution_record(task, plan, result, verdict)if verdict.accepted:candidates = propose_experience(task, result)approved = review_candidates(candidates, scope)update_memory(approved)return deliver(result, verdict)
In real implementations, validation cannot rely solely on model self-assessment. Whatever can be confirmed through field constraints, computation checks, business rules, or human feedback should preferentially use that evidence.
In addition, failed tasks may also produce valuable experience, but you should record the confirmed cause of failure rather than unverified guesses.
8. From an Engineering Standpoint, Which Problems Are Most Easily Overlooked
1. Skill Discovery Gets Harder as Scale Grows
As the skill catalog grows, similar names, vague descriptions, or overlapping functionality can all lead to routing errors.
You should establish clear applicability and exclusion conditions for skills and filter candidate skills by task scope. Do not assume that putting all skill descriptions into the context will let the system reliably select the right one.
2. Memory Can Bring Negative Returns
Irrelevant memory consumes context, outdated experience misleads decisions, and wrong preferences make the system over-cater to the user.
Memory retrieval should jointly consider relevance, timeliness, trustworthiness, and applicable scope. When no reliable memory is retrieved, falling back to a validated default flow is usually safer than forcibly using historical experience.
3. Self-Reinforcement Can Amplify Early Errors
If the system treats its own output as fact and then writes those “facts” into memory, errors can accumulate across subsequent tasks.
Writing experience requires external evidence or explicit feedback, and the source should be preserved. Changes to important rules should also go through review, testing, and version management.
4. Multi-User Environments Must Isolate Memory
User preferences, organizational experience, and global rules belong to different scopes. The system needs to make clear what applies only to the current user and what can be reused within an organization.
Access control must also be enforced at the retrieval stage. You cannot first retrieve all memory and then rely on the model “not leaking” sensitive content.
5. Experience Cannot Bypass High-Risk Operation Constraints
“It worked this way last time” does not constitute a new authorization. Regardless of historical experience, external write operations, sensitive-data access, and irreversible actions must all re-check current permissions and approval conditions.
9. How to Prove That Memory Actually Makes the Agent Better
Continuous improvement requires evidence, not just judgment based on interaction experience.
You can set up a baseline that does not use long-term memory, then compare on the same task set:
- Task completion rate and result correctness.
- Number of invalid calls and repeated attempts.
- Proportion of human intervention.
- Execution latency and resource consumption.
- Relevance of memory retrieval.
- Mistakes caused by outdated or wrong memory.
- User-preference adherence and privilege-escalation incidents.
You should also run targeted tests: disable a certain type of memory, change the retrieval count, or introduce outdated information, and observe whether results change. Only then can you tell whether the gains come from skill improvements, process optimization, or memory itself.
For critical business, you should retain skill versions, model configurations, memory references, and validation results so that anomalies can be traced and the system can roll back to a validated state.
10. Conclusion: Make Capabilities Modular, and Make Experience Evidence-Based
The core of “thin harness, fat skills” is neither to make the framework as simple as possible nor to give the agent as many skills as possible, but to govern general-purpose execution mechanisms separately from domain capabilities.
The harness ensures execution has boundaries, skill modules ensure capabilities are reusable, and the memory layer provides experience feedback in applicable scenarios. Combined, the three give the system a chance to gradually reduce repeated errors, improve interaction, and optimize execution paths while remaining controllable.
But memory is not a substitute for reliability, and past success is no guarantee of future correctness. A truly mature agent should give every capability a clear contract, give every piece of experience a traceable basis, and make every behavior change subject to validation.
The ultimate standard for measuring architecture quality is not the number of components, but whether new capabilities can be integrated at low cost, whether failures can be located, whether experience can be used safely, and whether the system remains maintainable, auditable, and correctable as rules and environments change.
