Working Memory

beginner
Memory TypesLast updated: 2025-01-15
Also known as: short-term memory, context window, conversation context

What is Working Memory?


Working memory is the cognitive system that temporarily holds and manipulates information needed for the current task. In AI agents, working memory typically corresponds to the context window - the information available during a single interaction or reasoning step.


The Context Window


For LLM-based agents, working memory is constrained by:


  • Token limits (4K, 8K, 32K, 128K+ tokens)
  • Attention mechanisms
  • Computational costs
  • Latency requirements

  • Working Memory Contents


    An agent's working memory typically includes:


  • Current conversation messages
  • System prompts and instructions
  • Retrieved context from long-term memory
  • Tool outputs and intermediate results
  • Scratchpad for reasoning

  • Managing Limited Capacity


    Strategies for working with limited context windows:


  • **Summarization**: Compress older context
  • **Sliding Window**: Drop oldest messages
  • **Selective Retrieval**: Only include relevant information
  • **Hierarchical Context**: Summaries + details on demand

  • Working vs Long-term Memory


    | Aspect | Working Memory | Long-term Memory |

    |--------|----------------|------------------|

    | Duration | Current session | Persistent |

    | Capacity | Limited (tokens) | Unlimited |

    | Access | Immediate | Requires retrieval |

    | Update | Automatic | Explicit storage |


    Implementation Patterns


    Common working memory patterns:


  • **Buffer Memory**: Recent N messages
  • **Summary Memory**: Compressed conversation history
  • **Entity Memory**: Tracked entities from conversation
  • **Knowledge Graph Memory**: Structured current context

  • Optimizing Working Memory


    Best practices for working memory management:


  • Prioritize recent and relevant information
  • Use structured formats to reduce tokens
  • Implement smart truncation strategies
  • Balance detail vs coverage
  • Monitor token usage

  • Related Terms