SECURITY AI

Transparent and traceable

Reproducibility

TECNOLOGY

Artificial intelligence

AI-driven innovation to digitalize business processes and optimize productivity.

ERP Integrations

Comply platform’s AI Agents access company systems in accordance with the permissions granted.

RESOURCES

ESEMPI APPLICATIVI

Transport documents

Enhance data and optimize the management of transport documents.

Supplier Invoices

Automate supplier invoice management, from acquisition to recording.

Customer order management

Automate the acquisition, validation, and recording of customer orders in the ERP system.

Supplier order confirmations

Manage supplier order confirmations with AI agents.

FE INTERNAZIONALE

Italy

Poland

Slovakia

Spain

RISORSE

Compliance Calendar

The interactive calendar, always up to date for B2B compliance.

INNOVATIVE TECHNOLOGY

AI agentica

Find out how orchestrators coordinate AI agents and complex processes.

AI agents

Explore the technology behind our agents and how they work together toward a common goal.

Get in touch

Try and buy

We guarantee that we will have a solution tailored to your business up and running within three days.

COMPLANY

Certifications

Contact us

Newsletter

Let’s stay in touch

Sign up now for our free newsletter to stay up to date.

AI agent memory: How to extend memory and ensure reliability in business workflows

Simone Tiso

Simone Tiso

Chief Technology Officer

icona normalizzata

10/11/2026

icona conforme

In the first two articles of this series, "Anatomy of an AI Agent" and "Architecture of Agentic AI", we introduced AI agents as autonomous digital workers that can orchestrate complex workflows, such as managing shipping documents or validating invoices. However, in order to manage workflows spanning multiple steps and requiring interaction with various tools (so-called long-horizon tasks), agents must overcome a fundamental challenge: memory.

For companies in Italy implementing Agentic AI in their critical processes, effective context management distinguishes a proof-of-concept demonstration from a secure, auditable, enterprise-grade solution.

This article is the third in the series and examines the inherent limitations of Large Language Models (LLMs). It describes the three strategies that AI agents use to overcome these obstacles and ensure that critical information essential for compliance and business automation is never overlooked.

1. The context window: the biological limit of LLMs and context rot

Large Language Models (LLMs) have a short-term memory, known as a context window. This is a memory buffer with a maximum size, measured in tokens. It contains the full history of a task or conversation, including initial instructions, intermediate messages, partial results of actions, and tool definitions.

The context window acts as a whiteboard on which the LLM writes and reads in order to make its next decision. However, the critical issue is that this short-term memory fills up over time, leading to the phenomenon known as context rot.

Academic research shows that a model's reliability decreases steadily as the length of the input increases. As the window approaches and exceeds roughly 50% of its capacity, the model may:

  • Lose relevant details: if crucial information (such as a company policy or the primary objective of a task) is located at the beginning of the conversation, it may be overlooked in favour of more recent data.
  • Ignore initial information (recency bias): the model tends to lose sight of details provided at the beginning of the conversation, paying more attention to the most recent information.
  • Lose critical details (lost in the middle): when the window is less than 50% full, the model may ignore information in the middle of the input.
  • Experience quality degradation: the complexity and length of the input negatively impact the model's ability to perform complex reasoning tasks, especially when thematically related distractions are present.
  • Experience performance degradation: as documented in industry studies and technical analyses, the quality of responses and reasoning decreases significantly when the input is too long or disorganised.

The only way to address this issue with a standard chatbot is usually to start a new conversation. However, for a company automating a 50-step supplier onboarding process, losing context halfway through is not an option.

Similarly, an LLM that "forgets" the rules at the start of the process is unacceptable for a compliance-focused B2B company. The AI agent solves these problems by adopting an architecture that is no longer dependent on the physical limitations of the LLM.

2. Enhanced short-term memory: agentic loops and window compaction

AI agents can overcome the limitations of the context window using two complementary mechanisms: the inference loop (structured short-term memory) and external memory (long-term memory).

The agentic AI architecture transforms the LLM's fluid memory into episodic memory, making it more organized and targeted.

The role of the agent loop (short-term memory)

