Dual-Drive Self-Evolving Agent Architecture and Runtime Framework: Engineering Practices

    This article examines how agent systems can move from one-off task execution to continuous improvement through a dual-drive architecture. It covers trace-based experience capture, asynchronous review, memory and skill curation, controlled parameter optimization, runtime safeguards, evaluation, and a staged rollout path for building a reliable improvement loop.

    1. From One-Off Task Execution to Continuous Improvement

    Agents typically complete tasks through a loop of “understand the goal, create a plan, call tools, observe results, and adjust actions.” This mechanism can handle multi-step problems, but task completion does not mean the system has learned a new capability. If failure causes, fixes, and applicable conditions are not preserved, the system may repeat the same trial and error the next time it encounters a similar problem.

    Context management can mitigate this issue, but it cannot solve it independently. The context window mainly carries information needed for the current task. Summaries and compression can reduce information footprint, but they do not naturally constitute long-term knowledge, nor do they guarantee that experience can be reliably reused.

    Therefore, a continuously improving agent needs to distinguish four types of information:

    • Task state: the current goal, completed steps, unresolved issues, and execution constraints.
    • Long-term memory: confirmed user preferences, stable facts, and necessary environment information.
    • Reusable skills: experience assets with applicable conditions, operational steps, validation methods, and failure-handling strategies.
    • Training samples: filtered, desensitized, and quality-checked data that can be used for subsequent model optimization.

    These four types of information have different lifecycles, access permissions, and quality requirements. They cannot simply be mixed into one ever-growing prompt text.

    “Double-drive self-evolution” can be understood as two complementary improvement paths: one improves performance by updating external memory, skills, and execution strategies; the other adjusts model parameters through controlled training so that some capabilities are consolidated inside the model. Here, “evolution” should be based on measurable performance improvement, not on equating automatically generated documents with capability growth.

    2. External Drive: Turning Execution Experience into Reusable Assets

    2.1 Establish a Complete and Traceable Execution Trace

    The foundation of experience curation is not the final answer, but the complete execution process. Saving only the conclusion “task succeeded” makes it impossible to determine whether success came from a reliable method, accidental conditions, or human intervention.

    The following information should be recorded:

    • Task goals, input conditions, and permission boundaries.
    • Key decisions and their observable evidence.
    • Tool call parameters, returned results, and error messages.
    • Retry, rollback, and human correction processes.
    • Final artifacts and their validation results.
    • Data sources, timestamps, environment versions, and resource consumption.

    The focus should be on verifiable behavior and results. The system should not require storage of unobservable internal reasoning from the model. For sensitive data, necessary desensitization, access control, and retention-period management should be performed before persistence.

    2.2 Use a Separated Architecture for Foreground Execution and Background Review

    If memory curation, skill generation, and quality review are completed synchronously with every response, users bear additional waiting time. A more reasonable design is to prioritize task completion in the foreground and conduct review in the background based on saved traces.

    The conceptual flow can be represented as:

    Task request → Execution and validation → Return result
             ↓
         Trace storage → Review queue → Experience review → Candidate assets → Validated release

    Asynchrony does not mean unrestricted parallel processing. Background tasks still require idempotency, retry limits, timeout control, and failure isolation. When the same trace is consumed repeatedly, the system should not write the same memory repeatedly or generate multiple indistinguishable skill versions.

    In addition, background review should treat execution records as read-only by default, avoiding unauthorized operations on the production environment after the user task has already ended.

    2.3 Trigger Review with Multi-Dimensional Conditions Rather Than Mechanical Counts

    Triggering experience curation by interaction count is a simple strategy, but the count itself does not reflect the value of the experience. A large number of repetitive Q&A interactions may not be worth reviewing, while a single complex failure-handling episode may contain important knowledge.

    A more robust trigger mechanism can consider:

    • Whether task complexity exceeds a defined threshold.
    • Whether multiple failures, retries, or path switches occurred.
    • Whether human corrections or explicit user feedback are included.
    • Whether a new scenario not covered by existing skills was discovered.
    • Whether enough similar tasks have accumulated.
    • Whether background compute budget and current queue load allow processing.

    Specific thresholds should be determined by business data and evaluation results. Counters are suitable as scheduling signals, but they should not be treated as sufficient proof that “learning value is present.”

    3. Review Responsibilities: Memory, Skills, and Error Analysis

    3.1 Memory Review: Retain Only Stable and Necessary Information

    The goal of the memory module is to reduce repeated confirmation, not to store as much user information as possible. One-time instructions, temporary authorization, and incidental conditions in the current task usually should not be automatically promoted to long-term preferences.

    For example, “use a short format for this report” and “use a short format for all future reports” have different persistence implications. The system needs to judge based on explicit expression, scope of application, and validity period.

    Memory entries should include source, confirmation status, update time, and scope of application. When new and old information conflict, change records should be retained. For preferences or facts with significant impact, the system can request user confirmation instead of silently overwriting them.

    3.2 Skill Review: Extract Methods, Not Copy Traces

    A high-quality skill is not an abbreviation of one successful record, but a method that can be executed repeatedly across different inputs. During extraction, temporary paths, incidental data, and task-irrelevant context should be removed, while preconditions that truly affect success should be retained.

    A maintainable skill should include at least:

    • Applicable scenarios: what problem it solves and when it does not apply.
    • Preconditions: required permissions, data, and environment capabilities.
    • Inputs and outputs: what information is received and what result is produced.
    • Execution steps: key actions, branch conditions, and checkpoints.
    • Validation criteria: how to confirm that the task is actually complete.
    • Failure handling: when to retry, roll back, or hand over to a human.
    • Risk notes: which operations may cause irreversible impact.

    For example, if a data import failure is resolved by adjusting field mappings, the reusable skill should describe field checks, mapping confirmation, trial import, and result validation. It should not save the complete operation record of a temporary file.

    3.3 Integrated Review: Analyze Observable Error Patterns

    Error review should distinguish between model judgment errors, tool failures, missing inputs, insufficient permissions, and environment changes. If all failures are attributed to “insufficient model capability,” subsequent training may fail to improve the problem and may instead increase system complexity.

    An effective review should answer: at which stage did the failure occur, what evidence supports that judgment, why existing rules failed to prevent the failure, whether prompts, skills, tool validation, or permission policies should be modified, and how to verify the modification.

    When causality is unclear, uncertainty markers should be retained to avoid packaging accidental success as a general rule.

    4. Internal Drive: From High-Quality Samples to Controlled Parameter Optimization

    External asset updates can change system behavior relatively quickly, but they also introduce retrieval costs, context occupancy, and conflicts among multiple skills. For capabilities that are high-frequency, stable, and improvable through training, parameter optimization such as model fine-tuning can be considered.

    It is important to clarify that dynamic skill generation does not automatically change model weights. Parameter updates must go through independent data preparation, training, evaluation, and deployment processes, and depend on actually available training capabilities.

    4.1 Training Data Must Be Filtered

    Raw execution traces cannot be directly treated as high-quality training samples. Failure processes may contain incorrect operations, sensitive information, outdated knowledge, and unsafe instructions. Successful traces may also have satisfied environmental conditions only by accident.

    Data processing typically includes:

    1. Desensitization and authorization checks.
    2. Deduplication and near-duplicate detection.
    3. Label and success-criteria verification.
    4. Filtering or explicit labeling of erroneous steps.
    5. Scenario coverage and sample distribution checks.
    6. Isolation of training, validation, and test sets.

    If highly similar traces of the same task appear in both the training set and test set, evaluation results may be inflated and may not reflect real generalization ability.

    4.2 Distinguish Knowledge That Should Be Internalized from Knowledge That Should Be Externalized

    Not all information is suitable for writing into model parameters. Frequently changing business rules, user-specific data, access credentials, and real-time states are better kept in controlled external systems. Relatively stable task patterns, structured output habits, and general operational judgment are more likely candidates for parameter optimization.

    A practical principle is: if a type of knowledge needs frequent updates, precise deletion, or strict per-user isolation, external storage and retrieval should be preferred over relying on trained memory.

    4.3 Constrain Updates with Evaluation Rather Than Subjective Judgment

    Parameter optimization may improve one type of task while harming other capabilities. Before release, the system should check target task performance, retention of general capabilities, correctness of tool calls, compliance with permission boundaries, and risk of sensitive information leakage.

    Evaluation should not only check whether the final answer “looks reasonable.” For execution-oriented agents, actual artifacts, key steps, and environment state changes should be verified.

    Model versions and skill versions should also be managed separately. Otherwise, when performance declines, it is difficult to determine whether the problem comes from a model update, a skill modification, or a runtime framework change.

    5. Runtime Framework Engineering: Making the Improvement Loop Reliable

    The runtime framework is the execution infrastructure that connects models, tools, state, memory, skills, and evaluation. It determines how the agent obtains information, how it takes action, and when it must stop.

    5.1 Define Clear States and Stop Conditions

    Task execution should have clear states, such as waiting for input, executing, waiting for approval, validating, completed, and failed. Each state transition should be supported by observable events.

    At the same time, budget and termination rules should be set, including limits on tool calls, execution duration, consecutive failures, and resource consumption. A loop without stop conditions may amplify a local error into ongoing cost or operational risk.

    5.2 Tool Calls Must Pass Boundary Checks

    Operation requests generated by the model cannot be directly treated as trusted instructions. Before execution, the system should check parameter types, target scope, permissions, operational risk, and required approvals.

    Read-only queries and data deletion should use different control levels. For irreversible operations, explicit confirmation can be required, and pre-checks, backups, or rollback plans should be provided where feasible.

    5.3 Use Versioned Release for Skill Updates

    Content generated in the background should first enter a candidate area rather than immediately taking effect for all tasks. A recommended process is “candidate generation, static checks, test validation, controlled trial, and formal release.”

    Static checks are used to find missing conditions, dangerous operations, and unclear instructions. Test validation is used to examine normal inputs, boundary inputs, and failure paths. Controlled trials are used to observe effects in real environments.

    Each skill version should retain its source trace, scope of application, change notes, and evaluation results. When anomalies occur, the system should be able to disable the new version and restore a verified version.

    5.4 Prevent External Content from Contaminating the Experience Base

    Documents, web pages, tool results, and user-uploaded files may contain persuasive instructions. If the system writes such content into long-term memory or the skill library without distinction, short-term input risk can become long-term behavioral risk.

    Therefore, the system should clearly distinguish “data used to complete a task” from “instructions allowed to change system behavior.” External content can serve as evidence, but it cannot by itself obtain system-level permissions. Candidate experience involving permission expansion, validation bypass, or data exfiltration should be rejected or sent to human review.

    6. Evaluation and Operations: Proving That the System Is Actually Improving

    A continuously improving system requires observation of both task quality and engineering health.

    Task quality metrics can include completion rate, result correctness, human intervention rate, recurrence of repeated errors, and skill reuse effectiveness. Engineering metrics can include response latency, background review time, queue backlog, resource cost, and update failures.

    These metrics must have clear definitions. For example, “completed” should correspond to a verifiable artifact or state, not a model declaring success on its own. Skill reuse should not only count retrieval occurrences; it should also check whether outcomes improved after use.

    An evaluation system should include:

    • Fixed regression tasks to detect degradation of existing capabilities.
    • New scenario tasks to test coverage.
    • Adversarial and abnormal inputs to check security boundaries.
    • Small-scale real-task trials to validate environmental adaptability.

    The same generation module should not be solely responsible for all quality judgment. Automated scoring is suitable for initial screening, but high-risk tasks require rule validation, environment verification, or human spot checks.

    7. Rollout Order: Establish Evidence Before Expanding Automation

    When building a dual-drive loop, it is not necessary to introduce parameter training from the beginning. A more reliable sequence is to proceed in stages.

    In the first stage, establish structured traces, unified task validation criteria, and basic monitoring. The first problem to solve is “what happened, and was the result correct?”

    In the second stage, introduce asynchronous review and a candidate skill library, and confirm the quality of experience extraction through human review and regression testing.

    In the third stage, improve skill retrieval, version management, controlled release, and automatic rollback, gradually increasing the automation level of external evolution.

    In the fourth stage, after data quality and the evaluation system are stable, consider parameter optimization and independently assess training benefits, deployment costs, and capability degradation risks.

    The core value of a dual-drive architecture is not how many experience documents the system can automatically write. It is whether the system can form a controlled evidence chain: execution results are verifiable, experience sources are traceable, asset updates are evaluable, model changes are comparable, and abnormal behavior can be rolled back. Only when these conditions are met can continuous agent improvement move from concept to reliable engineering capability.