AI Agents

An AI agent is a system that uses a model to choose actions in an environment. Agents often combine reasoning, memory, tools, retrieval, and feedback so they can complete multi-step tasks.

What is memory in an AI agent?

Memory in an AI agent is information the agent stores so it can use that information later instead of treating every interaction or task as completely new. Memory gives an agent continuity across steps, sessions, or tasks when previously learned information is still useful. What can agent memory store? Depending on the system, memory may contain: user preferences important facts learned earlier summaries of previous interactions past task outcomes recurring instructions useful observations successful strategies information about earlier events The system should store only information that has a clear future use. Example Suppose a user repeatedly asks an agent to prepare reports. The agent may remember: Preference: Keep reports concise and include an executive summary. On a future request, that memory can be retrieved and included in the agent's context. The user does not need to repeat the same preference every time. Memory is not the same as active context Context is the information currently available to the model for the present decision. Memory is information stored for possible future use. A memory does not affect the current step until the system retrieves it and places the relevant information into context. For example: Stored memory: User prefers CSV exports. Current context: The user asks for a downloadable data export, so that preference is retrieved and included. Memory is not the same as workflow state Agent state tracks the current condition and progress of an active workflow. For example: current goal completed subtasks retry count current execution status Memory usually captures information that may remain useful beyond the immediate execution. For example: user preferences knowledge learned from previous tasks summaries of earlier experiences State answers: Where is this workflow right now? Memory answers: What useful information from the past might help now? Memory can have different lifetimes Some memories are useful only briefly. Others may remain useful across many sessions. Agent systems may therefore use different forms of memory, such as: short term memory long term memory working memory episodic memory semantic memory procedural memory These memory types are covered in the following questions. Memory should be retrieved selectively An agent should not load every stored memory into every prompt. Instead, the system should retrieve memories that are relevant to the current task. For example, a memory about a user's preferred report format may be useful when creating a report but irrelevant when checking an API status. Selective retrieval keeps context focused. Memory should be updateable Stored information can become outdated. For example: Old memory: User prefers weekly summaries. Later: New preference: User prefers daily summaries. A reliable memory system should update, replace, or invalidate outdated information rather than continuing to use stale memory. Memory can improve continuity Without memory, an agent may repeatedly: ask the same questions forget user preferences repeat earlier mistakes ignore useful past outcomes Memory helps the agent build on relevant previous information. Memory should not be treated as automatically correct Stored memories can be: outdated incomplete incorrect conflicting An agent system may need to validate important memories against current information before relying on them. This becomes especially important when the memory affects high impact decisions. In short Memory in an AI agent is stored information from earlier interactions, tasks, or observations that can be retrieved and used later when relevant. It gives the agent continuity over time, but useful memory systems must also decide what to store, what to retrieve, what to update, and what to forget.

Why do AI agents need memory?

