One of the most common mistakes in agent design is treating “State” and “Memory” as the same thing. In StateBase, they serve two distinct purposes.Documentation Index
Fetch the complete documentation index at: https://docs.statebase.org/llms.txt
Use this file to discover all available pages before exploring further.
1. State (Active Logic)
Think of this as the “RAM” of your agent. State is a structured JSON object representing the current condition of the agent. It is what the agent uses to make its immediate next decision.- Structure: Strongly typed schemas (e.g.,
{"status": "onboarding", "step": 2}). - Behavior: Updated frequently, often every turn.
- Goal: Deterministic logic flow.
- Example: A shopping assistant’s current
cart_itemslist.
2. Memory (Long-term Facts)
Think of this as the “Hard Drive” of your agent. Memory consists of unstructured or semi-structured facts extracted from previous interactions. It is retrieved semantically when relevant.- Structure: Natural language or key-value pairs (
"User is allergic to peanuts"). - Behavior: Static until reinforced or corrected.
- Goal: Personality and long-term personalization.
- Example: The fact that a user lives in Seattle and prefers python.
The Synthesis: Context
When you callsb.sessions.get_context(), StateBase merges these two:
- It retrieves the Current State (Cart items: 3).
- It fetches Relevant Memories (User usually buys gluten-free).