Making AI Agents More Usable: Memory and Execution Architecture Best Practices
This article explains how to evaluate and improve the usability of AI agents by focusing on execution reliability rather than one-off task completion. It covers a four-layer memory model that turns raw conversation logs into verifiable knowledge, using core documents as execution contracts, governing skills by stability and reuse scope, capturing preferences as executable boundaries, building fault tolerance and security controls, and validating architecture changes through evaluation. Readers will find a practical, staged rollout plan for building agents that retain the right information, reuse proven workflows, and know when to stop and ask for confirmation.
1. Judging Whether an Agent Is Usable Starts with a Reliable Execution System
When discussing the user experience of an agent, it is not enough to look at whether it can complete a complex task once. For developers and enterprise users, the more important questions are: can similar tasks be completed reliably, are user corrections retained, can the system recover after an error, and is the execution process transparent enough?
Even an agent with strong language understanding may run into the following problems in real work:
- It asks again about preferences that have already been confirmed in every conversation.
- It finds the right tool but fails to follow project constraints.
- It treats a one-off successful workflow as a general method.
- It mistakes a temporary instruction for a long-term requirement, affecting later tasks.
- After a failure, it keeps repeating the same operation with no exit mechanism.
These problems usually cannot be solved by adding more to the prompt. A more effective approach is to split the system into task orchestration, memory management, skill execution, and safety governance, then define the information flow and control relationships between them.
A general execution pipeline can be expressed as:
User submits a task → identify the goal and boundaries → retrieve necessary memory → select an execution skill → check permissions → execute and verify → report results → extract reusable experience.
The key here is not to make the agent “remember more,” but to let it use the right information at the right time and be able to explain why a particular approach was chosen.
2. Upgrading Memory from a Conversation Archive to a Verifiable Knowledge System
1. Conversation logs are not the same as effective memory
Raw conversations contain a lot of repeated phrasing, tentative opinions, and conclusions that are no longer valid. Putting the entire history into the context window not only increases processing cost but also drowns important constraints in noise.
Therefore, a memory system should distinguish between “what happened” and “how to act in the future.” The former is for traceability, the latter for decision-making, and the two should not be conflated.
Memory can be organized into four logical layers. This layering is a design proposal, not a fixed standard adopted by all agent systems.
Layer 1: Raw events. Store task requests, key operations, execution results, and user feedback. This layer should preserve facts as much as possible and avoid over-interpretation, while applying necessary redaction and access control.
Layer 2: Task summaries. Aggregate related events into task-level records describing the goal, environment, methods attempted, final result, and reasons for failure. Aggregation can be based on task identifiers, time ranges, or content relevance, but different project constraints under similar topics should not be merged.
Layer 3: Structured experience. Extract preferences, conditions, applicable scope, and exceptions from summaries. For example, “before modifying configuration in production, first verify the impact and prepare a recovery plan” is more actionable than “the user is cautious.”
Layer 4: Candidate skills. Organize steps that have been repeatedly validated into reusable procedures, including input requirements, execution order, checkpoints, and failure branches.
This structure forms two interrelated loops:
- Memory loop: events are filtered and corrected, then settle into reliable knowledge.
- Skill loop: knowledge is turned into execution procedures, and execution results are used to revise the knowledge.
2. Conclusions distilled by the large model should not be treated directly as facts
Large models are good at summarizing records, spotting repeated patterns, and generating candidate rules, but they may also mistake correlation for causation or expand a single piece of feedback into a universal preference.
Therefore, each important memory entry should contain at least:
- Content: the specific fact or rule.
- Source: the corresponding task record or user confirmation.
- Scope: which project, role, or environment it applies to.
- Status: pending confirmation, confirmed, or expired.
- Time: creation time, last verification time, and any necessary validity period.
- Sensitivity level: whether cross-task reading is allowed.
For explicit user instructions, they can be recorded directly as confirmed constraints; for preferences inferred by the model, they should be kept as candidates and should not immediately affect high-risk operations.
3. Memory should be updatable and deletable
Memory quality is not determined by the number of entries. A usable system must have mechanisms for merging, expiring, correcting, and deleting.
For example, if a project once required a specific directory structure and later completed a migration, the old rule should be marked as expired rather than retrieved alongside the new rule. After a user withdraws a preference, the system should not continue to restore that preference based on an old summary.
Retrieval should jointly consider content relevance, applicable scope, confirmation status, and timeliness. Matching similar text is only the first step; whether it fits the current task is the final basis for judgment.
3. Core Documents Should Be Execution Contracts, Not Prompt Warehouses
1. Set up a unified entry point for rules
When a system contains memory, scripts, skills, and tools at the same time, it needs a unified entry point that explains how these components work together.
The core document should answer the following questions:
- Which tasks can be executed automatically, and which require confirmation?
- When information is missing, should the system ask the user or apply a default?
- How should skills be selected, and when is combining multiple skills allowed?
- After execution, which results must be verified?
- On failure, how should it retry, roll back, or terminate?
- Which information can be written to long-term memory?
The rules entry point should not be stuffed with all technical details. A more reasonable approach is to keep the key constraints and reference separate skill catalogs, memory specifications, permission policies, and reporting templates.
2. Document constraints need enforcement mechanisms
Writing “do not delete important files” in a document does not mean the system has deletion protection. For high-risk operations, additional measures are needed on the tool side, such as permission checks, approval mechanisms, pre-execution previews, or isolated environments.
Therefore, two types of constraints should be distinguished:
Behavioral constraints guide how the agent thinks and organizes tasks, for example inspecting the environment first, stating assumptions, and reporting uncertainty.
Enforced constraints are implemented by the execution layer, for example restricting accessible directories, prohibiting unauthorized reads, and requiring human confirmation for irreversible operations.
The core document declares the rules, the execution layer enforces them, and logs provide the basis for verification. All three are indispensable.
3. Define the order for handling conflicts
Project constraints, long-term preferences, temporary requests, and historical experience may conflict with one another. Without a clear priority, the agent tends to pick the rule that is easiest to retrieve rather than the one that best applies.
The following principles can be adopted:
Safety and permission boundaries come first; within those boundaries, the current explicit instruction takes precedence over historical preferences; project rules take precedence over generalized experience; candidate memory must not override confirmed constraints.
If two valid rules still cannot both be satisfied, the system should point out the conflict and ask for clarification rather than silently choosing one.
4. The Focus of Skill Tiering Is Governance, Not Fixed Ratios
1. Tier by stability and reuse scope
Skills can be organized into four categories: foundational, general, specialized, and experimental, but there is no need to set a fixed proportion for each tier. The number of skills, invocation counts, and business value are different measurement dimensions and should not be mixed.
Foundational skills target frequent, well-defined operations, such as file reading, directory checks, and result validation. They should have clear input and output boundaries and prioritize predictability.
General skills solve cross-project problems, such as task decomposition, fault localization, and change review. They need to handle different contexts while avoiding carrying implicit project assumptions.
Specialized skills serve a specific business or technical domain. Their value is not necessarily lower than that of general skills; they simply have a narrower scope.
Experimental skills are used to validate methods that are not yet stable. They should be explicitly marked and limited to low-risk or recoverable scenarios.
2. Skill promotion requires evidence
Invocation count can be a reference, but it should not by itself determine whether a skill is mature. A procedure that is repeatedly invoked may simply be the only option available, which does not mean it is reliable.
More reasonable promotion conditions include:
- Repeated success within a well-defined scope.
- Input requirements and failure conditions clearly documented.
- Reuse capability validated across different tasks.
- No dependence on undeclared environment state.
- Presence of check steps and necessary recovery paths.
- Confirmation of value through user feedback or human review.
The observation period and invocation threshold can be set according to the business, but they should be labeled as internal governance rules rather than universal technical standards.
3. Skill descriptions should guide execution
A practical skill entry should contain at least the goal, preconditions, steps, verification method, and exception handling.
For example, “check a configuration change” should not be just a list of operations; it should also explain whether the source of the input configuration is trustworthy; whether the check concerns format, logic, or runtime behavior; whether to stop after finding a conflict; and how to recover if verification fails.
In addition, skills need a retirement mechanism. When the environment changes, dependencies fail, or the success rate drops, automatic invocation should be suspended and restored only after re-validation.
5. Reducing Repeated Corrections with Preference Boundary Tables
1. Move from abstract preferences to executable boundaries
When a user says “keep answers concise,” it usually does not mean removing key evidence; when a user says “handle it automatically,” it does not mean allowing arbitrary changes to production.
Therefore, a preference record should describe both the expected behavior and the unacceptable behavior. For example:
Expected: prioritize giving an actionable solution.
Boundary: do not omit key preconditions, and do not present unverified judgments as definite conclusions.
Such paired records help turn vague expressions into checkable behavioral requirements.
2. Opposite preferences are not necessarily strict logical complements
In real language, “concise” and “detailed” are not mutually exclusive in all situations. The same user may want a detailed troubleshooting report but a brief daily progress update.
Therefore, it is not advisable to model all preferences as simple binary flips. A more robust structure is:
Preference dimension + applicable scenario + expected degree + prohibited items + exception conditions.
For example:
“When addressing non-technical readers, give the conclusion first, then add necessary explanation; for code review, retain the basis for issues and the risk description.”
When a user chooses the opposite direction on a given occasion, the system should first judge whether a new scenario has appeared, rather than directly overwriting the existing preference.
3. Corrective feedback should go through a scope judgment
Every correction is worth analyzing, but not all of it should be written to long-term memory. The system can distinguish:
- Factual correction: fixes incorrect knowledge.
- Project constraint: limited to the current project.
- Long-term preference: applies across multiple interactions.
- Temporary instruction: affects only the current task.
For feedback whose scope is unclear, it can first be stored in task memory, and the user can be asked whether it should take effect long-term when necessary.
6. Building Fault Tolerance and Security Boundaries for Execution
1. Failure handling should have a clear exit
When an agent fails, it should not retry indefinitely. The handling method should be chosen based on the error type:
Temporary faults can be retried a limited number of times; missing input requires additional information; insufficient permissions should stop execution with an explanation; when the result does not match expectations, the intermediate state should be checked first before deciding whether to roll back.
Each retry should also state what changed. If the input, environment, and strategy are all unchanged, repeating the execution usually brings no new value.
2. Distinguish trusted instructions from external content
Web pages, documents, and tool return values may contain text that appears to be commanding, but they are essentially data to be processed and should not automatically gain the authority to modify execution rules.
Memory writes need the same protection. External content should not enter long-term preferences or core rules merely because it was read. Only information that has undergone source checks, scope judgment, and necessary confirmation is suitable for settling into long-term knowledge.
3. Enterprise scenarios need additional data governance
Multi-user systems should isolate user memory, project memory, and organizational knowledge to avoid cross-tenant or cross-permission retrieval. Sensitive information should be stored on a minimum-necessary basis, with retention periods and deletion processes in place.
Logs should also not directly record credentials, full personal information, or unnecessary business data. Traceability and data minimization need to be designed together, not patched after the system goes live.
7. Validating Whether Architecture Improvements Are Effective Through Evaluation
“Feels more usable” can be a starting point, but it is not enough to prove that an improvement is effective. It is recommended to build an evaluation set covering different task types, including at least routine execution, missing information, constraint conflicts, changes in historical preferences, and tool failures.
The following metrics are worth focusing on:
- Task success rate: whether it meets predefined acceptance criteria.
- Repeated correction rate: whether confirmed issues occur again.
- Memory misuse rate: whether expired or inapplicable information is invoked.
- Skill reuse effectiveness: whether reuse reduces rework rather than merely increasing invocation counts.
- High-risk operation interception: whether operations requiring confirmation are correctly blocked.
- Execution cost: time spent, context size, and number of tool calls.
- Recoverability: whether the system can return to a workable state after failure.
During evaluation, task conditions should be kept as fixed as possible, comparing performance before and after a change. Memory and skill updates should preferably be introduced in batches, avoiding simultaneous changes to multiple modules that make it impossible to tell where the benefit comes from.
8. A Recommended Rollout Order
Actual implementation does not need to build a complete system from the start; it can proceed step by step in the following order:
Step 1: Define task acceptance criteria, permission boundaries, and reporting format, so that a single execution is controllable first.
Step 2: Establish task records and structured summaries to solve the problem of hard-to-trace historical processes.
Step 3: Bring confirmed preferences and project constraints into long-term memory, while implementing expiration and deletion mechanisms.
Step 4: Organize repeatedly validated successful procedures into skills, and fill in preconditions, verification steps, and exception handling.
Step 5: Introduce skill tiering, preference boundary management, and continuous evaluation, so the system has a stable improvement loop.
The true usability of an agent comes from the coordination of correct memory, clear constraints, and reliable execution. A good architecture is not one that makes the system store everything and execute everything automatically, but one that knows which information is worth keeping, which procedures are worth reusing, and when it must stop and seek confirmation.