AI agents need memory because useful information from the past can improve future decisions, reduce repeated work, and create continuity across interactions or tasks . Without memory, an agent may behave as if every request is completely new. Memory helps avoid repetition Suppose an agent already learned: the user's preferred report format which tools were previously tried which approach failed which result was accepted If none of this is remembered, the agent may ask the same questions or repeat the same work later. Memory allows useful past information to be reused. Memory improves continuity Some tasks span multiple interactions. For example: Earlier: The user selected Vendor B. Later: The user asks, “What are the risks of the option we chose?” If the agent can retrieve the earlier decision, it can understand that “the option we chose” refers to Vendor B. Without memory, that continuity may be lost. Memory can preserve user preferences Agents may repeatedly serve the same user. Useful preferences might include: preferred output format language level of detail recurring constraints preferred workflow For example: Memory: User prefers concise technical explanations. When relevant, the system can retrieve that preference and use it in the current context. Memory can help agents learn from previous outcomes An agent may remember what happened during earlier tasks. For example: Past task: Tool A repeatedly timed out for a particular data source. Useful memory: Tool B successfully handled the same source. A later execution may use that knowledge to choose a better approach. This does not mean the model itself has been retrained. The system is retrieving stored experience and making it available to the agent. Memory can preserve useful knowledge across sessions Some information remains useful after the current conversation or workflow ends. For example: project conventions customer preferences earlier decisions known constraints recurring task patterns Long term memory can make that information available later when it becomes relevant again. Memory can reduce unnecessary tool calls If a stable fact has already been retrieved and stored appropriately, the agent may not need to fetch it again every time. For example: Stored information: The project's default deployment region is us east 1. If that information is still valid and relevant, retrieving it from memory may be cheaper than repeatedly querying another system. Important or time sensitive facts may still need fresh verification. Memory helps with personalization An agent can adapt its behavior when it remembers relevant preferences or history. For example: Memory: The user normally wants CSV exports. When the user later asks to export a dataset, that preference can influence the proposed format. Personalization should still be based on relevant and appropriately stored information rather than collecting everything. Memory can support better planning Past information may change how the agent approaches a new task. For example: Memory: A previous deployment failed because a required environment variable was missing. During a future deployment, the agent may include environment validation earlier in the plan. Useful memory can therefore help reduce repeated mistakes. Agents do not need to remember everything Memory is useful only when the stored information has future value. Storing too much can create: irrelevant retrieval outdated information higher storage cost privacy concerns conflicting memories A good memory system is selective. Memory should be retrieved only when relevant Even useful stored information should not automatically be placed into every prompt. For example: A memory about preferred report formatting is useful when generating a report but probably irrelevant when diagnosing a database timeout. The system should retrieve memories based on the current task. Memory must be kept current Stored information can become stale. For example: Old memory: The user's preferred deployment region is Europe. New information: The project has moved to Asia. If the old memory remains authoritative, it can cause incorrect decisions. Memory systems therefore need mechanisms for updating, replacing, validating, or forgetting information. Memory complements context and state Memory is one source of information available to an agent. State represents the current workflow. Context is what the model can actively see right now. Memory stores information from the past that may be useful later. Relevant memories can be retrieved and added to context when needed. In short AI agents need memory because it allows them to reuse useful past information, maintain continuity, remember preferences, avoid repeated work, and improve future decisions based on previous outcomes . The goal is not to remember everything, but to preserve and retrieve the information that is genuinely useful for later tasks.

What is short-term memory in an AI agent?

Short term memory in an AI agent is information kept for a limited period so the agent can maintain continuity during a current conversation, task, or nearby sequence of interactions. It helps the agent remember recent information without treating every new step as unrelated. What short term memory can contain Short term memory may include: recent user messages recent tool results temporary preferences recently discussed entities recent decisions intermediate task results summaries of the current conversation The information is usually useful for the current interaction but may not need to remain available indefinitely. Example Suppose a user says: Compare Vendor A and Vendor B. A few messages later, the user asks: Which one had the lower setup cost? Short term memory can help the agent remember that the discussion is about Vendor A and Vendor B and reuse the comparison from earlier in the same interaction. Without that memory, the user might need to repeat the context. Short term memory is usually temporary The defining feature is its limited lifetime. It may last for: one conversation one workflow run one session a short series of related tasks After that period, the information may be discarded unless it is important enough to be stored in long term memory. Short term memory helps maintain conversational continuity A conversation often contains references such as: “that option” “the second one” “use the same format” “continue from where we stopped” To understand these references, the agent needs access to recent interaction history. Short term memory helps preserve that local continuity. Short term memory can reduce repeated questions Suppose the agent already asked: Preferred output format: CSV If that information is still relevant in the current session, the agent should not ask for it again a few minutes later. Short term memory helps avoid unnecessary repetition. Short term memory vs. long term memory Short term memory stores information that is useful for the current or recent interaction. Long term memory stores information intended to remain useful across future sessions or tasks. For example: Short term: The user selected Option B during the current comparison. Long term: The user generally prefers concise reports. A short term fact may later be promoted into long term memory if it has lasting value. Short term memory vs. working memory The two concepts are related but not identical. Short term memory refers to recently retained information that remains available for a limited period. Working memory is the smaller set of information the agent is actively using and manipulating for the current reasoning step. For example: Short term memory might contain: the last several user messages recent search results earlier decisions in the current task Working memory for the current step might contain only: the current question two relevant results one constraint Working memory is therefore usually more focused on immediate processing. Short term memory vs. context Short term memory may be one source of context. The system can retrieve relevant recent information and include it in the model's active context. Not every item in short term memory needs to be included in every model call. For example, an old message from the same session may remain stored but be omitted if it is irrelevant to the current step. Short term memory can be implemented in different ways Depending on the system, it may be represented by: recent conversation history session storage workflow state a temporary database record a rolling summary a bounded message buffer The implementation can vary, but the purpose is the same: preserve useful recent information for a limited period. It should remain selective Keeping every recent detail can still create too much context. A good short term memory system may: keep only the latest messages summarize older parts of the session retain important decisions remove redundant information drop details that are no longer relevant This helps the agent maintain continuity without overwhelming the context window. Short term memory can expire Some systems remove short term memories after: the session ends the workflow completes a time limit is reached the information is no longer relevant This prevents temporary interaction data from being kept longer than necessary. Example Suppose an agent is helping plan a trip. During the current session, short term memory may contain: destination: Mumbai travel date: Friday preferred departure: morning budget: ₹8,000 two shortlisted flights When the user later asks: Which of the two is better? The agent can use the recent memory to understand the question. Once the trip planning session ends, some of these details may no longer need to remain in short term memory. In short Short term memory in an AI agent is temporary memory used to retain recent information across a current conversation, task, or session. It helps maintain continuity, reduce repeated questions, and preserve recent decisions, while information with lasting value may instead be stored in long term memory.

