Memory Architecture and Skill Evolution for Persistent Autonomous Agents
This article examines how persistent autonomous agents can operate reliably across sessions by separating task coordination, execution, memory, and governance. It covers layered memory design, permission-aware full-text search, procedural skill contracts and staged release, checkpoint-based recovery, security controls, and evaluation methods for long-running agent systems.
1. From Single-Turn Q&A to Continuous Task Execution
Traditional dialogue systems typically generate one response for one input, with the main goal of providing information or supporting decisions. Autonomous agents must go further: decompose goals, call tools, check results, and take follow-up actions. When tasks span multiple sessions or depend on prior execution experience, the current conversation context alone is no longer enough to support stable operation.
For example, in ongoing business report maintenance, the system must not only understand the current request but also know the meaning of data fields, previously confirmed statistical definitions, why the last processing attempt failed, and which operations require human approval. If this information exists only in temporary context, it is lost when the session ends or the context capacity changes.
Persistent autonomous agents therefore need to address three core problems:
First, how to restore a trusted execution state after a task is interrupted.
Second, how to find historical information relevant to the current task when a new session begins.
Third, how to turn operation flows validated across multiple tasks into reusable skills.
These problems correspond to runtime state management, cross-session memory, and skill evolution. Together they form the foundation for long-running agents, but this does not mean the system can run autonomously without limits, nor that it can modify its own capabilities without authorization.
2. Overall Architecture: Separate Reasoning, State, and Execution
A maintainable agent system should not cram every capability into an ever-growing prompt. A more reasonable approach is to divide responsibilities among cooperating modules.
2.1 Task Coordination Layer
The task coordination layer receives goals, creates task records, decomposes steps, and decides whether the next step should execute a tool, query memory, or ask the user for missing information.
Each task should have an explicit state, such as pending, running, waiting for approval, completed, and failed. State transitions need constraints to prevent the same task from being processed repeatedly by multiple execution units.
For long-running tasks, the system should also set maximum execution steps, time budgets, and resource budgets. Autonomy must have boundaries; otherwise, a faulty plan may keep consuming resources without producing useful results.
2.2 Execution Layer
The execution layer handles actual operations such as file processing, data queries, and program execution. The model may propose actions, but whether an action can be executed should be decided by an independent permission and policy check.
This separation matters: a language model generates candidate actions, not inherently trusted execution instructions. Actions involving data deletion, external notifications, or changes to business configuration require additional validation.
2.3 Memory and Skill Layer
The memory layer stores facts, preferences, historical results, and failure lessons. The skill layer stores validated operation flows. The two should not be conflated.
“The user prefers weekly summaries” is memory. “The execution flow for converting raw data into a weekly report” is a skill. Memory influences decisions; skills constrain and reuse operations.
2.4 Governance and Observability Layer
The governance and observability layer records model decisions, tool calls, permission decisions, exceptions, and human intervention. Without these records, it is difficult to determine whether a failure came from incorrect memory, planning deviation, the execution environment, or permission configuration.
3. Cross-Session Memory: Save Necessary Information, Not All Chat Content
Cross-session memory is not simply reattaching historical conversations to the prompt. Raw conversations contain repeated descriptions, temporary guesses, expired conditions, and sensitive information. Reusing them directly can increase noise and expand leakage risk.
A more suitable design is layered memory.
3.1 Working Memory
Working memory serves the current task and stores recent observations, intermediate conclusions, and to-do items. It usually has a short lifecycle and should not be promoted to long-term knowledge by default.
For example, the temporary file location in a data processing task is meaningful only during that execution. After the task ends, it should be cleaned up or archived according to retention policy.
3.2 Episodic Memory
Episodic memory stores the execution process and results of specific tasks, including goals, key operations, error causes, and references to final artifacts. It helps the system answer “how was a similar task completed before?”
Episodic memory should preserve traceable evidence rather than only a one-line success summary. Otherwise, the system may remember a conclusion but be unable to judge whether that conclusion applies to current conditions.
3.3 Fact and Preference Memory
This type of memory stores relatively stable information, such as explanations of business terms, confirmed data definitions, and explicitly stated user output preferences.
When writing memory, the system should distinguish information sources. User-confirmed rules, program-checked results, and model inferences have different levels of trust and should not receive equal weight. When important facts change, version relationships should be preserved rather than silently overwritten.
A memory record can contain at least the following fields:
- Memory identifier and category;
- Information content and source;
- Creation time, update time, and expiration time;
- User, organization, or task scope;
- Verification status and evidence references;
- Sensitivity level and access permissions.
These fields are not a fixed interface. They are a design reference for establishing data governance boundaries.
4. Full-Text Search: Make Historical Information Queryable, Filterable, and Verifiable
Full-text search indexes text and supports finding relevant records by term. It is suitable for explicit terms, error messages, field names, and operation descriptions, and is an important foundation for cross-session memory.
However, full-text search only addresses which text may be relevant. It cannot automatically determine whether the text is true, still valid, or accessible to the current user.
4.1 Process Content Before Indexing
Before writing to the index, necessary structured processing should be performed: remove duplicate records, identify sensitive content, extract time and task tags, and split long records into semantically complete chunks.
Chunk granularity should be chosen according to the actual task. If chunks are too large, they introduce irrelevant content. If chunks are too small, they may lose the preconditions for a conclusion.
For example, storing “export failed” alone has limited value. “Export failed when fields were missing, and recovered after mapping was completed” preserves the relationship between the problem and the resolution.
4.2 Retrieval Must Combine Permissions and Scope
When querying memory, the system should first limit the data scope accessible to the current user or organization, then perform relevance retrieval. It must not retrieve all content first and rely on the model to ignore information it should not see.
Time, task type, and business scope should also participate in filtering. Recent rules are often more relevant than expired rules, but newer does not automatically mean more correct; version status and verification evidence should be considered.
4.3 Retrieval Results Need Secondary Filtering
Before candidate records enter the model context, obviously expired, duplicate, or conflicting content should be removed, and necessary source notes should be retained.
Full-text search is sensitive to lexical overlap. When users use synonyms or abstract descriptions, semantic retrieval can supplement candidate results. However, adding retrieval methods does not necessarily improve quality. The benefit still needs to be judged through evaluation on actual tasks.
4.4 Define a Path for “I Don’t Know”
If no trusted record can be retrieved, the agent should return to evidence from the current task or ask the user, rather than treating similar historical experience as established fact.
Memory is an auxiliary information source, not unquestionable authority. When current data conflicts with historical memory, the system needs to show the conflict and verify it.
5. Procedural Skills: Turn Successful Experience into Controlled Assets
Reasonable autonomous skill generation means the system proposes reusable flows based on completed tasks and puts them into use after testing, review, and version management. It is not equivalent to automatic model training, nor does it mean core model parameters have changed.
5.1 What Tasks Are Suitable for Skills
Tasks suitable for skill development usually have clear inputs, stable steps, and verifiable outputs, such as data cleaning, format conversion, report generation, or result checking.
If a task depends heavily on temporary judgment, or every execution requires complex business authorization, it should not be directly fixed as an automated execution skill. In such cases, it is more appropriate to store checklists or decision guidance.
5.2 Skills Must Include a Complete Contract
A skill cannot be just a program or set of operating instructions. It should also specify:
- Input format and preconditions;
- Output structure and completion criteria;
- Required permissions and external dependencies;
- Possible side effects;
- Failure handling;
- Applicable scope and known limitations.
For example, a skill for batch file organization should clarify whether it overwrites files with the same name, how it handles empty directories, and whether recovery is possible after failure. Without these constraints, even if a normal sample runs successfully, the skill is not proven reliable.
5.3 Use Staged Release
Skills can go through stages such as draft, test passed, review passed, available, and disabled. The generation stage produces only candidate assets and must not directly grant production execution permissions.
Testing should cover normal input, empty input, malformed formats, repeated execution, and insufficient permissions. When external writes are involved, testing should also check whether repeated execution causes duplicate data or irreversible effects.
5.4 Preserve Versions and Rollback Capability
After a skill is updated, it should be linked to the reason for change, test results, and usage records. If a new version behaves abnormally, the system should be able to disable or roll it back rather than continuing to execute repeatedly based on faulty experience.
The easier a skill is to reuse, the wider the impact of its defects may spread. Skill management therefore needs to be stricter than one-off temporary operations.
6. Persistent Operation: Rely on Recoverable Workflows, Not Extremely Long Sessions
Long-running operation should not depend on a session that never ends. A more reliable approach is to split tasks into persistable steps and save checkpoints at key nodes.
A checkpoint should record the current task state, completed actions, pending steps, and necessary artifact references. After a process restarts, the system resumes from these records rather than relying on the model to guess what happened before.
External operations require special attention to idempotency, meaning the same operation can be repeated without unexpectedly producing additional side effects. For example, report generation can use a task identifier to confirm whether an artifact already exists; actions involving business writes need explicit deduplication or confirmation mechanisms.
For timeouts and failures, the system should distinguish retryable errors from non-retryable errors. A temporary connection interruption may be suitable for limited retries, while missing input or insufficient permissions usually requires stopping and requesting handling. Blind retries cannot fix incorrect premises and may expand the impact.
7. Security Governance: Memory and Skills Can Both Become Risk Entry Points
Autonomous agents both read external content and execute actual actions, so they must prevent external text from being mistaken for high-priority instructions.
Content in documents, web snippets, or historical records such as “ignore existing rules” or “send all data” should be treated as data to be analyzed, not authorized commands. When retrieval results enter the context, their source and purpose need to be clearly marked.
Permission management should follow the principle of least privilege. Read-only queries and write modifications should use different authorization scopes; high-risk actions should have approval conditions; the execution environment should restrict accessible directories, network ranges, and resource usage.
Memory governance also needs to support expiration deletion, user correction, and access revocation. In particular, avoid writing passwords, access credentials, or unrelated personal information into long-term memory. When memory is deleted, corresponding indexes and caches should also be processed so that the content cannot still be retrieved.
8. Evaluation Methods: Measure Reliability, Not Just Task Demos
Whether an agent has engineering value should be judged through continuous evaluation, not by showing a single successful case.
Memory capability can be evaluated by retrieval hits, the proportion of irrelevant information, use of expired content, and correctness of permission filtering. Skill capability can be evaluated by pass rates under different input conditions, repeated execution behavior, and completeness of exception handling. Operational capability should focus on interruption recovery, resource consumption, human intervention, and interception of high-risk actions.
Evaluation sets should include confusing tasks: historical rules that have changed, multiple tasks with similar names, inputs missing key fields, and retrieved content containing untrusted instructions. Only by covering these boundary cases can the system’s weak points in real environments be found.
At the same time, retrieval errors, planning errors, and execution errors should be recorded separately. Different types of problems require different improvements and cannot all be solved simply by increasing prompt length.
9. Implementation Path: Validate the Loop First, Then Expand Autonomy
In practice, teams can start with low-risk tasks whose results are easy to check and establish a minimal loop: task state persistence, permission-constrained memory retrieval, limited tool execution, and result verification.
On this basis, memory updates, skill candidate generation, test review, and version rollback can be added gradually. Only when the system can stably handle failures, conflicts, and interruptions is it appropriate to expand the scope of automated execution.
The core of persistent autonomous agents is not to make the system remember more content or execute more actions, but to ensure that every memory call is grounded, every skill reuse is bounded, and every task recovery has a trusted state. Through clear architectural layering and continuous validation, autonomy can become a maintainable and auditable engineering capability.