The agent operates through a continuous cycle (inference loop) of planning, acting, verifying and adjusting. This cycle serves as an internal context manager.

  • Reflects: the agent is instructed to "think" about the task and summarize the results obtained after each step.
  • Structured state: rather than feeding the entire raw conversation back to the LLM, the system only provides the model with the current state of the task and the goals to be achieved.
  • Maintains structured summaries: it generates and updates concise, specific summaries of the progress of the current task.
  • Filters out irrelevant information: it identifies and discards information that is irrelevant to the next step.
  • Monitors progress: it tracks partial goals achieved to prevent the agent from focusing solely on the most recent steps.

Window compaction

Advanced agents use window compaction to keep the context lean and efficient. This technique maximizes the efficiency of the context window, especially in very long and real-time workflows, and optimizes costs related to token consumption.

This technique extends context management by reducing the number of tokens needed to maintain the context while ensuring the most vital information is available to the LLM.

Compaction can be achieved in the following ways:

  • Summarization: creating concise summaries of intermediate steps or past interactions and replacing full chats or logs with these summaries to free up space.
  • Filtering by relevance: a pre-processing module determines which information is necessary for the next phase and removes irrelevant information that could distract the LLM. This is a key principle for enterprise reliability. The module automatically removes irrelevant text.
  • Embedding/Vector Storage: it converts older context into vector embeddings for storage and only retrieves them when they are semantically relevant. This concept overlaps with the conversational memory concept of RAG.

Using tools to compact the window is critical for two business reasons: maintaining reliability for complex tasks and reducing operational costs. The cost of LLMs is often calculated based on the number of tokens processed (input + output).

3. Long-term memory: RAG for governance and traceability

The biggest challenge for AI agents is integrating confidential corporate data, internal policies, and document archives. Retrieval-augmented generation (RAG) serves as an external, verifiable long-term memory, which is essential for this integration. RAG transforms LLMs from generation engines into reasoning engines grounded in corporate data.

How RAG works

The RAG system connects the agent to one or more corporate knowledge bases, such as internal databases and document repositories. When the agent needs to answer a question or make a decision, it relies on the knowledge bases rather than solely on its "internal memory" (the context window).

  • Retrieve: when an agent needs to make a decision (such as whether to approve a purchase order) they send a query (vector search) to an internal vector knowledge base containing documents, policies, and master data. The knowledge base then retrieves the most relevant information snippets.
  • Enhance the prompt: the most relevant text snippets retrieved from the database are inserted directly into the LLM's context window.
  • Generate/Validate: the LLM then generates a response or decision based solely on this updated information, ensuring that the output is grounded in verifiable corporate data.

Integrating RAG allows Comply agents to use large reasoning models (LRMs) to solve complex problems while maintaining focus on context thanks to long-term memory. This methodology forms the basis of AI governance.

As Richard Hightower points out in his article Agent Memory: The Key to Salient Episodic Memory, episodic and long-term memory are key to giving agents an operational "consciousness."

4. Implications for business decision makers

Sophisticated memory management is the feature that distinguishes an enterprise-ready AI agent from a simple chatbot:

  • Reliability in long-term workflows: complex processes such as the automation of shipping documents in SAP or supplier onboarding do not fail due to loss of context. The agent maintains the objective and crucial details across dozens of steps.
  • Accuracy and reduced hallucinations: the use of RAG forces the agent to base its decisions on verified company data, improving compliance accuracy and reducing operational errors.
  • Operational cost efficiency: the use of window compaction reduces the token volume (and thus the cost) of each inference, making complex workflows economically scalable.
  • Governance and auditability: tracking state and context (rather than a single, opaque conversation log) makes every agent decision more transparent and auditable, a fundamental requirement under the EU AI Act.

For leaders aiming for growth in Italy, the real challenge is ensuring that artificial intelligence never forgets the rules of the game. Agentic AI, which remembers not only the "what" but also the "how" and "why" of its actions, extending its memory beyond the inherent limits of LLMs, is the key to implementing automation systems that are secure, scalable, and truly autonomous. Strategically managed memory is the only path to responsible automation.

About the Author

Simone Tiso

Simone Tiso

An expert in driving innovation and digital transformation, with over 15 years of experience in designing and implementing mission-critical infrastructures, primarily through an AI-driven approach. Proven ability to lead and coordinate multidisciplinary and international teams, aligning technology roadmaps with business objectives to maximize customer value and corporate competitiveness.

Newsletter

Subscribe to our monthly newsletter to stay up to date on the latest developments in business process automation.