What is long-term memory in an AI agent?

Long term memory in an AI agent is information stored so it can remain useful across future sessions, tasks, or interactions rather than only during the current run. It allows the agent to retain important information over time and retrieve it later when it becomes relevant. What can long term memory store? Depending on the agent, long term memory may contain: stable user preferences important project facts previous decisions recurring instructions useful outcomes from earlier tasks summaries of past interactions known constraints reusable knowledge learned during prior work The goal is to preserve information that has lasting value. Example Suppose a user repeatedly asks an agent to generate technical reports. The agent may store: Preference: Use concise explanations and include a short executive summary. Weeks later, when the user asks for another report, that memory can be retrieved and applied without requiring the preference to be repeated. Long term memory persists beyond the current session Short term memory may disappear when the current conversation or workflow ends. Long term memory is designed to remain available later. For example: Short term memory: The user selected Option B in the current comparison. Long term memory: The user generally prefers lower cost options when quality is similar. The first fact may be useful only for the current task, while the second may remain useful in future tasks. Long term memory is not always active context A long term memory can exist in storage without being included in every model call. The system usually retrieves it only when it is relevant. For example: Stored memory: Preferred export format: CSV If the current task is about exporting data, that memory may be retrieved and added to context. If the current task is about debugging an API timeout, the same memory is probably unnecessary. Long term memory should be selective Not everything from every interaction should become long term memory. Useful candidates are usually information that is: likely to matter again reasonably stable specific enough to be useful appropriate to retain Temporary details, one time values, and irrelevant history may not deserve long term storage. Long term memory can improve continuity Without long term memory, an agent may repeatedly forget: project conventions user preferences previous decisions known constraints lessons from earlier tasks Long term memory helps later interactions build on useful prior information. Long term memory can support personalization An agent may adapt future behavior based on remembered preferences. For example: Memory: The user prefers examples in Python. Later, when explaining a programming concept, the agent may choose Python examples when appropriate. This can make repeated interactions more consistent. Long term memory can store useful experience An agent may also retain useful outcomes from previous work. For example: Past experience: A particular data source frequently fails during peak hours. Useful memory: Prefer the alternate source when both provide the same information. A later task can retrieve this memory and use it to make a better decision. This is retrieval of stored experience, not retraining the model. Long term memory must be updateable Information can change. For example: Old memory: Project uses PostgreSQL 14. Later: New information: Project upgraded to PostgreSQL 16. The memory system should update or invalidate the outdated information. Otherwise, long term memory can become a source of incorrect decisions. Long term memory should have clear scope Stored information should be associated with the correct scope. Examples include: a particular user a project a team a tenant an organization Proper scoping helps prevent one user's or project's information from being used in another context. Long term memory may use different storage methods Depending on the architecture, it may be stored in: databases document stores key value stores vector databases memory services structured user or project profiles The storage mechanism matters less than the ability to retrieve the correct information when needed. Long term memory should not be trusted blindly Stored memories can become: stale incorrect incomplete contradictory Important decisions may require validating the memory against newer or authoritative information. For example, a remembered shipping address should not automatically override a newly supplied address. Long term memory vs. short term memory Short term memory supports the current or recent interaction. Long term memory preserves information intended to remain useful across future interactions. A piece of information may begin in short term memory and later be promoted to long term memory if it has lasting value. In short Long term memory in an AI agent is durable stored information that can be retrieved across future sessions or tasks when it becomes relevant. It helps agents maintain continuity, remember stable preferences and decisions, reuse useful past knowledge, and personalize future interactions without carrying every past detail into every prompt.

