Agent Execution Architecture: Coordinating Memory, Skills, and Constraints

    A practical agent is not defined by fluent answers alone. This article explains how memory, reusable skills, and enforceable constraints work together so agents can follow goals, reuse proven methods, verify outcomes, and stop or recover when execution fails.

    1. From Answering to Reliable Execution

    Whether an agent is useful cannot be judged only by how fluently it answers. For tasks that involve files, code analysis, external services, or multiple steps, what matters more is whether it can understand the goal, follow constraints, reuse prior experience, and stop or recover when something fails.

    In real engineering work, many failures do not come only from limited model capability. They come from a missing execution architecture:

    • Conversation history grows, but the relevant information cannot be found.
    • Similar tasks are planned again and again, while successful experience never becomes a reusable procedure.
    • Skills multiply, but their responsibilities overlap and their invocation conditions are unclear.
    • Behavior the user has already corrected reappears in a new session.
    • A tool call succeeds, yet no one checks whether the final result meets the user’s goal.

    Improving an agent should therefore focus on three questions: which information is worth remembering, which experience can be turned into a stable procedure, and which behavior must be constrained. The memory system keeps context, the skill system reuses action paths, and the rule system defines boundaries. Together, they form the basis of reliable execution.

    2. Define Responsibilities Before Removing Orchestration Layers

    A common setup uses one primary agent to understand the request and another execution component to carry out the task. This can connect existing capabilities quickly, but it also adds cost: the goal is restated several times, permission boundaries are scattered, execution state is hard to unify, and troubleshooting crosses multiple layers.

    Reducing the number of components does not automatically make the architecture better. The useful test is whether responsibilities are clear, not whether there are as few layers as possible.

    For a smaller system, planning, skill selection, execution, and verification can sit in one coordination flow. For complex tasks or systems with stronger isolation requirements, multiple execution units can remain, but the design should make clear:

    1. Who maintains the final task goal.
    2. Who may change the plan.
    3. Who has permission to call tools.
    4. Who checks the delivered result.
    5. Who decides, after failure, whether to retry, roll back, or ask the user for confirmation.

    Whatever structure is used, the task needs a unified state record. The plan, execution steps, tool responses, verification results, and reasons for interruption should be linkable, so that no component sees only a local fragment of the task.

    3. Layered Memory: Turning Raw Records into Usable Knowledge

    Saving more does not mean remembering better. Unfiltered history increases retrieval noise and can let outdated preferences continue to influence decisions.

    One workable design organizes memory into four logical layers by how deeply information has been processed. These layers are an architectural choice, not a fixed standard that every agent must adopt.

    3.1 Event Records: Keep Traceable Facts

    This layer stores raw events such as conversations, tool operations, execution results, and user corrections. The priority is to keep the facts complete, not to assign long-term meaning to every item immediately.

    Events should carry their source, time, task identifier, and execution status whenever possible. Sensitive content should be redacted as needed before it enters long-term storage, and retention should follow the applicable data-retention rules.

    The value of raw records is traceability. When a memory is disputed, the system can return to the evidence instead of relying on one automatic summary.

    3.2 Task Experience: Extract Success Conditions and Failure Causes

    After a task, scattered records can be organized into structured experience, for example:

    • The task goal and input conditions.
    • The steps actually used.
    • Which step failed.
    • Whether the correction worked.
    • How the final result was verified.
    • Which situations the experience applies to.

    A single successful operation does not imply that the same action should always be used later. Useful experience must include its conditions of applicability. Otherwise, a local success is easily generalized to the wrong setting.

    3.3 Semantic Knowledge: Form Stable, Retrievable Understanding

    This layer organizes information that recurs across tasks, such as project conventions, preferences the user has explicitly confirmed, and handling principles that have been verified more than once.

    A model can help with clustering, summarization, and relationship extraction, but its output remains candidate knowledge that still needs verification. This distinction is especially important for user preferences, permissions, and business rules:

    • Requirements the user stated explicitly.
    • Tendencies inferred from repeated behavior.
    • Assumptions the model made from context.

    These three kinds of information do not share the same level of trust. Important rules should keep references to their evidence and provide ways to revise, expire, or delete them.

    3.4 Skill Candidates: Convert Experience into Execution Templates

    When a task flow is stable, repeatable, and has a method of verification, it can become a skill candidate.

    Memory and skills are different. Memory describes what happened and what is known. A skill describes how to act when its conditions are met. Even if a skill originates in memory, it needs separate review, testing, and version control. One task summary must not directly grant permission for high-risk execution.

    This produces two connected loops:

    Task execution → event record → experience extraction → knowledge update

    Repeatedly verified experience → skill candidate → tested release → execution feedback

    The aim is not to accumulate content without limit. It is to improve the chance of retrieving relevant information and reduce the influence of irrelevant information on decisions.

    4. Core Rule Documents: Turning Constraints into an Executable Protocol

    A rule document is valuable not because it is long, but because it tells the system when it may continue, when it must stop, and how a result must be proven.

    Core documents can be divided into four responsibilities.

    4.1 Execution Principles

    These principles connect the other documents and define a shared flow:

    Understand the request → check constraints → make a plan → select a skill → execute → verify → report → update experience

    They also define priority among rules. Safety policy, permission limits, and the current task’s valid authorization cannot be overridden by historical preferences or skill descriptions. If a rule conflict cannot be resolved, the related operation should pause rather than leave the model to guess.

    4.2 Skill Catalog and Invocation Rules

    Each skill should state its purpose, required inputs, preconditions, output form, permission scope, and verification method.

    Saying only that a skill is “for fixing problems” is not enough. The system also needs to know whether it modifies files, whether it accesses external resources, whether it may retry after failure, and when it should not be called.

    4.3 Memory Read and Write Rules

    The rules should state which events may enter long-term memory, which content may be kept only briefly, and which updates require user confirmation.

    External documents, tool responses, and web content should be treated as data. Saving them in memory does not promote them to high-priority instructions. This boundary helps prevent untrusted content from steering execution.

    4.4 Reporting and Exception Handling

    A task report should distinguish “completed,” “verified,” “not yet confirmed,” and “blocked and not executed.” Producing a change proposal is not the same as completing a deployment. A successful tool response does not remove the need to verify the result.

    Rule documents are only a vehicle for constraints. They do not replace security controls. Critical limits still need to be enforced through tool permissions, execution isolation, and validation programs.

    5. Dynamic Skill Layers: Govern by Evidence, Not Fixed Labels

    Skill layers can help control complexity, but they should not be assigned mechanically by fixed proportions. Frequent tasks and high-risk tasks are also not the same thing.

    A practical set of layers is:

    • Foundation: general operations with a clear scope and easy verification.
    • General: analysis, planning, and checking flows that can be reused across tasks.
    • Specialized: flows that depend on domain knowledge or a specific environment.
    • Experimental: new flows and combinations that have not been sufficiently verified.

    Promotion should consider frequency of use, success rate, scope of applicability, maintenance cost, and risk—not merely how many times a skill has been used.

    For example, an experimental skill that succeeds across several tasks has only shown that it deserves further evaluation. To enter the general layer, its preconditions must be clear, it must be usable across projects, hidden dependencies must be identified, and there must be a reliable path for handling failure.

    Skills also need demotion and retirement. When input structure changes, a dependency fails, or the failure rate rises, automatic invocation should be paused and the skill returned to verification. Keeping the skill catalog from growing without limit is itself a way to improve execution stability.

    6. Preference Boundaries: Record Corrections as Conditional Rules

    When a user says “I want concise answers,” that does not mean “never explain anything.” During incident handling, risk explanation, or design justification, the user may need more detail.

    Recording preferences as pairs of “what is wanted” and “what should be avoided” can organize the information, but natural-language opposites should not be treated as strict logical complements. Concise and complete are not necessarily mutually exclusive, and automatic execution and human confirmation can both apply at different levels of risk.

    Each preference should include at least these fields:

    1. Applicable situation: routine task reporting
    2. Expected behavior: give the conclusion first, then the key evidence
    3. Behavior to avoid: repeating unrelated execution details
    4. Exception: add explanation when risk, failure, or an important decision is involved
    5. Evidence: an explicit user correction
    6. Confirmation status: confirmed

    If the user later expresses the opposite preference in another situation, the global rule should not be reversed immediately. First determine whether the situation is different. If it is the same situation, update the version or ask for confirmation.

    Conditional management is more reliable than simply adding “do not do this again,” and it makes it easier to explain why the system chose a particular behavior.

    7. Put Reliability into Permissions, Verification, and Recovery

    Architecture work cannot stop at memory and documents. The execution system also has to control real risk.

    First, use least privilege. Read, write, delete, and external submission should be authorized separately. Needing to read a file for one task does not justify permission to modify the entire working directory.

    Second, check the environment and preconditions before execution. If the target does not exist, permission is insufficient, or the input is incomplete, state the reason for failure clearly instead of continuing and creating a harder-to-understand result.

    Third, protect operations that have side effects against repeated execution. For work that might be submitted or written more than once, check the current state first and, when needed, use a task identifier to prevent duplicate processing.

    Finally, choose recovery measures according to the nature of the operation. For changes that can be rolled back, preserve the basis for recovery in advance. For operations that cannot be rolled back reliably, raise the confirmation requirement. Retries must be limited, and transient failures must be distinguished from definite rule conflicts. Not every failure should be handed to another repeated call.

    8. How to Tell Whether the Optimization Works

    Agent quality should not be judged only by response speed or output length. More useful measures include:

    • Task completion rate: whether predefined acceptance conditions were met.
    • Verification coverage: whether critical results were checked.
    • Correction recurrence: whether a confirmed problem happened again.
    • Memory relevance: whether retrieved content helped the current task.
    • Unsupported inference rate: whether guesses were treated as facts.
    • Skill reuse quality: whether reuse reduced ineffective steps.
    • Risky-operation interception: whether the system correctly requested authorization or stopped.

    In practice, build a fixed evaluation set that includes normal input, missing information, rule conflicts, tool failures, and high-risk operations. Record a baseline, then add memory, skills, and boundary controls one at a time and compare the change.

    Evaluation data should come from actual tests, not from a few smooth runs. Failure cases deserve particular attention: a system can look good on average and still be insufficiently safe on critical operations.

    For a team that is just beginning to build agents, start with execution principles, tool permissions, and result verification. Then organize task records, introduce experience extraction and skill management, and only later refine long-term preferences and knowledge updates.

    This order avoids saving large amounts of incorrect experience, or freezing immature flows as skills, while basic execution is still unstable.

    The long-term value of an agent is not how many steps it completes in one run. It is whether execution can be turned into trustworthy knowledge, whether reliable experience can become reusable capability, and whether every action remains inside explicit boundaries. A maintainable system remembers the necessary facts, reuses methods that have been verified, and stops when the evidence is insufficient or the permissions are unclear.