The Self-Evolution Architecture of Open-Source AI Agents: How Runtime Skill Generation, Layered Memory, and Backend Decoupling Work
This article breaks down the self-evolution architecture used in open-source AI agents and contrasts it with static execution designs. It explains how a runtime learning loop generates and selects skills, how three-layer memory and cache-aware prompt ordering keep long-running costs under control, and how separating the execution backend from the inference backend improves portability. It also covers migration steps, guardrails, observability, and evaluation practices for teams deciding whether this architecture fits their workload.
1. The Starting Problem: Why Fixed Capability Is the Core Bottleneck
Open-source AI agents today fall into two broad design routes. The first is the static execution model: a centralized gateway component schedules models, tools, and external systems, and the agent’s behavioral boundary is defined by skills written in advance by developers or contributed by the community. The advantage is predictable behavior and clear debugging paths; the drawback is that the capability ceiling is locked to the frequency of manual updates.
The second is the self-evolving model: experience accumulation and capability iteration are moved into the runtime itself, so the agent continuously rewrites its own behavioral strategy as it is used.
These two routes are not a matter of better versus worse — they fit different scenarios. Static execution suits stable workflows with strict compliance requirements. Self-evolution suits personal assistants and operations workloads where the task distribution drifts over long periods and the rules cannot be exhaustively enumerated. Understanding this distinction is the prerequisite for evaluating any agent framework.
2. Innovation One: Putting the Learning Loop at the Core of the Architecture
2.1 From Hand-Written Skills to Runtime-Generated Skills
In a static architecture, skill library growth depends on human effort: developers submit, the community reviews, and a version is released. The self-evolving architecture turns this step into runtime behavior. Once the agent has completed a certain number of tasks, or after it encounters a highly complex task, it triggers an experience review: it separates successful paths from failed ones, extracts the reusable parts that are independent of the specific input, and solidifies them into a structured skill description file (a common industry practice is Markdown with a metadata header) that is written into the skill library.
An illustrative skill file structure:
---name: Periodic report reconciliationtrigger: Intent such as "reconcile / check / discrepancy" with tabular input attachedpreconditions: Input contains a primary key columnsteps:1. Validate primary key uniqueness2. Compare column by column and output a discrepancy list3. Attach a confidence score to each discrepancyfailure_notes:- Null values are excluded from comparison and must be listed separately---
The key point is that trigger conditions and failure notes must be recorded explicitly. Storing only “how to do it” without “when it fails” degrades the review mechanism into log accumulation.
2.2 Strategy Selection Across Similar Tasks
When a new task resembles historical tasks in intent or structure, the evolving architecture retrieves candidate skills and selects or merges strategies based on historical execution results (success rate, average number of steps, number of human interventions) rather than simply appending a new skill. This step is the real source of the compounding effect: as the number of skills grows, retrieval and selection quality improve at the same time.
Two degradation modes need engineering attention. First, skill library bloat raises retrieval noise, so introduce a similarity threshold and periodic consolidation. Second, incorrect experience can become entrenched, so keep failure notes and allow human rollback to a specified version.
3. Innovation Two: Cost-Controlled Layered Memory
3.1 Division of Responsibility Across Three Memory Layers
The problem with a single memory file is mixed responsibility: persona settings, long-term knowledge, and the current context all swell inside the same file, and token cost rises linearly with history. A layered scheme splits memory into three tiers:
- Persistent notes: stable knowledge and user preferences accumulated across sessions;
- Skill memory: executable solution patterns, mapped to the skill library;
- Session memory: context for the current task, trimmed once the task ends.
3.2 Storage and Retrieval Combinations
A common engineering combination is relational storage plus a full-text search index, with the model summarizing and compressing long segments. The relational database handles structured fields and versioning, the full-text index handles keyword recall, and the summarization layer compresses lengthy history into a short context that can be injected. Only when the three are combined can you balance “remembering enough” against “fitting into the context window.”
3.3 Cache-Aware Cost Design
The cost pain point of long-running operation is essentially that every request carries the same unchanged context again. The core idea of cache-aware design is to place stable content first and keep it byte-for-byte identical, place volatile content last, so that prefix caching on the inference side hits as often as possible. Illustratively:
[Stable prefix] Persona settings + skill index + persistent notes summary ← keep unchanged to hit the cache[Semi-stable section] Full text of skills relevant to the current task[Volatile tail] Most recent dialogue turns + current input
Combined with a strategy where “growth in learned material does not necessarily raise per-request cost” (new knowledge is written to the index rather than injected in full), the cost curve shifts from linear to roughly step-shaped.
4. Innovation Three: Dual Decoupling of Execution Backend and Model Backend
Deployment flexibility has two orthogonal dimensions. The execution backend determines where code runs; common forms include local processes, containers, remote hosts, cloud sandboxes, and serverless functions, with selection based on isolation strength, cold-start tolerance, and network reachability. The inference backend determines where the model comes from, adapting to different protocols and authentication methods through a unified abstraction layer so that swapping models does not affect upper-layer skills.
The direct benefit of dual decoupling is portability: memory, skills, and configuration are stored in a file-based, exportable form, so migration means moving data rather than rewriting logic. For users of an existing static architecture, the recommended migration order is: export configuration and memory first, rebuild the skill index next, then run a batch of historical tasks as a regression comparison, and switch traffic over only after confirming behavior is consistent.
5. Implementation Advice and Evaluation Methods
- Scenario selection: prioritize the evolving architecture for scenarios with obvious task distribution drift and identifiable repeated patterns.
- Observability first: log every skill generation, hit, and rollback; otherwise capability changes cannot be explained.
- Cost baseline: measure per-request token volume for both the first turn and long sessions, and verify cache hit rate.
- Guardrails: set a cap on the number of skills, a similarity threshold, and a manual review switch to prevent incorrect experience from spreading.
- Compliance and isolation: when sensitive data is involved, prefer an execution backend with stronger isolation, and connect logs and monitoring alerts to a unified observability system.
If an enterprise wants to host these capabilities in its own environment, it can build them on general cloud product categories such as container platforms, object storage, log services, and monitoring and alerting; the relevant general capabilities of Baidu AI Cloud can serve as an infrastructure selection reference. Overall, the value of the self-evolving architecture is not that it is “smarter,” but that it moves capability iteration from the release process to the runtime, making long-term operation a benefit rather than a burden.