What is working memory in an AI agent?

Working memory in an AI agent is the small set of information the agent is actively using and manipulating for the current reasoning step. It contains what matters right now rather than everything the agent has seen or stored. What working memory can contain Working memory may include: the current goal the current subtask important constraints recent observations selected tool results intermediate calculations unresolved questions the next decision to make Its contents can change quickly as the workflow progresses. Example Suppose an agent is comparing three cloud providers. While evaluating cost, its working memory may contain: expected usage monthly budget pricing for Provider A pricing for Provider B pricing for Provider C Later, while evaluating compliance, its working memory may instead contain: required certifications data residency rules security requirements each provider's compliance information The broader task is the same, but the information actively being used has changed. Working memory is highly focused An agent should normally keep only the information needed for the immediate reasoning step. If it is deciding whether to retry an API call, useful working memory might include: the latest error retry count retry policy timeout value previous attempt result Unrelated conversation history does not need to be actively considered. Working memory vs. short term memory Short term memory retains recent information for a limited period, such as recent messages or earlier results in the same session. Working memory is the smaller subset being actively used for the current decision. For example, short term memory may contain several recent messages and tool outputs, while working memory may use only one message, one tool result, and one constraint. Working memory vs. long term memory Long term memory stores information intended to remain useful across future sessions or tasks. Working memory is temporary and supports immediate reasoning. A long term memory can be retrieved and placed into working memory when it becomes relevant. For example: Long term memory: The user prefers Python examples. Working memory: The current question, a relevant API response, and the Python code being analyzed. Working memory vs. context Context is all the information available to the model during a call. Working memory is the part of that context that is actively relevant to the current reasoning operation. The context may contain background instructions and conversation history, while the effective working memory may involve only a few important details. Intermediate results often belong in working memory Temporary reasoning artifacts may stay in working memory while the agent solves a problem. Examples include: a running total eliminated options a current hypothesis partial calculations the latest observation These may be useful for the current step but not worth storing permanently. Working memory should remain small and relevant Overloading working memory with unnecessary information can make it harder for the agent to identify what matters. A good agent system therefore updates working memory as the task changes: 1. bring in relevant information 2. use it for the current decision 3. keep useful intermediate results 4. remove information that is no longer needed 5. load the information required for the next step In short Working memory in an AI agent is the small, temporary set of information the agent is actively using to reason about the current step. It is more focused than short term memory, changes as the task progresses, and can draw information from context, state, recent observations, or long term memory.

What is episodic memory in AI agents?

