Dual-Drive Evolution Architecture and Runtime Harness for Persistent Agents
This article describes how persistent agents differ from request-scoped chat programs, and how a runtime harness can connect execution with two complementary evolution paths: external updates to memory and skills, and internal model-weight training. It covers trajectory logging, review triggers, skill verification, GRPO-style training with governed rewards, prompt and context engineering, and practical controls for reliability.
From Chat Programs to Persistent Agents: What Changes in Architecture Goals
Typical chat programs organize compute around a single request: take input, call a model, return a result. Even with multi-turn dialogue, state often lives mainly in session history. Persistent agents must outlive a single request and continuously manage tasks, tools, memory, and execution state on the server.
That shift implies three core requirements.
First, tasks must be recoverable. Complex work may include retrieval, file processing, analysis, and operations on external systems, and can hit timeouts, process exits, or permission interruptions. The system must persist critical state rather than betting the whole workflow on one model call.
Second, experience must be filtered and reused. A success is not automatically a long-term skill, and a failure is not automatically worthless. Useful experience usually includes applicability conditions, failure causes, correction steps, and verification evidence.
Third, capability updates must be constrained. Auto-generated skills can be wrong, training data can be noisy, and updated models can regress. “Self-evolution” in engineering terms means the system can collect feedback, propose updates, validate effects, and release them under control—not that it may strengthen itself unconditionally.
Around this goal, architecture splits into two evolution paths:
- External evolution: update memory, skills, and task strategies without changing model weights.
- Internal evolution: train on governed task data and change model parameters.
The paths can complement each other, but not every agent system has both. Weight training in particular usually needs separate training infrastructure and should not be mixed with online task execution.
Overall Architecture: A Runtime Harness Connecting Execution and Evolution
A general persistent-agent system can be layered as follows:
User request or scheduled event↓Task intake and identity checks↓Runtime harness: state management, model scheduling, tool control, budget limits↓Model inference ↔ controlled tool execution↓Task results, checkpoints, and execution traces↓Async review and data governance├─ Memory and skill candidates → validation → publish└─ Training-data candidates → train → evaluate → deploy
The runtime harness is the control system around the model. It is not merely a wrapper for model calls. It decides what the model can see, which tools it may call, when to stop, how to recover after failure, and which operations require human confirmation.
The model reasons and generates; the harness constrains and executes. Clearer roles make failures easier to locate: model judgment, missing context, tool faults, or incorrect permission and state management.
External Evolution: Turning Traces into Verifiable Skill Assets
1. Record traces before discussing experience
Execution traces should include enough information to explain the task, for example:
- Task goals and completion criteria
- Context used and skill versions
- Tool-call parameters, result summaries, and error types
- Key decisions and checkable evidence
- Final output and verification results
- User corrections, human takeover, and later feedback
Prefer observable events over unverifiable internal model thoughts. For large files and long tool outputs, store references, summaries, and integrity checks instead of stuffing every raw payload into context.
Recording should follow minimization. Access credentials, personal sensitive data, and business secrets should not be retained without limit just because they might be “used for learning.”
2. Trigger review by value, not mechanical counts
Reviewing after a fixed number of turns is easy, but turn count is not experience value. A better mechanism combines task events:
- First completion of a new task type
- A verifiable repair path after failure
- Explicit user correction of system behavior
- Repeated instances of the same problem
- A step with notable cost or risk
Counters can be a fallback trigger, not the only rule. Thresholds should follow workload and review cost, not a fixed default.
3. Decouple foreground response from background review
Users usually should not wait for full experience packaging. After the main path verifies results, return the response, then enqueue review.
Background review can include at least three types:
Facts and preferences. Extract user-stated information with long-term value, and record source, scope, and validity period. Temporary requests should not become long-term preferences.
Skill-candidate generation. Abstract reusable operation paths into structured procedures with preconditions, inputs/outputs, tool dependencies, failure branches, and acceptance methods.
Failure-mode analysis. Separate model errors, missing information, tool exceptions, and process defects. Different causes need different fixes; they cannot all be reduced to “the prompt was not good enough.”
Async processing must handle duplicate delivery and failed runs. Task IDs, idempotent writes, and candidate-state management help prevent the same experience from being published twice.
4. Skills need validation, versions, and exit paths
Reusable skills should not be only natural-language “do this, then that” paragraphs. They need clear boundaries:
Skill: batch document structure checkScope: document sets with explicit section rulesPreconditions: read permission granted; check rules confirmedMain steps: extract structure → match rules → summarize exceptionsVerification: sample review; check that exception locations are accurateFailure handling: report unparsable documents separately; do not invent contentRisk boundary: do not overwrite originals; do not auto-delete content
This is a generic design example, not an existing product interface.
Before a candidate enters the official skill library, run repeatability checks, permission checks, and task tests. Skills that write, delete, or communicate externally need stricter approval.
Publication is not permanent. Tools, business rules, and data structures change, so record versions, evaluation results, and dependencies, and support downgrade and rollback.
Internal Evolution: Use Reinforcement Learning to Optimize Policy, Not to Learn Every Trace
1. Skill accumulation and weight updates solve different problems
A skill library tells the model, via external context, how to handle a class of problems. Cost is usually lower, updates are faster, and audit is easier. Effectiveness still depends on retrieval quality and whether the model follows the procedure.
Weight updates try to change the model’s tendencies on similar tasks so some strategies no longer depend entirely on external prompts. They need higher data quality, training cost, and evaluation effort.
The relationship is not “skills only patch, training only breaks through.” They are different cost structures for capability improvement. Skills can raise task performance substantially; training may help or may introduce regression.
2. The training loop must define verifiable rewards first
On tasks with clear acceptance criteria, group relative policy optimization (GRPO) can be considered. Such methods typically generate a set of candidate traces for the same task and construct relative advantage from within-group reward differences to update policy.
The method itself does not guarantee results. What matters is whether the reward truly reflects the task objective.
For example, data-processing tasks can check constraint satisfaction; tool-operation tasks can check whether a target state was reached. For tasks without objective answers, model scoring or human feedback can provide signal, but review bias must be guarded against.
Reward design should also consider:
- Result correctness
- Permission and safety boundaries
- Effectiveness of tool calls
- Resource consumption
- Whether output contains fabricated conclusions
Cost metrics should not outweigh correctness. If the system over-rewards fewer tool calls, the model may skip necessary verification. If it only rewards output form, the model may learn answers that merely look complete.
3. Govern traces before they enter the training set
Online traces should not go into training untreated. Use a separate data pipeline:
- Strip sensitive information and unauthorized content
- Remove duplicate traces and obviously corrupted data
- Re-verify outcomes
- Split train and test by task, time, or source to reduce leakage
- Keep valid failure cases and correction processes
- Record data origin, processing rules, and usage rights
After training, besides target-task evaluation, check general capability, safety behavior, long-task stability, and tool-use quality. Offline evaluation, limited-traffic validation, and version rollback turn training gains into controlled online improvement.
Prompt Engineering: Keep Goals, Constraints, and Acceptance Criteria Aligned
Prompt design is not endless instruction stacking. A more effective approach layers information:
- System rules: identity, permissions, safety boundaries, and high-risk operation requirements
- Task specification: goals, inputs, constraints, and acceptance conditions
- Dynamic material: retrieval results, tool output, skill fragments, and history summaries
These layers have different trust levels. External documents and tool returns are data to be processed; they must not automatically override system rules.
Task specifications especially need a clear meaning of “done.” “Organize the data” is too vague; “unify field formats, output an exception list, keep original files, and pass sample verification” is easier to execute and evaluate.
For deleting resources, changing production configuration, or sending external messages, authorization should be enforced by the harness, not by a single prompt line that says “be careful.”
Context Engineering: State Governance Inside a Limited Window
Persistent agents do not mean stuffing all history into the model window forever. Context is finite; excess history can dilute the current task.
State can be split into four types:
Working state: current goal, completed steps, pending items, and blockers.
Recent interaction: latest dialogue and tool results that affect the current task.
Long-term memory: confirmed stable facts and preferences, with source and permission scope.
Skill assets: reusable procedures, retrieved by task relevance.
When compressing history, keep constraints that decisions depend on, error evidence, and unresolved issues—not only a generic summary. Store raw traces outside the window and re-read by reference when needed.
In multi-user environments, apply permission filters at retrieval time. Semantic relevance is not authorization. Memory or business material from different users must not mix into the same task because they look similar.
Runtime Harness Practice: Reliability Comes from Explicit Execution Boundaries
1. Manage the task lifecycle with a state machine
Tasks can have states such as waiting, running, pending authorization, retryable failure, completed, and terminated. Record reasons and checkpoints on every transition.
For external writes, confirm whether the action already took effect before resume, to avoid duplicate messages, duplicate records, or duplicate resource changes. Idempotency must come from business APIs or the execution layer, not from the model’s memory.
2. Give tools permissions, timeouts, and resource budgets
Different tools need different capability boundaries. Read, write, delete, and external communication should not share one overly broad permission set.
The execution layer should also set timeouts, output-size limits, retry counts, and a total task budget. When the budget is exhausted, report what completed and what remains instead of guessing a finished conclusion.
3. Put confirmation points on irreversible actions
High-risk operations can be split into generate plan, check impact, obtain authorization, execute, and verify. Human confirmation does not reject automation; it keeps automation inside an acceptable risk range.
4. Make observability span the full path
Correlate task IDs, model versions, skill versions, tool events, review records, and evaluation results. That is how you answer whether a failure came from a new skill, whether quality dropped after a model update, or whether a tool keeps causing retries.
Metrics should cover the whole system, not only answer latency. Useful signals include task completion rate, result-verification pass rate, human-takeover rate, repeated-failure ratio, per-task resource use, and regressions after introducing a skill.
Rollout Order: Controllable Execution First, Then Continuous Evolution
A four-stage path is recommended.
Stage one: establish task state, tool isolation, execution budgets, and result verification to form a reliable base execution path.
Stage two: ship trace recording and human review, and confirm the data can explain success and failure.
Stage three: introduce automatic skill-candidate generation, but use a controlled candidate–test–approve–publish flow with rollback.
Stage four: only when task scale, data quality, and verifiable rewards are mature, evaluate the return on weight training.
The value of persistent agents is not stacking “memory,” “skills,” and “reinforcement learning.” It is that every update has evidence, every execution has boundaries, and every failure can be located. External experience and internal parameter optimization only form a stable, auditable, continuously improvable engineering loop when they are designed together with prompts, context, and the runtime harness.
