This document introduces how AgentScope handles context and memory in agent workflows.Documentation Index
Fetch the complete documentation index at: https://docs.agentscope.io/llms.txt
Use this file to discover all available pages before exploring further.
For implementation details and APIs, see Context and Memory.
Why It Matters
Without memory, an agent treats every turn as a new conversation. With memory, it can:- keep conversation continuity,
- remember user preferences and task state,
- retrieve useful history when needed.
Msg, memory backends, and prompt construction.
Three Layers in AgentScope
Context (inference-time input)
Context is the final input sent to the model for one inference call. In AgentScope terms, it is typically assembled from:- system instructions,
- current user
Msg, - selected short-term history,
- retrieved long-term memory,
- tool results.
Short-Term Memory (session state)
Short-term memory tracks the current session and usually storesMsg objects.
In AgentScope, this is provided by MemoryBase implementations (for example:
InMemoryMemory, RedisMemory, AsyncSQLAlchemyMemory).
Common usage:
- recent conversation turns,
- temporary task progress,
- marked messages (such as
hint,summary,tool_result).
Long-Term Memory (cross-session knowledge)
Long-term memory stores information that should survive session boundaries. In AgentScope, this is abstracted byLongTermMemoryBase implementations.
Typical content includes:
- stable user preferences,
- important facts from previous interactions,
- retrievable semantic memories.
How They Work Together
A typical agent turn looks like this:- Load recent session memory (short-term).
- Retrieve relevant long-term memory (if needed).
- Build model context with current user input and retrieved signals.
- Run model inference.
- Write new messages back to short-term memory, and optionally persist key facts to long-term memory.
ReActAgent workflows).
Context Management vs Memory Management
In practice, the boundary is soft:- Memory management focuses on storing, retrieving, marking, and updating information.
- Context management focuses on selecting and assembling the right subset of that information into the model input.
Summary
| Layer | What it is | AgentScope mapping |
|---|---|---|
| Context | Input for one inference | Prompt assembled from Msg + retrieved memory + tool outputs |
| Short-Term Memory | Session-level working state | MemoryBase backends storing and filtering Msg |
| Long-Term Memory | Persistent cross-session knowledge | LongTermMemoryBase retrieval and storage |