Episodic memory in AI agents is memory of specific past experiences or events that the agent can retrieve later when a similar situation occurs. Instead of storing only general facts, episodic memory preserves what happened in a particular interaction or task. What can episodic memory contain? An episodic memory may include: what task was being performed what actions the agent took which tools were used what observations were received what decision was made whether the outcome succeeded or failed important context surrounding the event The memory represents an experience rather than only an isolated fact. Example Suppose an agent previously handled a deployment failure. That episode might contain: deployment failed error indicated a missing environment variable agent inspected configuration missing variable was added deployment succeeded afterward Later, if another deployment fails with a similar error, the agent may retrieve this earlier episode and use it as useful guidance. Episodic memory is about particular events Episodic memory answers questions such as: What happened last time? What action did we take? What result did that action produce? Have we seen a similar situation before? This makes it useful for learning from prior experience. Episodic memory can improve future decisions If the agent can retrieve relevant past episodes, it may: avoid repeating failed approaches reuse successful strategies recognize recurring problems make better plans choose tools more effectively The agent is not necessarily retraining its model. It is using stored experience as additional information. Episodic memory vs. semantic memory Episodic memory stores specific experiences. Semantic memory stores general facts or knowledge. For example: Episodic: Last week's deployment failed because the database password had expired. Semantic: Database credentials can expire and cause authentication failures. The first describes a particular event. The second describes general knowledge. Episodic memory vs. procedural memory Episodic memory records what happened in a specific case. Procedural memory represents how to perform a task or follow a process. For example: Episodic: During a previous outage, restarting Service B restored traffic. Procedural: To restart Service B, first drain traffic, restart the service, then run health checks. One captures experience; the other captures a reusable procedure. Episodic memory may include outcome information An episode is more useful when it includes what happened after an action. For example: Action: Retried API request immediately Outcome: Failed again or: Action: Waited 30 seconds and retried Outcome: Succeeded The outcome helps the agent judge whether a previous strategy is worth reusing. Retrieval should be based on relevance An agent should not retrieve every past episode. Instead, it may search for experiences similar to the current situation using signals such as: task type error type user tool domain goal outcome Only the most relevant episodes should be added to the current context. Episodic memory should not be trusted blindly A previous solution may not work in the current situation. The environment may have changed, or the earlier outcome may have depended on conditions that no longer apply. The agent should treat episodic memory as evidence from past experience, not as guaranteed truth. In short Episodic memory in AI agents is memory of specific past experiences, including what happened, what actions were taken, and what outcomes followed. It helps agents reuse useful experience, recognize recurring situations, and avoid repeating past mistakes when similar tasks occur again.

What is semantic memory in AI agents?

Semantic memory in AI agents is stored general knowledge, facts, concepts, and relationships that can be retrieved later without depending on one specific past event. It represents what the agent knows rather than what happened in a particular experience. What can semantic memory contain? Semantic memory may include: facts definitions concepts relationships between entities project rules domain knowledge stable preferences reusable knowledge learned from previous interactions The important point is that the information is stored as general knowledge rather than as a detailed record of one event. Example Suppose an agent previously learned: Fact: Project Alpha uses PostgreSQL. That fact can be stored as semantic memory. Later, when the agent needs to generate a database migration for Project Alpha, it can retrieve that knowledge without needing to remember the exact conversation in which the fact was originally mentioned. Semantic memory is about knowledge Semantic memory helps answer questions such as: What is true about this user, project, or domain? What does this term mean? What relationship exists between these entities? What rule should normally be followed? What fact has previously been established? The emphasis is on reusable knowledge. Semantic memory vs. episodic memory Episodic memory stores a specific past experience. Semantic memory stores general knowledge derived from or independent of specific experiences. For example: Episodic: Last Tuesday, deployment failed because the database password had expired. Semantic: Expired database credentials can cause authentication failures. The first describes an event. The second expresses reusable knowledge. Semantic memory may come from repeated experiences General knowledge can sometimes be extracted from several episodes. For example, an agent might observe repeatedly that: a particular API is slow during peak hours retries after a short delay usually succeed Instead of remembering only each individual episode, the system may form a semantic memory such as: Knowledge: This API frequently experiences temporary peak hour latency. This is a more reusable representation. Semantic memory can reduce repeated retrieval If a stable fact has already been learned and stored, the agent may not need to rediscover it every time. For example: Stored semantic memory: The team uses Python for backend services. When a future task requires a code example, that fact can be retrieved and used when relevant. Time sensitive or high impact facts may still need verification. Semantic memory should be retrieved selectively The agent should not load all stored knowledge into every prompt. Instead, it should retrieve only knowledge relevant to the current task. For example: A memory about deployment conventions may be useful during a release task but irrelevant while answering a billing question. Selective retrieval keeps context focused. Semantic memory can be structured Semantic memory may be stored as: key value facts documents database records knowledge graph relationships vector indexed text structured profiles For example: Project: Alpha Database: PostgreSQL Region: ap south 1 Primary language: Python Structured storage can make important facts easier to retrieve and update. Semantic memory must be updateable Facts can change. For example: Old knowledge: Project uses PostgreSQL 14. Later: New knowledge: Project upgraded to PostgreSQL 16. The old semantic memory should be updated or invalidated so the agent does not continue using stale information. Conflicting semantic memories need resolution An agent may sometimes store contradictory facts. For example: Memory A: Preferred language is Python. Memory B: Preferred language is TypeScript. The system may need to consider: which information is newer which source is more authoritative whether the memories apply to different projects whether clarification is needed Semantic memory should not be treated as automatically correct. Semantic memory vs. procedural memory Semantic memory stores knowledge about facts and concepts. Procedural memory stores knowledge about how to perform a task. For example: Semantic: The production database is PostgreSQL. Procedural: To deploy a database migration, create the migration, review it, run tests, and apply it through the release workflow. One represents knowledge. The other represents a reusable process. Semantic memory can support personalization Some user information may also be represented as semantic memory. For example: preferred language: English preferred output format: CSV preferred explanation style: concise When appropriate, these facts can be retrieved and used in future interactions. In short Semantic memory in AI agents is stored general knowledge about facts, concepts, relationships, and stable information that can be reused across future tasks. Unlike episodic memory, it is not tied to one specific past event. Its value comes from making useful knowledge easy to retrieve, update, and apply when relevant.

