Dual-Driven Self-Evolution Architecture and Execution Framework for AI Agents: Engineering Practices
This article explores the engineering practices of building a dual-driven self-evolution architecture for AI agents. It details the separation of online execution and offline evolution, explaining how to transform execution experience into governed skill assets (external-driven evolution) and optimize decision-making strategies through reinforcement learning (internal-driven evolution). Additionally, it covers the execution framework, evaluation system, and a phased implementation approach to ensure that agent self-improvement is measurable, controllable, and verifiable.
1. Redefining “Self-Evolution”: From Experience Accumulation to Verifiable Improvement
AI agents typically consist of language models, context management, tool calling, memory storage, and task scheduling. The model understands goals and generates decisions, while the surrounding system provides information, executes actions, and feeds back results.
In many implementations, context management primarily solves the continuity of the current task: saving conversations, compressing history, and supplementing retrieved information to avoid losing critical constraints midway. However, task success does not mean the system has learned new methods. If effective steps are not distilled and failure causes are not recorded, the system may still resort to trial-and-error when encountering similar problems.
Therefore, discussing agent “self-evolution” requires distinguishing three levels:
- State Continuation: The system can retain task facts and user preferences.
- Strategy Reuse: The system can transform successful methods into retrievable, executable experience assets.
- Parameter Optimization: Through controlled training, the model’s decision distribution changes.
The first two belong to external capability enhancement, while the third involves updating model weights. They can cooperate but should not be confused. Saving a memory entry is not training a model, and generating a skill document does not mean the model has mastered the skill.
A more rational dual-driven architecture uses an external experience layer to improve near-term task execution, an offline training mechanism to drive long-term strategy optimization, and independent evaluation to determine if the improvement is genuinely valid.
2. Overall Architecture: Separating Online Execution and Offline Evolution
To prevent time-consuming operations like retrospectives and training from affecting interactive responses, the system can be divided into an online execution plane and an offline evolution plane.
The main responsibilities of the online execution plane include:
- Receiving tasks and identifying goals, constraints, and permissions.
- Retrieving relevant memories and verified skills.
- Planning actions, calling tools, and handling exceptions.
- Validating task results and returning answers.
- Recording execution trajectories and dispatching retrospective events.
The offline evolution plane is responsible for:
- Cleaning and desensitizing trajectories.
- Extracting facts and summarizing candidate skills.
- Verifying whether the experience has reuse value.
- Building evaluation samples and training data.
- Updating the skill library or model version once release conditions are met.
These two planes can be decoupled via message queues, task tables, or event logs. The key is not which specific infrastructure is used, but ensuring that interactive requests do not wait for all retrospectives to complete, while background tasks have retry, deduplication, and state tracking capabilities.
A conceptual workflow is as follows:
Task Request → Context Assembly → Planning & Execution → Result Validation → User Response
↓
Trajectory Archiving & Retrospective Events
↓
Candidate Experience → Validation → Release
↓
Evaluation & Training Data → Parameter Optimization
This is not a process where the model is updated immediately after every task. Weight training typically requires aggregating sufficient qualified data, performing it in an isolated environment, and going through a release review.
3. External-Driven Evolution: Turning Execution Experience into Governed Skill Assets
3.1 Record Explainable Trajectories, Not Just Chat Text
Simply saving user questions and final answers makes reliable retrospectives difficult. The system needs to understand how the task was completed and where deviations occurred.
A valuable execution trajectory should include:
- Task goals, input conditions, and key constraints.
- Model used, prompt configuration, and skill versions.
- Tool call parameter summaries, results, and error states.
- Key decisions and their observable evidence.
- Final artifacts, validation results, and user feedback.
- Execution time, resource consumption, and human intervention.
“Decision evidence” should prioritize external evidence and structured decision summaries rather than relying on the model to output its complete internal reasoning process. Observable events, tool results, and validation records are more suitable for auditing and reproduction.
When personal information, credentials, or business secrets are involved, trajectories should be collected minimally based on usage. Raw records and records approved for training should be managed separately to avoid mistaking execution permissions for data usage authorization.
3.2 Retrospective Triggers Should Be Determined by Value Signals
Fixed-round triggers can serve as a simple implementation, but the number of rounds is not a reliable indicator of experience value. A single failed high-risk task may be more worth analyzing than multiple rounds of ordinary Q&A.
A more robust trigger mechanism can comprehensively consider:
- Task completion, failure, or abort events.
- Repeated occurrences of the same error.
- Tool calls significantly deviating from common paths.
- User correcting key facts or operational steps.
- Reusable optimization opportunities in high-cost tasks.
- Scheduled batch retrospectives and manual retrospectives.
These conditions are configurable strategies, not fixed parameters common to all agent systems. In actual deployment, retrospective concurrency and budgets must be limited to prevent background analysis costs from crushing online services.
3.3 Distinguish Factual Memory, Skill Experience, and Improvement Suggestions
Retrospective products can be divided into three categories, but their storage and release rules should differ.
Factual Memory is used to store explicitly expressed user preferences, long-term constraints, and necessary background. It should carry source, update time, scope of application, and deletion mechanisms. Model-inferred preferences cannot be treated directly as confirmed facts.
Skill Experience describes reusable task methods. It is not just an abbreviation of a successful process; it should explain under what conditions it applies, what pre-checks are required, and when to stop execution.
Improvement Suggestions are used to identify systemic issues, such as retrieval omissions, incomplete error classifications, or vague tool interface descriptions. Such suggestions may require developers to modify the execution framework and are not suitable for automatic conversion into skills.
Mixing these three products in a single text library can easily lead to user facts being misused as operational rules, or unverified suggestions being treated as approved processes.
3.4 Skills Must Include Boundaries, Not Just Steps
A maintainable skill must at least specify:
- Applicable tasks and inapplicable scenarios.
- Input requirements and preconditions.
- Execution steps and key checkpoints.
- Available tools and permission scopes.
- Common exceptions and recovery methods.
- Success criteria.
- Source, version, maintenance responsibility, and validation status.
For example, a data cleaning skill cannot just say “delete abnormal records.” It should also clearly define abnormalities, whether modifying original data is allowed, whether backups are needed, under what circumstances manual confirmation is required, and how to verify the statistical relationship before and after cleaning.
The core value of a skill is not to make the agent bolder in execution, but to make execution more stable and predictable.
3.5 Establish a Candidate, Validation, and Release Lifecycle
Model-generated experience can only serve as candidate assets. Single-task success might stem from chance factors or mask data leakage or unauthorized behavior.
Therefore, skills should go through the following before release:
- Structure and sensitive information checks.
- Duplication and conflict detection with existing skills.
- Testing on representative and boundary samples.
- Manual review of high-risk content.
- Small-scale release and effect observation.
Skill versions must be rollbackable. If the success rate drops, permission requests increase, or error patterns change after an update, promotion should be paused, rather than defaulting to “the new version is better because it contains more experience.”
4. Internal-Driven Evolution: Optimizing Decision Strategies via Reinforcement Learning
4.1 External Skills and Weight Training Solve Different Problems
External skills are suitable for storing knowledge and processes that change frequently, require auditing, and need quick corrections. Weight training can optimize the model’s understanding of tasks, action selection, and error recovery tendencies.
However, there is no simple relationship of “external experience is necessarily insufficient, reinforcement learning is necessarily a breakthrough.” For many business tasks, improving tool descriptions, adding deterministic checks, or optimizing retrieval may be more effective than training the model.
Parameter optimization is only worth considering when the problem stably exists in the model’s strategy layer, and there is sufficient data and a reliable evaluation method.
4.2 Basic Concept of Group Relative Policy Optimization (GRPO)
Group Relative Policy Optimization (GRPO) is a type of reinforcement learning method. Its typical approach is to sample multiple candidate outputs or execution trajectories for the same task, calculate their respective rewards, and then use intra-group relative performance to form policy update signals.
Conceptually, the relative advantage of a trajectory can be expressed as:
Relative Advantage = (Trajectory Reward - Group Average Reward) / (Group Reward Standard Deviation + Stabilization Term)
This expression only illustrates the intra-group comparison mechanism and is not the complete training objective. Actual implementation also involves probability ratio constraints, deviation control from the reference policy, and the specific granularity of advantage calculation.
For agents, candidate trajectories may involve multiple tool interactions. The training system must therefore not only evaluate the final answer but also handle long-sequence execution, environmental feedback, and dependencies between steps.
4.3 Rewards Must Correspond to Real Task Goals
Reward design is the part of the closed loop most prone to bias. Fluent answers, rich steps, or self-proclaimed “task completion” cannot replace external verification.
Evaluation dimensions to consider include:
- Whether the final result meets task requirements.
- Whether tool calls are legal and necessary.
- Whether permissions and data boundaries are observed.
- Whether failures and uncertainties are handled correctly.
- Whether the execution cost is within a reasonable range.
Among these, safety and permission constraints are usually not suitable as soft rewards that can be offset by other high scores. A more robust approach is to set hard admission criteria or directly reject violating trajectories.
At the same time, guard against reward hacking. For example, if only fewer calls are rewarded, the model might skip necessary checks; if only the final correct state is rewarded, the model might adopt unacceptable destructive operations.
4.4 Training Data Does Not Equal All Production Trajectories
Production logs cannot be directly fed into training without filtering. Erroneous tool outputs, outdated rules, and sensitive data can all pollute the learning process.
Data processing should at least cover authorization confirmation, desensitization, quality filtering, sample deduplication, environment annotation, and train/evaluation separation. Successful trajectories can provide positive references, while failed trajectories need to be accompanied by verifiable error labels or evaluation information, rather than simply being used as demonstrations to imitate.
It is also necessary to prevent approximate variants of the same task from entering both the training set and the test set simultaneously; otherwise, memorization effects may be misjudged as generalization improvements.
5. Execution Framework: Making the Dual-Driven Closed Loop Truly Controllable
The agent execution framework bears the execution control, state management, and validation responsibilities outside the model. It is not a simple tool-calling wrapper, but the engineering foundation that determines whether the system can land safely.
5.1 Constrain the Execution Process with State Machines
It is recommended to clearly distinguish states such as pending, executing, awaiting approval, success, failure, and canceled, and define legal transition conditions.
For operations with external side effects, such as payments, deletions, and permission modifications, permission checks and necessary approvals should be conducted first. Text plans generated by the model should not directly become execution authorizations for high-risk actions.
5.2 Separate Retry and Idempotency
A request timeout does not mean the operation failed. If the system retries blindly, it may duplicate resource creation, send duplicate messages, or modify records repeatedly.
The execution framework should adopt idempotent keys, result queries, or compensation mechanisms based on the operation type. Background retrospectives also require deduplication to prevent the same trajectory from being repeatedly generated and published as multiple skills.
5.3 Isolate Untrusted Content from Control Instructions
Retrieved documents, web texts, and tool return values may contain malicious instructions. They should be treated as data to be analyzed and must not automatically override system permissions, approval requirements, or skill release rules.
The retrospective process also carries similar risks: if external content is transcribed into long-term skills without review, a single input injection might become a continuously effective execution rule. Therefore, experience retention must track its source and be checked for newly introduced permission requirements or abnormal actions.
5.4 Build Observability and Rollback Capabilities
Each task should be able to associate the model version, prompt version, skill version, tool configuration, and result validation records. Skill updates and model updates are best released separately to pinpoint the cause of performance changes.
When anomalies occur, the system should support pausing background releases, rolling back skill versions, switching model versions, and disabling specific high-risk tools. Without these control capabilities, “continuous learning” can easily degenerate into untraceable continuous drift.
6. Evaluation System: Turning “Looks Smarter” into Measurable Conclusions
The dual-driven system needs to evaluate quality, efficiency, and risk simultaneously.
Quality metrics can include task success rate, constraint satisfaction rate, tool parameter correctness rate, and manual correction rate. Efficiency metrics can include completion time, repeated call count, and average resource consumption. Governance metrics include unauthorized events, sensitive information exposure, audit record completeness, and rollback availability.
To identify the independent contributions of the two paths, four groups of experiments can be set up:
- Base model with original execution framework.
- Base model with verified dynamic skills.
- Updated model without newly added skills.
- Updated model with verified dynamic skills.
When comparing, task distribution, tool permissions, and budget conditions should be kept as consistent as possible, and the sample size and result variance should be reported. Otherwise, tasks becoming simpler or tools becoming stronger might be wrongly attributed to “self-evolution.”
7. Phased Implementation: Trustworthy Experience First, Then Model Learning
Phase 1: Improve execution trajectories, result validation, and failure classification. At this stage, do not pursue automatic skill generation; first understand why tasks succeed or fail.
Phase 2: Establish a manually reviewed experience library to verify which processes are worth reusing, and clarify skill formats, permission boundaries, and regression testing requirements.
Phase 3: Introduce asynchronous retrospectives, allowing the system to automatically generate candidate facts, skills, and improvement suggestions, but still controlled by rules and reviews for release.
Phase 4: After independent evaluation proves the skills are effective, expand the automation scope and continuously check for conflicts, expiration, and retrieval hit quality.
Phase 5: Conduct offline training for stable strategy bottlenecks. After passing quality, safety, and cost evaluations, the training results are gradually released into the real task environment.
The focus of this path is to ensure that every round of improvement has evidence, boundaries, and an exit mechanism. Dual-driven self-evolution is not about letting the agent modify itself indefinitely, but forming a governed feedback system through external experience assets and internal strategy optimization. A truly reliable architecture must possess learning ability, verification ability, and the ability to stop incorrect learning.
