Self-Evolving Agents: Architecture Design and Practice
This article describes a self-evolving agent architecture that separates model capabilities from structured memory, scenario-specific policies, and reusable scenario packages. It covers scenario segmentation, long-term memory types, per-turn requirement extraction, the feedback-to-policy lifecycle, repository-based reuse, engineering controls, and an execution loop, with guidance on suitable boundaries and implementation order.
Why a Self-Evolving Architecture Is Needed
Most conversational agents treat “understanding the current turn correctly” as the measure of success: the user asks a question, the system retrieves information, calls tools, and generates an answer. This model works for one-off Q&A, but it exposes three gaps in sustained collaboration.
First, experience is lost when the session ends. When similar tasks recur, the system still reasons from scratch and cannot retain validated steps, constraints, and exceptions. Second, preferences exist only in prompts or temporary context. A user’s requirements for tone, format, risk boundaries, and decision order are hard to apply consistently across tasks. Third, improvements lack ownership. If a human correction only rewrites the current answer, later tasks in the same category still fall back to the old strategy.
A self-evolving architecture does not aim to let the model rewrite its weights during runtime. Instead, it builds an independent agent layer outside the model: scenarios, experience, knowledge, and preferences are stored in structured form; feedback is converted into versioned policies; and those policies are reliably retrieved and enforced in later execution. The model handles language understanding and generation, while the agent layer handles what to remember, when to use it, how to update it, and who can reuse it.
Overall Layering
The system can be divided into five layers with decoupled responsibilities.
- Interaction layer: receives user goals and additional constraints, and returns the execution process in an explainable way.
- Scenario layer: determines which business scenario the current task belongs to, and selects the corresponding process template, tool permissions, and acceptance criteria.
- Memory layer: stores facts, experience, preferences, and failure cases by scenario, and controls the memory lifecycle.
- Policy layer: compiles feedback into executable rules, such as output structure, checklists, tool selection order, and rejection conditions.
- Reuse layer: publishes validated scenario methods to an organization-wide agent repository so new users and new tasks can reuse them according to permissions.
The key to this layering is that “evolution happens in policies and memory, not implicitly inside a long context.” Context expires, gets truncated, and is difficult to audit. Independently stored policies can be versioned, rolled back, and authorized.
Scenario Segmentation: The Basic Unit of Evolution
If all conversations are written into a single memory, the system quickly encounters conflicts: finance scenarios require rigorous citations, while creative scenarios require divergent expression; personal preferences should not leak into shared team processes. Therefore, self-evolution should use scenarios as boundaries.
Scenarios do not need to be exhaustively enumerated at the start. Online classification can use four fields: goal, object, constraints, and success criteria.
- Goal: what the user ultimately wants to accomplish, such as generating a proposal, reconciling data, or orchestrating a process.
- Object: the business entity involved, such as a contract, ticket, report, or code module.
- Constraints: timeliness, compliance, format, permissions, and prohibited actions.
- Success criteria: how completion is determined, such as passing a checklist, receiving user confirmation, or satisfying structured fields.
Classification can follow a “rules first, model supplement” approach. Stable, high-risk scenarios use explicit rules to avoid misclassification; long-tail scenarios receive candidate labels from the model and are retained after manual or automated confirmation. Each scenario has its own memory namespace, tool whitelist, and policy version. Across scenarios, only desensitized and approved general knowledge is shared; personal preferences are not shared.
Scenario segmentation also controls explosive growth. New scenarios first enter an observation state, where they are recorded but not automatically executed. When similar tasks reach a certain frequency, feedback is consistent, and risk is acceptable, they can be upgraded to reusable templates.
Long-Term Memory: Store Experience, Knowledge, and Preferences Separately
If “long-term memory” is just concatenated historical conversations, it is both expensive and unreliable. A more robust approach divides memory into three object types.
Experience is reusable ways of doing things: steps, common pitfalls, checkpoints, and fallback actions for a category of tasks. It should be written as short operational cards, not raw chat logs.
Knowledge is relatively stable facts and business rules: term definitions, process nodes, field meanings, and permission boundaries. Knowledge needs sources, update times, and invalidation conditions so outdated interpretations are not treated as facts.
Preferences are requirements from users or teams about interaction style: level of detail, structure, language, confirmation timing, and strength of risk warnings. Preferences must carry a subject and distinguish among user, project, and tenant; by default, they are not inherited across subjects.
A schematic structure is shown below:
MemoryItemidscene_idtype: experience | knowledge | preferencescope: user | team | tenantcontentevidence[] # source turns, feedback, or document referencesconfidencevalid_from / valid_toversionsensitivity
Before writing, three gates are needed: deduplication, conflict detection, and sensitivity marking. When opposite preferences appear in the same scenario, do not overwrite the old value; record the conflict and raise its confirmation priority. Content involving identity, credentials, or unauthorized data is not written to long-term memory by default.
During retrieval, search by “current scenario + subject scope + validity + relevance,” and inject only a small number of high-confidence items into the execution context. This preserves long-term retention while avoiding irrelevant memory polluting answers.
How to Identify Requirements in Each Turn
Self-evolution depends on stable requirement identification rather than waiting for the user to state every requirement completely. Each turn can extract four types of signals:
- Task intent: query, generate, modify, compare, or execute.
- Explicit requirements: format, length, terminology, deadlines, and materials that must be cited.
- Implicit preferences: directions the user repeatedly revises toward, such as “more concise” or “give the conclusion first.”
- Completion signals: acceptance, partial acceptance, rejection, or additional constraints.
Identification results should first affect the current turn’s plan, and then determine whether to write to memory. One-off temporary requirements, such as “use a table for this version,” should not automatically become global preferences. Only requirements that recur and are confirmed should be upgraded to scenario preferences.
A lightweight turn record can connect identification and execution:
TurnRecorduser_goalextracted_constraints[]scene_idplan_steps[]tools_used[]output_summaryuser_feedback: accept | revise | rejectrevision_deltamemory_writes[]policy_updates[]
This record is the raw material for later auditing and evolution. Without it, the system can only remember that “the user seemed dissatisfied” but cannot specify which policy should change.
How Feedback Becomes Long-Term Policy
Continuously absorbing feedback does not mean changing rules after every comment. Updates should be divided into three stages: candidate, validation, and publication.
The candidate stage records differences only. For example, if a user removes the “background introduction” three times and asks to “list risks first,” the system generates a candidate policy: by default, this scenario starts with a risk list and compresses background into an appendix. At this point, the policy is not yet active.
The validation stage tests the candidate on subsequent similar tasks. If the candidate policy improves acceptance rate, reduces rework, and does not violate compliance constraints, it moves to publication. If it works only for an individual user, it is limited to that user and not promoted to a team policy.
The publication stage writes a versioned policy set. The executor loads the current version when the scenario starts and preserves the policy identifier in the output for traceability. If a policy fails or triggers complaints, the system can roll back to the previous version instead of manually searching chat logs for the cause.
Policies should be written as checkable constraints, not vague slogans:
Policyscene_idversionwhen: task_type=proposal_reviewrequire:- First paragraph states conclusion and risk level- Each recommendation includes rationale and open itemsforbid:- Fabricating data that was not provided- Referencing personal preferences across scenariosescalate_if:- Missing key input- Involving permission or compliance judgment
High-risk actions should still require human confirmation. Self-evolution improves consistency and reuse efficiency; it does not replace authorization and responsibility boundaries.
Reuse of Scenario Knowledge
Methods in mature scenarios are often more valuable than a single model performance: which input fields are needed, which tools to call first, how to verify acceptance, and which errors have occurred before. An organization can build an agent repository where authors publish “trained” scenario agents. Here, training mainly refers to the accumulation of configuration, examples, memory, and policies, not necessarily retraining a foundation model.
A reusable scenario package should include:
- Scenario definition and applicable boundaries, stating what it does not apply to.
- Standard process and checklist.
- Desensitized experience cards and failure cases.
- Policy versions, permission requirements, and human confirmation points.
- A minimal evaluation set: several representative inputs and expected behaviors.
When a new user takes over, they do not directly inherit another person’s personal preferences and raw conversations; they inherit only reviewed scenario methods. Before reuse, run the evaluation set to confirm that the methods still hold under the tenant’s data and permissions. New feedback generated during use enters the local version and, when necessary, is merged back into the public version. In this way, the repository provides an evolvable starting capability rather than an uncontrollable black box.
Key Engineering Controls
Without governance, self-evolution will turn memory and policies into new technical debt. The following controls should be established during implementation.
Traceability: every memory item and policy can be traced back to evidence, author, time, and version. Which policies were referenced in an output should be discoverable in logs.
Least privilege: tools, data, and memory are authorized by scenario. Shared repositories are desensitized by default, and personal preferences are private by default.
Lifecycle: set review and expiration times for memory. When business definitions change, related knowledge is automatically downweighted until reconfirmed.
Evaluation and observability: use fixed scenario sets to compare policy versions, and observe acceptance rate, rework count, human escalation rate, and policy violation interception. Metrics are used to decide whether to publish, not as external performance promises.
Cost control: store only distilled cards and differences, not unlimited raw text. Set an upper limit on retrieval count so long context does not crowd out truly relevant information.
Failure protection: when scenario identification confidence is low, policies conflict, or tool results are abnormal, fall back to clarification or human handling instead of continuing to write memory automatically.
These controls can use general object storage for scenario packages, message queues for feedback events, container platforms for executors, and logs and monitoring alerts to observe policy hits and failure fallbacks. They are capability categories; specific choices and interfaces should follow the norms of the environment rather than being tied to a proprietary naming scheme.
A Complete Execution Loop
Bringing the mechanisms together, a single turn can proceed as follows:
- Parse goals and constraints, and match or create a scenario.
- Read the scenario’s knowledge, experience, and subject preferences according to permissions.
- Load the current policy version, generate a plan, and mark steps that need confirmation.
- Call tools within the authorized scope, aggregate evidence, and generate output according to policy.
- Receive acceptance, revision, or rejection, and record the difference.
- Write reusable differences into candidate memory or candidate policies; publish only after validation.
- Desensitize, evaluate, and publish scenario packages that meet the standard to the repository.
function run(turn):scene = match_scene(turn.goal, turn.constraints)memories = retrieve(scene, turn.actor, limit=k)policy = load_policy(scene.id, status="active")plan = compose_plan(turn, memories, policy)if plan.needs_confirmation:return ask_user(plan.questions)result = execute(plan, allowed_tools(scene))answer = render(result, policy)feedback = await_feedback(answer)propose_updates(scene, feedback) # candidate only; not immediately globalreturn answer
This flow emphasizes two things: use published policies during execution, and produce only candidate updates during learning. Separating the two makes evolution pausable, rollback-capable, and auditable.
Applicable Boundaries and Implementation Order
Self-evolution is suitable for tasks where rules recur, feedback is clear, and the cost of errors is controllable, such as proposal drafting, ticket triage, report interpretation, and standardized R&D assistance. It is not suitable for treating an unverified claim as fact, nor for automatically executing external actions without authorization.
Implementation does not need to be completed all at once. First, fix scenario boundaries and turn records to solve “repeatedly falling into the same pitfalls on the same type of task.” Then separate experience, knowledge, and preferences to solve “personal requirements polluting team processes.” Next, add policy versioning and evaluation to solve “improvements that cannot be rolled back.” Finally, open a reviewed scenario repository to solve “reinventing the wheel for new tasks.”
The value of self-evolution ultimately shows in whether later outputs more consistently follow confirmed scenario methods. As long as memory has boundaries, feedback has evidence, policies have versions, and reuse has permissions, an agent can turn every effective collaboration into the starting point for the next task without sacrificing controllability.