What is procedural memory in AI agents?

Procedural memory in AI agents is stored knowledge about how to perform a task, follow a process, or carry out a sequence of actions. It represents reusable know how rather than a specific past event or a standalone fact. What can procedural memory contain? Procedural memory may include: step by step procedures task workflows tool use patterns operating rules troubleshooting routines preferred execution strategies reusable action sequences Its purpose is to help the agent know how to do something. Example Suppose an agent frequently deploys an application. A procedural memory might contain: 1. Run tests. 2. Build the application. 3. validate configuration. 4. deploy to staging. 5. run health checks. 6. request approval. 7. deploy to production. 8. verify production health. This memory can guide future deployments without requiring the process to be reconstructed from scratch each time. Procedural memory is about how Procedural memory helps answer questions such as: How should this task be performed? What steps should happen first? Which tool should be called next? What checks are required before continuing? What sequence has worked reliably for this kind of task? The emphasis is on execution knowledge. Procedural memory vs. semantic memory Semantic memory stores facts and general knowledge. Procedural memory stores knowledge about how to perform an action or process. For example: Semantic: The project uses PostgreSQL. Procedural: Before applying a database migration, create the migration, review it, run tests, back up critical data if required, and apply it through the release workflow. One describes what is known. The other describes what to do. Procedural memory vs. episodic memory Episodic memory stores what happened during a particular past experience. Procedural memory stores a reusable method. For example: Episodic: During the previous deployment, the application failed because an environment variable was missing. Procedural: Before deployment, validate all required environment variables. A useful procedure may sometimes be created from lessons learned across multiple episodes. Procedural memory can improve consistency Agents may perform the same type of task many times. Without a reusable procedure, the agent may generate a slightly different process each time. Procedural memory can provide a stable execution pattern for recurring tasks such as: onboarding a customer investigating an incident processing a refund reviewing a document deploying software This can make repeated execution more predictable. Procedural memory can guide tool use A procedure may include which tools should be used and in what order. For example: 1. Search customer record. 2. Check payment status. 3. Verify refund eligibility. 4. Request approval if required. 5. Call the refund tool. 6. Confirm the result. The agent still needs to respond to current observations, but the procedure provides a useful execution framework. Procedures can contain conditions Procedural memory does not need to be a simple fixed sequence. It may contain conditional rules such as: if authentication fails, refresh credentials if retry count reaches the limit, escalate if the amount exceeds the approval threshold, request human approval if validation fails, stop before the external action This allows procedures to guide decisions as well as actions. Procedural memory should be adaptable A stored procedure should not force the agent to follow outdated steps when the environment changes. For example: Old procedure: Deploy using Tool A. Later, the organization may migrate to Tool B. The procedural memory should be updated so future execution follows the current process. Procedures should have clear scope Different projects or users may require different procedures. For example: Project A: Requires manual approval before deployment. Project B: Allows automatic deployment after tests pass. The memory system should retrieve the procedure appropriate to the current task and scope. Procedural memory may be represented in different ways Depending on the architecture, it may be stored as: workflow definitions checklists structured rules reusable prompts task templates tool use instructions executable workflow graphs The representation can vary, but the purpose remains the same: preserve reusable knowledge of how a task should be performed. Procedural memory can evolve from experience Past episodes may reveal better ways to perform a task. For example: Several deployment incidents may show that configuration validation should happen before the build step. That lesson can be converted into an updated procedure. In this way: episodic memory captures what happened while: procedural memory captures how future execution should be done Procedures still require current context A procedure alone is not enough. The agent still needs current information such as: task inputs user requirements tool results permissions constraints errors Procedural memory provides the method, while current context determines how that method should be applied now. In short Procedural memory in AI agents is reusable knowledge about how to perform tasks, follow workflows, and execute sequences of actions. Unlike episodic memory, it is not tied to one specific event, and unlike semantic memory, it describes how to act rather than simply what is known.

