Reusable Agent Skills: From Conversation History to Reliable Execution
Agents often appear to remember prior work yet still ask users to restate the same rules. This article explains why conversation history and long-term memory are not enough for reuse, and how to turn proven task execution into executable skills. Using table data ingestion as an example, it covers input contracts, deterministic cleaning rules, write strategies, success criteria, skill capture and validation, skill matching, permission separation, and production safeguards such as idempotency, transactions, least privilege, observability, and audit. It also offers criteria for evaluating whether an existing agent needs an upgrade.
I. The Real Problem Is Not Memory but Reuse
Consider a common scenario. You ask an agent to process a spreadsheet: remove duplicate records, standardize date formats, and import the data into a business database. On the first run, you explain the field meanings, cleaning rules, and target table structure. After several rounds of confirmation, the task is completed successfully.
A few days later, you provide another dataset with a similar structure and expect the agent to follow the previous process. The agent replies only that it has handled a similar task before, then asks you to explain the rules again.
This does not necessarily reveal a memory failure. It reveals that the experience was never converted into an operational process that can be invoked.
Conversation history usually contains task descriptions, temporary judgments, failed attempts, and final conclusions. Without further organization, an agent may be able to retrieve the history but still not know which steps have been validated, which conditions still apply, and which operations must be confirmed again.
Therefore, when discussing whether to replace an agent solution, it is not enough to ask how many chat records it can store. Three questions matter more:
- Can it extract a stable process from successful tasks?
- Can it identify applicable conditions and find the right process when a new task appears?
- Can it comply with permission, validation, and approval requirements during reuse?
These three questions are the key to moving from a conversational assistant to a reusable execution system.
II. Distinguish Conversation History, Long-Term Memory, and Executable Skills
These three types of information are often mixed together, but they serve different purposes.
1. Conversation History: Preserve What Happened
Conversation history records what the user requested, what the agent attempted, and how the two sides reached a conclusion. It is suitable for tracing context, but it is not a naturally reliable operating manual.
For example, a historical conversation may contain both “delete records with empty values” and “keep records with empty values and move them to an exception list.” If retrieval matches only the first part, the next execution may apply a rule that has already been rejected.
Conversation history therefore needs a clear chronological order and conclusion markers. No single utterance should be treated as a valid instruction by default.
2. Long-Term Memory: Preserve Stable Preferences and Persistently Valid Facts
Long-term memory is better suited to relatively stable information, such as:
- The user prefers to review an execution plan before approving data writes.
- A certain type of report uses a fixed date display format.
- The production environment does not allow existing business records to be overwritten directly.
- Project conventions require anomalous data to be output separately with an explanation.
Here it is also important to distinguish “preferences” from “constraints.” Output format preferences can be adjusted for the current request, while safety constraints should not be easily overridden by an ordinary task description.
Long-term memory also needs scope. Field rules for one project should not automatically become defaults for other projects, and one user’s preferences should not be exposed to other users.
3. Executable Skills: Preserve How to Complete a Class of Tasks
In this article, “skill” means a task process that has been organized and has applicable conditions and execution constraints, not a specific product feature.
A complete skill should at least specify:
- What problem it solves;
- What inputs it requires;
- Under what preconditions it can execute;
- In what order to process the task;
- How to determine whether the result is correct;
- How to stop, recover, or hand off to a human after failure;
- Which operations require additional authorization.
Simply put, conversation history answers “what happened before,” long-term memory answers “what should usually be followed in the future,” and a skill answers “what should be done when the conditions are met.”
III. Define a Truly Reusable Skill Using Table Data Ingestion as an Example
Saving “clean and import into the database” as a single sentence is still not enough to guide reliable execution. Data ingestion involves source files, business semantics, target structure, and write strategy. If any of these is unclear, errors can occur.
1. Define the Input Contract
An input contract does not require every file to be identical. It specifies which variations are allowed and which variations must be rejected.
For example:
- Whether the file contains a header row;
- Which fields are required;
- Which date formats are allowed;
- Whether negative numbers are allowed;
- Whether empty strings and missing values have the same meaning;
- The allowed file size or record count for a single run;
- How the target database and target table are provided by authorized configuration.
For comma-separated text files, attention should also be paid to character encoding, delimiters, quote escaping, and line breaks within fields. It is not sufficient to process every file by splitting on lines and then splitting on commas.
2. Write Cleaning Rules as Deterministic Decisions
“Clean dirty data” is not an executable rule.
A clearer expression would be:
- When a required field is empty, place the record in an exception list.
- When a date cannot be parsed using allowed formats, do not guess automatically.
- Identify duplicate records using the agreed business key.
- When a numeric value exceeds the business range, mark it as anomalous rather than silently truncating it.
- Report unknown fields first; do not discard data that may have business meaning without authorization.
In particular, distinguish duplicates within the file from records already present in the database. The former can be detected within the current input, while the latter requires judgment based on target data and business uniqueness constraints. The two cannot be conflated.
3. Specify the Write Strategy
Inserting new records, updating existing records, and overwriting an entire table are operations with very different risk profiles.
A skill must state which strategy is used and which fields are used to locate existing records. If no unique business key exists, the process cannot claim to have reliable repeat-execution capability.
When the target table does not exist, it should not be assumed that it will be created automatically. Checking whether the table exists is a reasonable prerequisite validation. Creating a table involves schema design, indexes, permissions, and lifecycle management, and usually requires separate approval.
4. Define Success Criteria
“The execution produced no errors” does not mean the task succeeded.
At minimum, verify:
- How many records were read;
- How many passed validation;
- How many were classified as anomalous;
- How many were excluded as input duplicates;
- How many records were actually inserted or updated in the database;
- Whether conflicts, skips, or transaction rollbacks occurred.
Provided the categories are mutually exclusive and cover all input records, the total input count should correspond to the processing category statistics. Database-side write counts need to be explained separately in light of insert, update, and conflict policies.
IV. What Steps Should Turn a Successful Execution into a Skill?
Reliable skill capture is not about saving an entire chat. It is about extracting experience, removing accidental factors, and then validating the result.
Step 1: Collect Execution Evidence
Keep the final adopted process, input structure, validation results, exceptions, and human confirmation records. Failed attempts are also valuable, but they should be marked as failure paths and must not be mixed into normal execution steps.
“The user expressed satisfaction” can serve as feedback, but it cannot replace data verification and execution logs.
Step 2: Separate Rules from Parameters
Target table names, file paths, and the current processing date are usually parameters. “The target table structure must be validated before writing” is a rule.
If the specific path from one task is hard-coded into a skill, the next run may process the wrong file. Conversely, if every detail is abstracted into free text, the skill loses its constraints.
A reasonable approach is to fix stable rules and explicitly parameterize variable items.
Step 3: Generate a Skill Draft and Confirm It
An agent can propose saving a process, but whether it has this capability depends on whether the system implements mechanisms for skill generation, storage, and invocation. It cannot be assumed that the system supports this merely because the model can summarize.
A skill draft should show users the scope of application, key rules, write strategy, and risk boundaries. When production data or shared processes are involved, a maintainer with the appropriate permissions should also approve it.
Step 4: Validate with Different Samples
Prepare at least test cases such as normal input, missing fields, abnormal dates, duplicate records, and mismatched target structures.
If a process succeeds only on the file used the first time, it may be a one-off script rather than a skill with a stable scope of application.
Step 5: Release a Version
Changes to a skill should produce a new version and record the reason for the change. When deduplication rules, field mappings, or write strategies change, the skill must be revalidated. A version already relied on by the business should not be overwritten silently.
V. Matching and Validation Are Central to Automatic Skill Invocation
When a user says “import this data,” the system cannot execute an existing skill based only on keyword similarity.
A more robust invocation chain can be represented as follows:
User request
→ Identify task intent
→ Retrieve candidate skills
→ Validate applicable conditions
→ Fill in missing parameters
→ Generate an execution plan
→ Complete necessary approvals
→ Execute and verify results
The retrieval stage can use task descriptions, tags, and input characteristics to find candidates, but final usability should depend on more explicit condition checks.
For example, two data ingestion tasks may look similar: one file is used to add new customers, and another is used to revise order amounts. Even if the file formats are similar, the business objects and write semantics are different, so the same set of rules cannot be reused.
For high-risk tasks, retrieval similarity can only be used for ranking, not as a basis for authorization. When the target environment, write strategy, or business key is missing, the system should ask first rather than guess.
VI. Skill Improvement Must Be Separated from Execution Permissions
It is valuable for an agent to discover that a process lacks a validation step. But “can propose an improvement” does not mean “can expand its own permissions.”
Improvements can be divided into two categories.
One category is low-risk validation enhancement, such as adding field completeness checks, supplementing exception statistics, or improving the readability of error messages. Even so, it should be tested to see whether it affects existing results.
The other category changes business behavior, such as automatically creating data tables, overwriting existing records, adjusting unique keys, or expanding the scope of data access. Such changes should go through approval and version release processes rather than being added directly to the current execution.
A closed loop of “propose—validate—approve and release” is recommended. This allows experience to accumulate while preventing unverified assumptions from becoming long-term rules.
VII. Engineering Safeguards Required for Production
1. Idempotency and Duplicate Execution Protection
After a network interruption, a user may resubmit the same task. The system needs to determine whether the task has already been completed based on task identifiers, business unique keys, or processing records, so as to avoid duplicate writes.
Recording only the file name is not reliable, because files with the same name may have different contents. Recording only a content digest also does not solve all business duplication problems. The specific strategy should be designed in light of business objects and write semantics.
2. Transactions and Recovery
For writes that need to remain consistent as a whole, transactions can be used when the database supports them and resources allow. Large batch tasks may require commits in batches. In that case, batch status should be recorded, and the continuation or compensation strategy after partial success should be clearly defined.
It is not acceptable to commit in batches while claiming that any failure can automatically roll back all results.
3. Least Privilege and Secret Protection
Execution accounts should have only the permissions required for the task. Credentials should not be written into skill bodies, conversation records, or ordinary logs. They should be obtained through a controlled credential management mechanism.
Text in file contents and database fields should also be treated as data to be processed. It should not be elevated to an execution instruction merely because it contains phrases such as “ignore checks” or “export all records.”
4. Observability and Audit
Each execution should be associated with a task identifier, skill version, target environment, approval record, and processing result. Logs should also avoid exposing sensitive fields.
This makes it possible to answer questions when problems occur: which version was used, which steps were executed, who approved the write, and which records were affected by the error.
VIII. How to Decide Whether an Existing Agent Is Worth Upgrading
Whether to replace a solution should not depend on whether a demo proactively says “I will save the process for you.” It should be validated through a set of repeated tasks.
Focus on observing:
- How much of the same information must be supplied again on the second execution;
- Whether inapplicable old processes are correctly identified;
- Whether the agent can stop and explain why when input is anomalous;
- Whether any data writes occur without approval;
- Whether skill changes have versions and validation records;
- Whether human review time is actually reduced.
During evaluation, use the same tasks, the same permissions, and the same data conditions as much as possible. Avoid mixing model differences, configuration differences, and process design differences together.
If the existing system merely lacks a skill library, retrieval mechanism, or approval chain, filling those gaps may be more reasonable than a full migration. Only when the execution framework cannot support necessary state management, permission control, or traceability should architectural changes be seriously evaluated.
IX. Conclusion: Experience Reuse Depends on System Design, Not “I Remembered”
The practical value of an agent is not only understanding the current instruction. It also includes turning validated experience into a capability that can be safely used next time.
However, this capability cannot be obtained simply by saving chat records. It requires an explicit skill structure, reliable retrieval and matching, deterministic input validation, controlled execution permissions, and continuous version governance.
For developers, the most valuable thing to build is a complete chain: successful tasks produce evidence, evidence is distilled into processes, processes are validated and become skills, skills are invoked when conditions are met, and execution results feed controlled improvement.
When this chain is in place, users no longer need to repeatedly translate past experience into new instructions. Agents can then move from completing one-off tasks toward stable, explainable, reusable automated execution.
