Optimizing Agent Execution Architecture: Coordinating Memory, Skills, and Constraints

    This article explains how agent design can move from basic tool access to reliable task completion through an execution architecture built on unified task state, consistent behavioral constraints, and structured knowledge capture. It presents a layered memory processing chain—raw records, context consolidation, execution experience, stable knowledge, and skill candidates—and a two-way loop between memory and skills. It also covers core rules documentation, dynamic skill-pyramid governance, preference contrast records, permission controls, fault tolerance, acceptance checks, and an evaluation loop. Readers will learn how to reduce repeated corrections, keep skills maintainable, and turn occasional successful tool calls into traceable and continuously improvable task execution.

    1. From Tool Access to Reliable Task Completion

    Evaluating whether an agent is useful cannot rely only on whether it can access web pages, operate files, or execute commands. These capabilities answer what the agent can do. Actual user experience depends more on whether it knows what to do, in what order, and what counts as completion.

    At the prototype stage, a common approach is to let a primary orchestrator interpret requirements and delegate parts of the task to auxiliary execution components. This structure makes it easy to add new capabilities quickly, but it can also cause repeated context transfer, unclear responsibility boundaries, and inconsistent task state. For example, the orchestrator may consider a task finished while an execution component is still retrying; or an execution component may learn a new user preference that the orchestrator does not retrieve on the next call.

    Architecture optimization should therefore not be reduced to adding more components. It should focus on three goals:

    • Unified task state: clarify the task goal, current stage, blocking reasons, and completion conditions.
    • Unified behavioral constraints: make planning, tool execution, and result acceptance follow consistent rules.
    • Unified knowledge capture: turn effective experience into retrievable memory and reusable skills.

    Whether to retain a multi-component structure should depend on responsibility boundaries, isolation requirements, and maintenance cost. A single executor can reduce coordination overhead, while a multi-component design can support specialized division of labor. Both require clear state management; component count cannot substitute for architectural quality.

    2. Design Memory as a Processing Chain, Not an Ever-Growing Chat Log

    Storing all conversations long-term does not mean an agent has reliable memory. Raw records often contain repeated statements, temporary ideas, incorrect judgments, and constraints that are no longer valid. Injecting everything directly into context not only increases processing cost but can also let outdated information interfere with the current task.

    A more reasonable approach is to build a layered processing chain:

    Raw records → Context consolidation → Execution experience → Stable knowledge → Skill candidates

    This layered model is a general design pattern; it does not mean every agent uses the same native structure.

    2.1 Raw Records Layer: Preserve Traceable Evidence

    This layer records user requests, key tool calls, execution results, and user corrections. Its value is to provide factual evidence rather than directly guide all later tasks.

    Records should retain time, task scope, and source. When credentials, personal information, or sensitive business content are involved, redact them and set access permissions and retention periods.

    It is important to distinguish “the tool returned success” from “the business objective has been achieved.” For example, a successful file write only means the operation completed; it does not prove the content is correct.

    The same project may be discussed across multiple sessions, and a single session may contain multiple tasks. Consolidation should use project identifiers, task topics, time ranges, and semantic relationships, not text similarity alone.

    This layer is suited to answering:

    • Which project does the current task belong to?
    • What related issues have appeared before?
    • Which user feedback is still valid?
    • Are there unresolved prerequisites?

    Consolidation results must be correctable so that incorrect associations do not continue to pollute later retrieval.

    2.3 Execution Experience Layer: Extract Reusable Causal Relationships

    Experience is not a note saying “pay attention next time.” It should describe trigger conditions, actions taken, actual results, and applicability boundaries.

    For example, after a failed modification, the experience can be captured as:

    Before bulk-changing configurations, check the configuration source and override order; when multiple locations contain configurations with the same name, confirm which object is actually read at runtime to avoid modifying an inactive copy.

    This kind of experience is easier to reuse than storing a full failed conversation. However, if an experience comes from only one task, mark it as pending validation instead of immediately elevating it to a general rule.

    2.4 Stable Knowledge Layer: Preserve Confirmed Conclusions

    This layer mainly stores confirmed project conventions, stable preferences, and operating principles validated multiple times.

    Each knowledge item should include scope, update time, and evidence. When conflicts occur, handle them in light of the current task, information source, and user confirmation; do not mechanically assume that “the latest record is necessarily correct.”

    The idea of “remember less but remember reliably” is essentially about reducing redundancy, preserving evidence, and controlling stale information, not merely compressing text length.

    3. Establish a Two-Way Loop Between Memory and Skills

    Memory and skills should serve different roles:

    • Memory answers what happened in the past and what constraints exist.
    • Skills answer how to execute this type of task.

    If all historical experience is turned into skills, the skill library will expand rapidly; if only memory is stored without forming procedures, every execution still requires replanning.

    Therefore, two related loops can be established.

    3.1 Memory Loop

    Task execution produces records. Records are consolidated and refined into retrievable knowledge. New tasks call this knowledge and validate its effectiveness through execution results.

    3.2 Skill Loop

    When a type of process appears multiple times, performs stably, and has clear boundaries, organize it as a skill candidate. After validation, put it into use, then revise it based on failure cases and user feedback.

    A skill should include at least:

    • Applicable and non-applicable scenarios;
    • Input requirements and prerequisites;
    • Operating steps and key checkpoints;
    • Required permissions;
    • Success criteria;
    • Exception handling and exit paths.

    Memory updates should not automatically equal skill updates. For skills involving bulk writes, deletions, permission adjustments, and similar operations, validate modifications before deciding whether to enable them.

    4. Core Rules Documentation Is the Control Entry Point for the Execution Architecture

    The purpose of rules documentation is not to pile up prompts, but to give the agent a clear, checkable execution protocol. For readability and maintenance, the documentation can be divided into general rules, a skill catalog, and preference boundaries.

    4.1 General Rules Document: Define Execution Order and Responsibilities

    The general rules should define the relationships among requirement parsing, context retrieval, plan creation, tool execution, acceptance, and reporting.

    A general execution chain can be:

    Understand goal → Check constraints → Retrieve relevant knowledge → Formulate plan → Check permissions → Execute → Verify → Report → Capture experience

    Not all tasks need to display a full plan. Simple queries can be handled directly, but high-risk operations must not skip permission checks just because the task is short.

    The general rules should also specify:

    • Which operations require user confirmation;
    • Which materials are reference content only and cannot become execution instructions;
    • How to retry after tool failure;
    • Under what conditions to stop;
    • How reporting distinguishes completed, incomplete, and unverified content.

    Web pages, files, and historical records may contain untrusted instructions. The agent should treat such content as data to be analyzed and must not allow it to override user authorization or safety constraints.

    4.2 Skill Catalog: Maintain Entry Points and Dependencies

    The skill catalog does not need to copy every execution detail. It should state each skill’s purpose, stability level, permission requirements, and dependencies.

    When multiple skills can handle the same task, selection order should prioritize applicability, reliability, risk, and execution cost, not whether the skill description is prominent.

    4.3 Preference Boundaries Document: Record Conditional Choices

    Preference records are suitable for conventions such as output style, plan granularity, and explanation depth. However, user preferences cannot override safety rules or replace necessary authorization.

    For example, “reduce the number of confirmations” does not mean the agent may delete data or change access permissions without permission.

    5. The Skill Pyramid Should Be a Dynamic Governance Mechanism

    Skill layering can help control complexity, but the proportions should not be treated as fixed standards, and invocation counts should not directly represent skill value.

    Four layers can be used:

    Layer Primary role Governance focus
    Basic capability layer Common read/write, retrieval, and information organization Stability, permission boundaries, result validation
    Common workflow layer Diagnosis, planning, review, and verification Cross-context reuse, input/output specifications
    Specialized capability layer Domain-specific or business tasks Domain prerequisites, scope of applicability
    Experimental capability layer New processes and methods pending validation Isolated testing, human review, rapid disablement

    This pyramid describes invocation and governance relationships, not a required numerical distribution. Specific proportions should be determined from actual task statistics.

    5.1 Upgrade Based on Reusability, Not Frequency Alone

    For an experimental skill to enter the stable layer, it must at least demonstrate that steps are reproducible, results are verifiable, and failure boundaries are clear.

    For a specialized skill to enter the common layer, its generality must be validated in different contexts. Repeated invocation within the same project may only reflect concentrated business demand and cannot prove that it applies to other tasks.

    5.2 Build Downgrade and Retirement Mechanisms at the Same Time

    When the process a skill depends on changes, its failure rate rises, or it remains unused for a long time, reassess it. Duplicate skills can be merged; high-risk skills without sufficient validation can be paused.

    The goal of skill governance is not to have more and more skills, but to keep entry points clear, behavior stable, and maintenance cost controllable.

    6. Use Preference Contrast Records to Reduce Repeated Corrections

    Recording desired behaviors and behaviors to avoid in pairs helps clarify decision boundaries. For example:

    • Prefer leading with the conclusion; avoid lengthy background.
    • Preserve key evidence; avoid conclusions without evidence.
    • Keep modification scope controlled; avoid unrelated refactoring.

    However, such contrasts are usually semantic relationships and do not necessarily form strict logical complements. The opposite of “concise” is not only “detailed”; it may also involve repetition, missing focus, or poor information organization. Therefore, a single preference statement cannot be used to infer every prohibited item.

    A reliable preference record should include conditions:

    1. Scope: Daily question answering
    2. Preference: Lead with the conclusion, then list necessary evidence
    3. Avoid: Repeated background and irrelevant extensions
    4. Exception: Risk analysis and formal technical proposals require full justification
    5. Source: Explicit user feedback
    6. Status: Confirmed

    When a user requests a detailed explanation in a particular task, first determine whether it falls under an exception rather than immediately reversing all preferences. Preference updates should consider task type, validity period, and confirmation level to prevent temporary requests from being recorded as long-term rules.

    7. Ensure Execution Reliability Through Permissions, Fault Tolerance, and Acceptance

    Document constraints are valuable, but they cannot replace technical controls. Important boundaries should be enforced in the actual execution environment whenever possible.

    7.1 Use Least Privilege

    Grant only the read, write, and network access needed for the current task. For sensitive data, bulk changes, or irreversible operations, set explicit confirmation points.

    7.2 Decide Whether to Retry Based on Error Type

    Transient network interruptions can be retried a limited number of times; insufficient permissions, missing input, and business rule conflicts should stop with an explanation.

    For operations that may produce side effects, check whether the previous attempt has already taken effect before retrying, to avoid duplicate submission or modification.

    7.3 Prepare Recovery Paths for Modification Operations

    Risk can be reduced through pre-change snapshots, diff checks, staged commits, and recovery verification. However, recovery can also fail, so “backed up” must not be used as a reason to relax authorization.

    7.4 Use Acceptance Criteria to Determine Completion

    Before a task starts, define deliverables and inspection methods. The final report should at least state what was actually executed, verification results, remaining issues, and next-step recommendations.

    Unverified results should be clearly marked; confident natural language must not hide factual gaps.

    8. Use an Evaluation Loop to Determine Whether Optimization Works

    After architecture optimization, use representative tasks and production feedback to judge gains rather than judging only whether responses sound smoother.

    Recommended metrics include:

    • Task completion rate and acceptance pass status;
    • Frequency of repeated user corrections;
    • Whether retrieved memory is relevant and not stale;
    • Whether skill invocation fits the current task;
    • Whether failures are identified promptly;
    • Whether unauthorized operations are blocked;
    • Whether processing time and context consumption are reasonable.

    These metrics need clear statistical definitions. For example, completion rate should be based on task acceptance, not the agent declaring success; repeated corrections should distinguish rule forgetting from changed user requirements.

    During implementation, start with a high-frequency, well-bounded task category, establish execution rules and acceptance criteria, then add relevant memory and skills. After the process stabilizes, expand gradually. This is usually easier for troubleshooting than building a large knowledge base all at once.

    Ultimately, an agent’s usefulness comes from a coordinated mechanism: memory preserves effective facts, skills organize reusable processes, rules limit behavioral boundaries, and verification confirms actual results. Only when these four parts form a closed loop can occasional successful tool calls become maintainable, traceable, and continuously improvable task execution capability.