Agent Execution Architecture Optimization: Coordinating Memory, Skills, and Constraints
Agent reliability depends on the entire execution chain, not just response quality. This article outlines a general architecture for making agent behavior more stable and verifiable: establish a primary executor with clear responsibilities, organize memory into four maturity layers, govern skills through a dynamic pyramid, use core documents to define execution boundaries, and capture paired user boundaries to reduce repeated correction. It also explains bidirectional feedback between memory and skills, validation and observability metrics, and a practical implementation sequence.
1. Assess Agents by Their Execution System, Not Just Output Quality
When using agents for development tasks, the common problem is not that they “cannot do it at all” but that they “can do it, but not reliably”: the same task sometimes completes smoothly and sometimes requires repeated trial and error; user preferences that were explicitly stated still need to be explained again next time; tool calls succeed, but the final delivery does not meet expectations.
These phenomena indicate that an agent’s actual effectiveness cannot be measured by answer quality alone. The full execution chain must be examined:
Task understanding → constraint identification → plan formulation → skill selection → tool execution → result verification → experience consolidation.
If any link lacks rules, local success can become overall failure. For example, the agent correctly modifies code but does not run necessary checks; it correctly understands the functional requirement but ignores the constraint that existing interfaces must not be changed.
Therefore, optimization should shift from “adding more tools” to “building an explainable, verifiable execution architecture.” The memory layering and skill governance discussed in this article are a general design approach and do not imply that every agent system has the same native capabilities.
2. Define a Primary Executor to Avoid Competing Rule Sets
In complex systems, one agent may handle planning while another execution unit performs concrete operations. This combination can extend capabilities, but it can also cause overlapping responsibilities: both sides maintain task state, interpret user intent, and store long-term memory, eventually creating multiple inconsistent versions of the facts.
A more robust design defines three types of responsibilities:
- Primary executor: receives tasks centrally, maintains the plan, state, and final delivery.
- Capability execution units: perform well-bounded operations such as retrieval, file processing, and testing.
- Governance components: handle permissions, memory, logging, and quality checks.
Whether an architecture should be simplified cannot be based only on the experience of a single task. Observe whether coordination cost consistently exceeds its benefit: whether tasks are repeatedly decomposed, errors are hard to locate, state is frequently lost, and multiple components give different interpretations of the same constraint.
For actions that involve resource changes, assign a single accountable owner. Other components may provide suggestions or perform delegated operations, but they should not modify the same task state together without a coordination mechanism.
3. Build Four Memory Layers: From Raw Records to Executable Experience
An agent’s long-term memory should not be an ever-growing chat log. Raw conversations contain a large amount of temporary information, exploration paths, and expired conclusions. Putting all of it into context is not only costly but also likely to interfere with the current task.
A more reasonable approach is to manage information by maturity level.
3.1 Layer 1: Raw Records and Task Clustering
This layer stores conversations, execution logs, tool results, and user feedback. Its purpose is to provide traceable evidence rather than directly guide all subsequent actions.
Records should carry basic metadata such as task ID, timestamp, applicable project, information source, and sensitivity level. Clustering can be organized around task goals, problem types, and involved objects rather than merely word similarity.
For example, two “test failures” may be caused by a missing environment and a business logic error, respectively. They should not be classified as the same handling experience just because their descriptions are similar.
3.2 Layer 2: Execution Process Distillation
Extract key information related to outcomes from raw records:
- initial goals and explicit constraints;
- steps actually taken;
- effective and ineffective attempts;
- final verification results;
- unresolved issues.
The focus of distillation is to distinguish observation from inference. “The check passed after adjusting the configuration” is an observation; “that configuration is the only root cause” is a judgment that requires additional evidence. Mixing the two will cause subsequent tasks to inherit unverified conclusions.
3.3 Layer 3: Semantic Understanding and Conditional Experience
This layer uses large language models or rule processing to abstract individual events into reusable experience, but it must retain applicability conditions.
For example, it should not record only “prefer modifying configuration.” It should record: “When the error appears as a resource location failure and the relevant file has been confirmed to exist, check path resolution and working directory first.”
Experience should include at least the applicable scenario, recommended behavior, constraints, evidence source, and update time. For content involving user preferences, it should also note whether this is an explicit requirement, a one-time choice, or a system inference.
3.4 Layer 4: Skill-Based Consolidation
Only experience with relatively stable steps, clear inputs and outputs, and verifiable results is suitable for conversion into a skill.
A skill is not just a prompt template. It should also specify:
- what inputs are required;
- what preconditions exist before execution;
- which capabilities can be invoked;
- how completion is determined;
- how to stop or recover after failure.
These four layers form a transformation chain from information to capability, but not all information must reach the final layer. Temporary facts may expire after a task ends; low-confidence inferences should wait for confirmation; experience from high-risk operations must not automatically become an autonomously executable skill just because it appears repeatedly.
4. Make Memory and Skills Feed Back in Both Directions, Not Accumulate One-Way
Memory provides context, and skills provide methods of operation. The two must correct each other through execution results.
The forward flow is:
task experience → conditional memory → candidate skill → reuse after verification.
The reverse flow is:
skill execution → result check → failure attribution → revise memory and skills.
For example, a skill for analyzing the causes of check failures may perform stably across multiple tasks and can be given higher retrieval priority. If it fails repeatedly in a certain class of environments, its preconditions need to be supplemented rather than simply increasing the number of retries.
“Remember less, remember firmly” should also be understood as a governance goal rather than mere data compression. A good memory system should achieve the following:
- Retrieve only relevant information for the current task.
- Merge duplicate content without incorrectly merging different scopes of applicability.
- Replace or mark expired conclusions as outdated.
- Allow summaries to be traced back to necessary raw evidence.
Summaries can reduce context burden, but they should not become the only unauditable source of truth.
5. Core Documents Are the Entry Point for Execution Rules, Not Decorative Documentation
Skills determine “how to execute,” while core documents determine “when to execute, to what extent execution is allowed, and how to prove completion.” For multi-step tasks, the latter is often the foundation of stability.
Core rules can be split into three logical documents.
5.1 Execution Charter
The execution charter is the entry point for other rules and should specify:
- the standard process for handling tasks;
- the order of handling when constraints conflict;
- methods for selecting and combining skills;
- confirmation requirements for high-risk actions;
- result verification and reporting format;
- memory read/write and failure recovery mechanisms.
For example, it can specify: check the current state before modification; seek confirmation before expanding task scope; when verification cannot be completed, state the unverified items and do not describe “modified” as “completed.”
However, document constraints cannot replace system controls. For actions such as deleting resources, accessing sensitive data, and modifying critical configurations, permission checks, execution isolation, or human approval are still required. A model may misread rules; the execution environment must be able to prevent unauthorized behavior.
5.2 Skill Tiering Description
Skill tiering guides retrieval and maintenance rather than attaching permanent labels to skills. Classification criteria should center on invocation frequency, scope of applicability, reliability, and maintenance cost.
5.3 Decision Boundary Record
This document maintains user preferences, explicit prohibitions, and conditional exceptions. It needs to be updated with feedback, but each temporary request should not be upgraded to a global rule.
The three types of documents should be version-controlled together. After a rule update, check whether it conflicts with existing skills, so that the charter does not require “confirm first” while a skill step executes directly.
6. Dynamically Manage the Skill Pyramid
Skills can be divided into four layers:
| Layer | Primary Role | Typical Content | Management Focus |
|---|---|---|---|
| Base layer | High-frequency and stable operational capabilities | File reading, directory checks, result organization | Permission boundaries and reliability |
| General layer | Methods reusable across tasks | Problem localization, plan formulation, change review | Input/output and verification standards |
| Specialized layer | Capabilities dependent on specific scenarios | Data analysis, model evaluation, domain design | Environment and knowledge prerequisites |
| Experimental layer | Candidate capabilities not yet fully validated | New processes, draft steps, exploratory approaches | Isolated validation and human review |
These layers do not need preassigned fixed percentages. If counting the number of skills, the proportions of all layers should add up to 100%. If counting invocation volume, the measurement basis must be stated separately and must not be mixed with skill counts.
Skill upgrades should also not be based only on usage count. A skill that is called frequently but has a high failure rate may simply reflect strong task demand; it does not mean the skill is mature.
More reasonable upgrade criteria include: successful reuse across different tasks, clearly explainable preconditions, checkable results, acceptable maintenance cost, and user confirmation that its behavior meets expectations.
Downgrade and retirement mechanisms are equally necessary. When the environment changes, the execution method becomes outdated, or quality continues to decline, a skill should return to the experimental state and be suspended if necessary. The pyramid is therefore a dynamic operational view, not a static directory.
7. Use Paired Boundary Records to Reduce Repeated Correction
Users often express only what they want, without fully describing what they do not want to happen. An agent can propose candidate boundaries based on this, but it must not treat inferences as direct user commands.
For example, if a user says “make the report more concise,” the system can form the following record:
Scope: Daily progress reportsExpected behavior: State conclusions first, then list key progressExcluded behavior: Repeatedly narrate the entire operation processMust retain: Risks, blockers, and unverified itemsConfirmation status: Confirmed by user
This paired record is more executable than storing only “the user likes brevity,” because it simultaneously specifies what to retain and what to reduce.
However, “not a preference” in natural language is usually not a strict mathematical complement. “Prefers brevity” does not mean “rejects all detailed explanations”; when the user asks for elaboration during an incident review, it does not mean the previous preference is invalid.
Therefore, boundary records should include scenario, priority, validity period, and confirmation status. When new feedback appears, first determine whether the original rule has been revised or a new exception scenario has been added.
Such records also cannot override security and permission restrictions. User preferences can affect expression style and workflow, but they cannot authorize the system to cross access boundaries.
8. Support Continuous Optimization with Validation and Observability
Whether an architecture is effective must ultimately be validated through task performance. The following metrics can be recorded continuously:
- the proportion of first deliveries that meet requirements;
- the number of user corrections required per task;
- repeated occurrences of the same type of error;
- relevance of memory retrieval results;
- verification pass rate after skill execution;
- average retry count and task duration;
- whether unauthorized actions are correctly blocked.
When evaluating, distinguish task types and difficulty to avoid mistakenly concluding that architecture optimization has taken effect because recent tasks were simpler. A representative set of tasks can be selected as a fixed regression set and checked repeatedly after rule, memory, or skill updates.
Failure handling also needs classification: ask for clarification when input is incomplete, stop and explain when permissions are insufficient, consider limited retries when tools are abnormal, and re-analyze when results do not meet expectations. Unlimited retries neither guarantee success nor avoid duplicate writes or resource waste.
For sensitive memory, adhere to minimal storage and provide deletion, expiration, and access control mechanisms. Improving agent capabilities should not come at the cost of unbounded accumulation of user data.
9. Recommended Implementation Order
In practice, there is no need to build a complex long-term memory system from the start. A more effective order is:
- First define the execution process, permission boundaries, and delivery standards.
- Then organize a small number of high-frequency, stable, and verifiable skills.
- Save task logs and establish a basic result-checking mechanism.
- Extract conditional experience from recurring problems.
- Introduce relevant memory retrieval and evaluate whether it actually reduces correction.
- Finally, improve skill upgrade, downgrade, and automated governance.
Agent stability comes from consistency among rules, state, capabilities, and validation. The model handles understanding and reasoning, skills carry reusable steps, memory stores filtered experience, and core documents unify execution boundaries. Only when these parts form a closed loop can a system move from “occasionally completing tasks” to “continuously and controllably delivering results.”
