Agent Execution Architecture Optimization: A Practical Guide to Memory, Skills, and Decision Boundaries
This article explains why AI agents often work in demos but fail in real projects, and how to fix the problem at the architecture level. It introduces four reusable modules—memory systems, core documents, skill governance, and decision boundaries—and shows how to move from a three-layer memory model to a four-layer pipeline, prioritize constraint documents over new skills, manage a dynamic skill pyramid, and use a preference boundary table to turn corrections into reusable rules. It also outlines a practical implementation order and general cloud capabilities that support it.
1. Where the Problem Starts: Why Agents “Work” but Feel Hard to Use
Many teams follow a familiar curve after adopting an AI coding tool or a general-purpose agent framework. The initial demo looks impressive, but once the agent enters a real project, problems appear quickly: lost context, instruction drift, repeated mistakes, and a skill library that becomes harder to manage over time. The root cause is usually not model capability. It is a missing execution architecture.
In one common early setup, the agent runs as an extension component mounted on an external orchestration platform. The main orchestrator handles sessions and tool coordination, while the agent handles only local tasks. As the execution chain grows longer and tasks become more complex, the scheduling overhead and semantic loss of this “primary and auxiliary” structure are amplified. The natural next step is an execution architecture centered on the agent itself.
This evolution is useful for most teams: architectural control should sit at the layer with the strongest constraints and the best observability.
This article abstracts four reusable modules: the memory system, core documents, skill governance, and decision boundaries.
2. Memory System: Consolidating Three Layers into Four
Native memory usually has three layers: raw conversation records, periodic summaries, and long-term preferences. The problem is that the third layer is disconnected from executable knowledge. The model remembers preferences but does not know how to apply them.
With a localized memory extension component, these can be consolidated into a four-layer pipeline:
- Conversation clustering: split by task intent rather than time, and compress redundancy.
- Execution distillation: extract what was done, why it failed, and which paths worked.
- Deep understanding: the model performs causal induction on the distilled results and forms structured entries.
- Skill consolidation: stable conclusions are turned into callable skills.
The result is a dual loop between memory and skills: memory supplies material for skills, and skills produce higher-quality execution traces in return. The goal is to remember less and remember it well—retaining high-value information within a limited context budget.
Example structure:
memory/raw/ # Raw sessionsclustered/ # Clustering resultsdistilled/ # Execution distillationsemantic/ # Deep understanding entriesskills/ # Skills consolidated from memory
3. Core Documents: Constraints Come Before Skills
One counterintuitive but important conclusion: writing good core constraint documents has a higher priority than creating new skills. Constraints define the agent’s behavioral boundaries; skills only supply capability.
At a minimum, maintain three documents:
- AGENTS.md: the central hub. It defines the execution flow, skill orchestration mechanism, reporting format, memory architecture, and fault tolerance and rollback strategy. It determines how work gets done.
- SKILLS PYRAMID document: skill layering and promotion rules. It determines what is used to get work done.
- Yin-Yang table document: paired records of preferences and boundaries. It determines what not to do.
Example AGENTS.md:
# Execution Rules1. Read constraints first, then code, then act2. No more than 3 files per change; split the plan if exceeded3. After two failures, switch approach and report# Reporting Format- Conclusion / Evidence / Risks / Next Step
4. Skill Pyramid: Dynamic Layering Instead of Static Labels
Skills are layered by invocation frequency and value, forming a pyramid:
- Foundation layer, about 55%: file operations, terminal commands, and web access—high-frequency daily work.
- General layer, about 30%: debugging, planning, and code review—reused across projects.
- Specialized layer, about 15%: domain-specific tasks such as data training, creative design, and code hosting operations.
- Experimental layer, about 5%: draft skills where trial and error are allowed.
The key is that promotion is based on dynamic analysis, not one-time classification:
Experimental → Specialized: 3 effective invocations within 30 days with positive feedbackSpecialized → General: successful reuse across 3 different projectsAny layer → Retired: 60 consecutive days with zero invocations or a high failure rate
This keeps the skill library from expanding indefinitely or letting skills occupy context indefinitely just because they “look useful.”
5. Yin-Yang Table: Turning Corrections into Decision Boundaries
Combining the Daoist concept of yin and yang with the idea of complementary sets, you can build a preference boundary table. The core flow is: the user provides P (what they want), the agent infers not-P (what they do not want and the boundaries), paired entries are recorded, and the next time the table is checked directly.
Three points matter:
- P and not-P are semantically opposed. Neither is the positive or negative side; they only hold as a pair.
- If the user prefers not-P on a given occasion, the original P automatically becomes the new not-P. No new entry is needed; a reverse lookup is enough.
- After each correction, the system automatically summarizes and writes to the table, forming a continuously growing boundary record.
Example entry:
- id: 012P: Output includes complete runnable codenotP: Only pseudocode or fragmentsupdated: 2024-06-01
6. Implementation Advice and General Cloud Capabilities
Recommended implementation order: write AGENTS.md first, then build the Yin-Yang table, then organize the skill pyramid, and finally connect the four-layer memory.
At the runtime level, general cloud capabilities can help: use object storage to save documents and memory snapshots, use a message queue to decouple long-running tasks, use a container platform to host execution sandboxes, and use logging and monitoring with alerting to observe failure rates and invocation frequency, providing data for skill promotion and retirement.
At this point, the agent shifts from an “auxiliary plugin” to the “architectural core,” achieving clear constraints, lean memory, controllable skills, and reusable boundaries.