What is the difference between agent state and agent memory?

Agent state and agent memory both store information, but they serve different purposes. Agent state describes the current execution of a workflow. Agent memory stores information that may be useful again later. Agent state tracks the current run Agent state answers questions such as: What is the current goal? Which steps are completed? What step is running now? Which tasks are still pending? What was the latest tool result? How many retries have occurred? Is the workflow waiting for approval? State is mainly about where the current execution stands. Agent memory preserves useful information over time Agent memory answers different questions: What useful information was learned earlier? What preferences should be remembered? What happened in similar past tasks? What facts or procedures may help later? Memory can remain useful beyond the current workflow. Example of agent state Suppose an agent is processing a refund. Its state might contain: customer verified order found refund eligibility confirmed approval pending retry count: 0 next step: wait for approval These values describe the current workflow run. Once that workflow finishes, much of this state may no longer be needed. Example of agent memory The same agent may remember: the user prefers email confirmations a recurring customer account issue a previously successful troubleshooting approach a general refund procedure These memories may be useful in future interactions or workflows. State is usually execution specific State is commonly tied to a particular run or task. For example: Run A payment check completed shipment check pending Run B payment check pending shipment check pending Each run needs its own state. Mixing state between runs could cause incorrect execution. Memory can outlive a workflow Memory may remain after a workflow finishes. For example: A workflow may end today, but a useful preference or lesson learned from that workflow could still be retrieved next month. That is one of the main differences between state and memory. State changes as the workflow moves Agent state often changes after almost every execution step. For example: Before tool call Order status: Unknown After tool call Order status: Shipped Next task: Check delivery estimate State evolves continuously as the workflow progresses. Memory changes less frequently Memory is usually updated only when information is worth retaining. For example: A temporary API response may belong in state. A stable user preference may belong in memory. A useful lesson from several previous tasks may also become memory. The system should not automatically turn every state value into a long term memory. State helps the agent continue The main purpose of state is execution continuity. It helps the system know: what already happened what is happening now what should happen next This is especially important for multi step and long running agents. Memory helps the agent reuse the past The main purpose of memory is reuse. It can help the agent: remember preferences reuse prior knowledge recognize recurring situations avoid repeated mistakes apply successful past strategies Memory is valuable when previous information can improve future decisions. State can contain temporary information State may include information that is important now but has little future value. Examples include: current retry count temporary tool output current node pending approval active branch intermediate calculation These values often disappear when the workflow completes. Memory should contain information with future value Good memory systems are selective. Useful memories may include: stable preferences important project facts reusable procedures notable past experiences learned constraints Temporary execution details usually should not become long term memory unless there is a clear reason. State and memory can interact Memory can be retrieved and placed into the current state or context. For example: Memory: User prefers CSV exports. A new workflow may load that memory and include: Output preference: CSV in its current state. Similarly, something discovered during a workflow may later be saved as memory if it has lasting value. State is closely related to checkpointing Because state represents the current workflow, checkpoints often save snapshots of that state. If execution stops, the system can restore the checkpoint and continue. Memory is not primarily for recovering workflow position. Its purpose is preserving reusable information. State and memory should both be scoped correctly State is usually scoped to a specific workflow run. Memory may be scoped to: a user a project a tenant a team an organization Proper scoping prevents information from one execution or user from leaking into another. A simple way to remember the difference Think of it this way: Agent state = What is happening in this task right now? Agent memory = What from the past may be useful again? In short Agent state represents the current condition and progress of an active workflow, while agent memory stores information that may be retrieved and reused later. State helps the agent continue the current execution correctly. Memory helps the agent benefit from relevant information across time.

