
Session-scoped conversation history with automatic expiration.
Short Memory stores conversation records keyed by a session_id. Records are returned
in chronological order and expire after a configurable TTL (default 24 hours). It's designed
for maintaining turn-by-turn context within a single chat session.
Access it via client.memory.short.
from guidedmind import Client
client = Client()
# Add a user message
client.memory.short.add_record(
session_id="session-abc123",
role="user",
content="What pricing plans do you offer?",
)
# Add the assistant's response
client.memory.short.add_record(
session_id="session-abc123",
role="assistant",
content="We offer Free, Pro, and Enterprise plans.",
)records = client.memory.short.get_records(session_id="session-abc123")
print(f"Total records: {records.total}")
for record in records.records:
print(f" [{record.role}] {record.content}")A common pattern is fetching short memory to pass as context to your LLM call:
def get_chat_history(session_id: str) -> list[dict]:
"""Return messages in OpenAI-compatible format."""
records = client.memory.short.get_records(session_id=session_id)
return [
{"role": record.role, "content": record.content}
for record in records.records
]
# Usage
history = get_chat_history("session-abc123")
# Pass `history` as the `messages` array to your LLM API| Method | Returns | Description |
|---|---|---|
add_record(session_id, role, content) | MemoryRecord | Append a message to the session |
get_records(session_id) | RecordList | Fetch all records ordered by time |
aadd_record(...) | Awaitable[MemoryRecord] | Async version of add_record |
aget_records(...) | Awaitable[RecordList] | Async version of get_records |
| Parameter | Type | Default | Description |
|---|---|---|---|
session_idrequired | str | — | Unique identifier for the conversation session. |
rolerequired | str | — | Sender role. Either "user" or "assistant". |
contentrequired | str | — | Message text. |
import asyncio
from guidedmind import Client
async def save_turn(session_id: str, user_msg: str, assistant_msg: str):
async with Client() as client:
await client.memory.short.aadd_record(
session_id=session_id,
role="user",
content=user_msg,
)
await client.memory.short.aadd_record(
session_id=session_id,
role="assistant",
content=assistant_msg,
)Short Memory records expire automatically. For durable, cross-session storage use Long Memory instead.