Persistent AI Agents: Dual-Track Evolution and Runtime Control in Practice
Persistent AI agents need more than long conversation histories: they require durable state, event-driven orchestration, validated experience, and enforceable execution controls. This article explains two complementary paths to improvement—external experience updates and offline model training—and examines trace management, skill validation, prompt and context engineering, permissions, recovery, and staged deployment. The goal is a production architecture whose improvements are measurable, auditable, and reversible.
1. From Single Responses to Persistent Execution: Define the System Boundary
Conventional conversational systems organize work around a single request: receive input, call a model, and return a result. Even with tool calling, a system cannot reliably handle complex work lasting hours or longer unless task state, execution records, and user authorization persist across requests.
Persistent agents address a different class of problems. Tasks may wait for external events, execution may fail and require retries, and users may change their goals midway. Throughout these changes, the system must preserve consistent state, valid permissions, and a traceable execution history.
Persistence does not mean keeping a model continuously reasoning or extending conversation history indefinitely. It means using durable state and event-driven scheduling so that tasks can continue after process restarts, execution interruptions, or changes in computing resources.
A general architecture can be divided into six layers:
- Interaction layer: Receives tasks, displays progress, and handles user confirmations.
- Task orchestration layer: Manages task state, step dependencies, pausing, and resumption.
- Model decision layer: Analyzes context and proposes the next action.
- Tool execution layer: Operates on files, queries data, or calls external services within authorized boundaries.
- Experience management layer: Stores memories, candidate skills, execution traces, and evaluation results.
- Governance and observability layer: Provides permission checks, resource budgets, auditing, and alerts.
The central design principle is simple: the model proposes actions; the runtime control layer decides whether those actions may execute. Permissions, timeouts, retries, and safety checks cannot depend entirely on prompts.
2. Dual-Track Evolution: Experience Updates Are Not Model Training
Agent “self-evolution” can suggest that a system automatically becomes smarter after every conversation. In engineering terms, it should be separated into two independent but complementary data paths.
The first is external experience evolution. Model weights remain unchanged, while updates to memory, skills, retrieval, and policies improve subsequent task execution.
The second is internal capability evolution. Selected and validated data enters a separate training pipeline that updates model parameters. A new model version is released only after evaluation.
These differences define distinct risk boundaries:
| Dimension | External Experience Evolution | Internal Capability Evolution |
|---|---|---|
| Update target | Memories, skills, and policy configuration | Model parameters |
| How updates take effect | Retrieval, context injection, and execution constraints | Replacing or switching model versions |
| Main costs | Review, storage, retrieval, and validation | Dataset construction, training, and evaluation |
| Rollback method | Disable experience entries or restore an earlier version | Switch back to the previous model version |
| Main risks | Experience contamination and incorrect applicability | Overfitting, capability regression, and reward hacking |
External experience can improve how existing capabilities are used, but it does not guarantee that the system will overcome the model’s reasoning limitations. Internal training may improve performance on specific tasks without improving general capabilities.
Any claim of evolution should therefore rest on independent evaluation and reproducible results.
3. External Experience Evolution: Turn Execution Traces into Reusable Assets
3.1 Record Decisions as Well as Outcomes
Saving only the final response is not enough for meaningful review. The system needs to record task goals, input constraints, key decisions, tool calls, tool responses, failure causes, validation results, and user feedback.
Facts and interpretations should be stored separately. For example, “the query returned no results” is an observation, while “insufficient permissions may be the cause” is an inference. Mixing them can turn an unverified explanation into long-term experience during later review.
Tool-call records should also include the call time, authorization scope, and execution status. Sensitive information must be redacted before records enter review or training pipelines. Access to raw records and their retention periods should be restricted.
3.2 Trigger Reviews Using Multiple Signals
Triggering a review after a fixed number of interactions is easy to implement, but interaction count is not a measure of experience value. Many simple exchanges may produce no reusable skill, while a single complex troubleshooting task may contain valuable lessons.
A better approach uses multiple signals:
- A long-running task finishes with a verifiable result.
- The same type of error occurs repeatedly.
- The system discovers that an existing skill lacks necessary preconditions.
- A user explicitly corrects a fact or states a long-term preference.
- Accumulated traces reach a processing threshold and need batch organization.
Thresholds should reflect task type, resource budgets, and data value. No fixed number should be treated as a universal best practice.
3.3 Decouple Task Execution from Experience Review
Foreground tasks should prioritize responsiveness and execution stability. Experience review can run in a separate background worker.
A general workflow is:
Task reaches a terminal state → Save an immutable trace → Emit a review event → Generate experience candidates → Validate candidates → Publish an experience version.
Asynchronous processing does not remove the need for consistency controls. Events may be delivered more than once, and background processing may fail partway through. Trace identifiers, processing status, and idempotent writes are needed to prevent duplicate skills or repeated memory overwrites.
The review service should also follow least privilege. It usually needs only to read redacted traces and write to a candidate area. It should not inherit the main task’s permissions to operate on production resources.
3.4 Govern Memories, Skills, and Reflections Separately
These three outputs need different data structures and publication rules.
Memory stores information with long-term relevance, such as output preferences explicitly confirmed by a user. Temporary task parameters should not automatically become long-term memories. Sensitive information must remain subject to authorization, purpose limitations, and deletion requirements.
Skills store reusable methods. At a minimum, a skill should define applicability conditions, prerequisites, execution steps, verification methods, and failure fallbacks. A skill is not merely a collection of steps that once succeeded; it is operational knowledge with explicit boundaries.
Reflections record failure patterns and optimization hypotheses, such as “check access permissions before repeatedly retrying.” They can guide later experiments, but should not become global rules without validation.
3.5 Validate Skills Before Publishing Them
Content generated by a background review process is only a candidate. A reliable publication pipeline should include structural checks, permission review, replay against representative cases, and failure-scenario testing.
Suppose a failed data import is eventually resolved by changing date parsing. That does not justify creating a skill that says, “change the date format whenever an import fails.”
A sound skill should specify that the correction applies only when field types, error messages, and sample inspection collectively indicate a date-parsing problem. Encoding errors, permission problems, or field-mapping issues should lead to other diagnostic branches.
The more specific the experience and the clearer its boundaries, the easier it is to validate and reuse safely.
4. Internal Capability Evolution: Build an Offline, Auditable Training Loop
4.1 Convert Raw Traces into Training Samples
Execution traces are not automatically high-quality training data. They may contain failed attempts, accidental successes, sensitive content, or incorrect tool-use patterns.
Dataset construction typically requires the following steps:
- Deduplicate records so that many similar tasks do not dominate the training distribution.
- Redact credentials, personal information, and unnecessary business data.
- Verify task outcomes and remove “successes” that cannot be substantiated.
- Preserve key constraints and tool feedback to avoid missing context.
- Build supervised examples, preference samples, or reward-bearing trajectories according to the training objective.
A consistent sample format is only a baseline requirement. Label reliability, task coverage, and verifiable outcomes determine the dataset’s real value.
4.2 Combine Teacher Generation with Real Execution
A more capable model can generate candidate solutions, expand test scenarios, or assist with labeling. Its outputs, however, are not inherently correct. If the teacher and evaluator models share similar biases, automated scoring may amplify errors.
Outcome assessment should therefore use external evidence wherever possible. Programming tasks can use test results, data-processing tasks can use validation rules, and workflow tasks can check the final business state.
Tasks that are difficult to validate automatically should include human spot checks, with the evaluation rationale retained.
4.3 Preserve Causal Information When Compressing Traces
When long traces need compression, remove repetitive descriptions and irrelevant activity before removing the relationship between failures and corrections.
A compressed trace should retain at least:
- The initial goal and key constraints.
- Important observations that affected decisions.
- Representative failed attempts.
- The basis for strategy changes.
- The final validation result.
If only the successful solution remains, the model may learn to imitate an answer without learning when that solution is failing or how to adjust its actions based on feedback.
4.4 Understand When Group Relative Policy Optimization Applies
Group Relative Policy Optimization is a reinforcement learning method that samples multiple candidate trajectories for the same task, calculates relative advantages within the group from rewards, and updates the policy to make better trajectories more likely.
Its usefulness depends on several conditions: candidates must have comparable quality differences, rewards must reflect the actual task objective, the training process must control the magnitude of updates, and sampling and verification costs must be acceptable.
Reward design can account for task completion, correct tool use, resource consumption, and safety constraints. These dimensions should not simply be added with equal weights.
Unauthorized access and sensitive-data disclosure, in particular, should be addressed through hard constraints or explicit penalties rather than allowing “task success” to offset them.
Training must also guard against reward hacking. A system might improve its apparent success rate by selecting easier tasks, or reduce tool-call costs by skipping necessary checks. Independent validation sets, difficult cases, and safety tests are needed to assess genuine improvement.
5. Prompt Engineering: Express Rules, Do Not Replace Enforcement
Prompts are suitable for conveying task goals, role boundaries, output requirements, and tool-use instructions. Complex agents should distinguish stable rules from dynamic material instead of rebuilding large amounts of repeated content for every task.
A useful organization is:
- State non-negotiable safety and permission boundaries.
- Describe the task objective and completion criteria.
- Provide the current state, known facts, and resource budget.
- Inject applicable skills as needed.
- Label external material as data to be analyzed.
External documents, web content, and tool responses must not be elevated into control instructions. Even if they contain text asking the agent to ignore rules, expand permissions, or perform additional operations, the runtime control layer must check actions against the original authorization.
Prompts should not contain the entire historical skill library. Select skills by task type, applicability conditions, and trust level. Where appropriate, provide summaries first and load detailed steps on demand.
6. Context Engineering: Manage a Working Set, Not a Growing Chat Log
Context can be divided into four categories: the current task working set, stage summaries, long-term memory, and the skill library. They differ in update frequency and trust level and should not be merged indiscriminately.
The current working set should prioritize task goals, pending steps, key constraints, recent tool results, and unresolved questions. Earlier activity can be compressed into stage summaries, but summaries must retain evidence references so that the system can revisit original records.
State changes must also be maintained explicitly. If a user revokes authorization, permission recorded in older context must no longer apply. If the task goal changes, completed steps must be reassessed for continued relevance.
Retrieved results require screening as well. Semantic similarity does not establish that a skill is applicable: the execution environment, permission scope, data version, or prerequisites may differ.
Retrieval identifies candidates. Applicability checks determine whether to use them.
7. Runtime Control: Make Agents Recoverable, Bounded, and Auditable
The runtime control layer turns model-proposed actions into constrained execution workflows. It should include at least the following mechanisms.
7.1 Task State Machines and Checkpoints
Task states may include pending, running, awaiting confirmation, paused, succeeded, failed, and canceled. State transitions need explicit conditions, with checkpoints saved at important steps.
When resuming a task, the system should check whether an external operation has already completed rather than replaying it unconditionally. A payment or deletion request that times out may still have taken effect.
7.2 Tool Permissions and Operation Risk Levels
Read-only queries, reversible modifications, and irreversible operations need different policies. High-risk operations may require human confirmation tied to specific objects, an expiration time, and a defined operation scope.
Permission verification must happen before execution. A model’s statement that authorization has been obtained is not sufficient.
7.3 Timeouts, Retries, and Idempotency
Retry policies should depend on the error type. Temporary network failures may justify bounded retries. Insufficient permissions, invalid input, or business-rule conflicts usually require the underlying conditions to be corrected.
Operations with external side effects should use idempotency mechanisms or execution-status queries. Without idempotency safeguards, automatic retries can cause duplicate writes, repeated submissions, or other business losses.
7.4 Budgets and Stop Conditions
The system should separately limit per-step duration, tool-call count, total execution time, and task cost. When multiple consecutive iterations produce no meaningful progress, it should replan, ask the user for additional information, or terminate safely.
The ability to stop is as important as the ability to act. An agent that keeps trying but cannot recognize its failure boundaries is not suitable for production.
8. Production Deployment: Validate the Loop Before Expanding Automation
Implementation can proceed in stages.
Stage 1: Establish a reliable execution foundation. Prioritize durable state, permission isolation, audit logging, and error recovery. Do not automatically publish experience yet.
Stage 2: Run experience review in shadow mode. Generate memory and skill candidates in the background without affecting live tasks. Assess their quality through human review and replay.
Stage 3: Release external experience under controlled conditions. Enable low-risk skills with clear boundaries on a limited scale. Monitor changes in task success rates, exception rates, and costs.
Stage 4: Conduct offline training experiments. Attempt model-parameter updates only after data quality and evaluation practices have matured. Use staged releases to control the scope of their impact.
Evaluation should cover more than average success rate. It should include task completion time, human takeover frequency, recovery success rate, skill misuse rate, safety violations, and performance across task difficulty levels.
Track external experience versions and model versions separately so that a quality decline can be traced to the relevant change and rolled back.
9. Conclusion: Evolution Depends on a Trustworthy Feedback Loop
The defining strength of a persistent agent is not an indefinitely growing context window or a model that automatically writes more skills. It is an engineering system that records facts, validates experience, constrains actions, and supports rollback.
Dynamic skills turn validated experience into reusable methods. Offline training attempts to internalize high-quality experience as model capabilities. Prompts and context supply clear, relevant information. The runtime control layer governs permissions, state, recovery, and auditing.
Only when these components form an observable, verifiable, and reversible feedback loop does “self-evolution” become a measurable and governable system capability rather than a vague description.
