GitHub
Memory System

Short-term Memory (STM)

Attentional working memory for the current session, simulating human cognitive limits.

Storage: Redis (Volatile with TTL)

Purpose

Short-term Memory acts as the "working RAM" for the agent. It holds the immediate context of the current conversation/session.

Key Features

  • Attention Mechanism: Items have a relevance_score. High-relevance items stay; low-relevance items decay and are evicted.
  • Capacity Limit: Simulates the human "7±2" cognitive limit to prevent context window overflow with irrelevant noise.

Functional Deep Dive

Attention Decay

Items in the buffer lose relevance_score over time unless they are accessed or "refreshed" by new interactions.

Context Injection

The most relevant STM items are prepended to the LLM's system prompt. This ensures the agent maintains immediate conversation continuity without re-reading the entire history.

Eviction Strategy

When the buffer reaches capacity, the item with the lowest score (calculated as Relevance * Recency) is dropped. Valuable items may be promoted to Episodic memory before eviction.

Attention Mechanism

API Reference

Short-term Memory provides endpoints for managing session buffers.

MethodEndpointDescription
POST/api/memory/v1/short-termAdd to buffer
GET/api/memory/v1/short-term/session_id/keyGet item from buffer
GET/api/memory/v1/short-term/session_id/keysList all keys in buffer
PUT/api/memory/v1/short-term/session_idUpdate buffer item
DELETE/api/memory/v1/short-term/session_idClear session buffer

SDK Reference

The Functor SDK provides a Python interface for short-term memory operations.

Managing Session Buffer

from functor_sdk import FunctorClient
client = FunctorClient(api_key="your-api-key")
# Add to buffer
client.memory.short_term.add(
session_id="session_123",
key="user_context",
value={"preferences": ["dark_mode", "compact_view"]},
ttl_seconds=3600
)
# Get from buffer
item = client.memory.short_term.get(
session_id="session_123",
key="user_context"
)
# List all keys
keys = client.memory.short_term.list_keys(session_id="session_123")
# Update buffer
client.memory.short_term.update(
session_id="session_123",
key="user_context",
value={"updated": "data"},
ttl_seconds=7200
)
# Clear session
client.memory.short_term.clear(session_id="session_123")