Session Memory
Session Memory stores structured snapshots of an agent's working state — files modified, commands run, decisions made, and open tasks. Agents can restore full context after a session ends or a compaction event fires.
Store a Session Snapshot
curl -X POST https://api.ainative.studio/api/v1/public/memory/v2/session \
-H "x-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"session_id": "session-abc123",
"project_path": "/Users/dev/myapp",
"files_modified": ["app/main.py", "app/api/router.py"],
"key_decisions": [
"Switched to async endpoints for better throughput",
"Added Redis caching layer"
],
"open_tasks": ["Write tests for /api/v1/models/available"],
"event": "pre_compact"
}'
event values:
pre_compact— fired before context window compactionsession_end— agent session ending cleanlycheckpoint— manual mid-session save
Get the Latest Session
curl "https://api.ainative.studio/api/v1/public/memory/v2/session/latest" \
-H "x-api-key: $API_KEY"
Get a Specific Session
curl "https://api.ainative.studio/api/v1/public/memory/v2/session/{session_id}" \
-H "x-api-key: $API_KEY"
Python SDK
import requests
API_KEY = "your-api-key"
BASE = "https://api.ainative.studio/api/v1/public/memory/v2/session"
headers = {"x-api-key": API_KEY, "Content-Type": "application/json"}
# Save session state before compaction
requests.post(BASE, headers=headers, json={
"session_id": "my-session-001",
"project_path": "/Users/dev/project",
"files_modified": ["src/main.py"],
"key_decisions": ["Refactored auth middleware to use JWT"],
"open_tasks": ["Add rate limiting to /api/v1/messages"],
"event": "pre_compact"
})
# Restore on next session start
latest = requests.get(f"{BASE}/latest", headers=headers).json()
print(f"Restoring session: {latest['session_id']}")
print(f"Open tasks: {latest['session_data']['open_tasks']}")
Request Fields
| Field | Type | Required | Description |
|---|---|---|---|
session_id | string | Yes | Unique session identifier |
project_path | string | No | Working directory path |
files_modified | string[] | No | Files changed this session |
key_decisions | string[] | No | Important decisions made |
open_tasks | string[] | No | Unfinished tasks at save time |
event | string | No | pre_compact, session_end, checkpoint |
Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /memory/v2/session | Store session snapshot |
| GET | /memory/v2/session/latest | Get most recent session for user |
| GET | /memory/v2/session/{session_id} | Get session by ID |