How does an agent decide what information to remember?

An AI agent should decide what to remember by asking a simple question: Will this information likely help in a future interaction, task, or decision? Good memory systems are selective. They do not store every message, tool result, or temporary detail. 1. Remember information with future value Useful memories are often information that may matter again. Examples include: stable user preferences important project facts recurring constraints decisions that affect future work reusable procedures lessons from successful or failed tasks For example: Useful to remember: The user prefers CSV exports. Usually not useful to remember: A temporary API latency value from one completed request. 2. Prefer stable information Information is a better memory candidate when it is unlikely to change frequently. For example: preferred programming language project architecture team conventions recurring output preferences Highly temporary information may belong in workflow state or short term memory instead. 3. Consider how important the information is Some information may be worth remembering because forgetting it would cause repeated work or poor decisions. For example: Important: Production deployments require human approval. Remembering this constraint can affect many future workflows. A minor intermediate calculation from one task usually has much less future value. 4. Remember repeated patterns If the same fact or preference appears repeatedly, that is a strong signal that it may deserve memory. For example: The user repeatedly asks for: concise answers Python examples CSV exports Instead of rediscovering these preferences every time, the system may store them as reusable memory. 5. Learn from outcomes Agents can also remember useful lessons from previous tasks. For example: Past experience: A certain API often times out when called with very large batches. Useful memory: Use smaller batches for that API. This kind of memory can help future execution without requiring the agent to repeat the same failed approach. 6. Avoid remembering temporary execution details Many values are useful only while a workflow is running. Examples include: current retry count current workflow node temporary tool output intermediate calculations transient error messages These usually belong in agent state or short term memory rather than long term memory. 7. Avoid storing duplicate information If the same fact is already stored, the system should usually update or reinforce the existing memory instead of creating many copies. For example: Instead of storing: User prefers Python. User likes Python examples. Use Python when giving code. the system may maintain one clear memory: Preferred code language: Python This makes retrieval cleaner. 8. Consider whether the information is sensitive Not every useful piece of information should automatically be stored. Before creating memory, the system should consider: whether retention is necessary whether the information is sensitive whether the user or organization allows it to be stored how long it should be retained who is allowed to retrieve it Memory usefulness does not override privacy or security requirements. 9. Store the right level of abstraction The system should remember the useful meaning, not necessarily every raw detail. For example, instead of preserving a long conversation about report formatting, it may store: Preference: Reports should be concise and begin with an executive summary. This produces a smaller and more reusable memory. 10. Give memories a clear scope A memory should be attached to the correct scope. For example: user level preference project level fact tenant level policy task specific memory organization level procedure A preference for one project should not automatically affect another unrelated project. 11. Consider confidence and source Some memories are more reliable than others. For example: High confidence: The user explicitly said, “Always export this project as CSV.” Lower confidence: The agent inferred a preference because CSV was chosen once. A memory system may store confidence, source, or timestamp information so later retrieval can judge how much to trust it. 12. Check whether newer information replaces older memory Memories should not accumulate conflicting versions forever. For example: Old memory: Project database is PostgreSQL 14. New information: Project upgraded to PostgreSQL 16. The system should update or invalidate the old memory. A practical memory decision Before storing something, an agent system can evaluate: Is it likely to be useful again? Is it stable enough to retain? Is it important enough to matter? Is it already stored? Is it safe and appropriate to retain? What user, project, or tenant does it belong to? Should it expire? Should an existing memory be updated instead? Only information that passes these checks should become durable memory. In short An agent should remember information that has clear future value, is sufficiently important or reusable, and is appropriate to retain. Good memory systems are selective: they preserve useful preferences, facts, lessons, and procedures while leaving temporary execution details in state or short term memory.