Repository navigation
v0.2.0 "Elephant" — Memory & Session Persistence
codenano v0.2.0 Release Notes
Highlights
This release introduces two major persistence features — Memory System and Session Persistence — enabling agents to learn across conversations and resume interrupted sessions. Test coverage jumped from 225 to 326 tests (75% statement coverage).
Memory System — Cross-Session Learning
Agents can now automatically extract and recall knowledge across sessions, inspired by Claude Code's memory architecture.
How it works
The agent analyzes conversations after each turn, extracts useful information (user preferences, project context, feedback on approach), and saves it as markdown files. On the next session, these memories are automatically loaded into the system prompt.
const agent = createAgent({
model: 'claude-sonnet-4-6',
memory: {
autoLoad: true, // inject saved memories into system prompt
extractStrategy: 'auto', // extract after every completed turn
},
})Memory Types
| Type | What it stores |
|---|---|
user |
User's role, preferences, knowledge |
feedback |
Guidance on approach — what to avoid or repeat |
project |
Project state, goals, decisions (not derivable from code) |
reference |
Pointers to external systems (Linear, Grafana, etc.) |
Key Features
- Auto-extraction — fire-and-forget after each turn, no blocking
- Extraction strategies —
'auto'(every turn),{ interval: N }(every N turns),'disabled' - Forked agent option — use prompt caching for efficient extraction (
useForkedAgent: true) - MEMORY.md index — auto-maintained index file linking all memories
- Standalone API —
saveMemory(),scanMemories(),loadMemory(),loadMemoryIndex() - Default path —
~/.agent-core/memory/<cwd-hash>/(isolated per project) - Custom path — set
memory.memoryDirto any directory
Session Persistence — Save & Resume Conversations
Sessions can now be saved to disk and resumed later using JSONL files, following Claude Code's session storage design.
How it works
When persistence is enabled, every message is automatically appended to a <sessionId>.jsonl file. To resume, pass the session ID to agent.session() — all previous messages are restored.
const agent = createAgent({
model: 'claude-sonnet-4-6',
persistence: { enabled: true },
})
// Start a session — messages auto-save
const session = agent.session()
console.log(session.id) // save this UUID
await session.send('Analyze the codebase')
// Later — resume from where you left off
const resumed = agent.session(session.id)
await resumed.send('What did we find?') // model has full contextKey Features
- Auto-save — messages persisted after each turn (append-only JSONL)
- Resume by ID —
agent.session(sessionId)restores full conversation history - Session listing —
listSessions()returns all saved sessions sorted by date - Session loading —
loadSession(id)returns metadata + messages - Graceful recovery — malformed JSONL lines are skipped, never crash
- Default path —
~/.agent-core/sessions/ - Custom path — set
persistence.storageDirto any directory
JSONL Format
{"type":"metadata","timestamp":"...","metadata":{"sessionId":"...","model":"claude-sonnet-4-6","createdAt":"..."}}
{"type":"message","timestamp":"...","message":{"role":"user","content":"Hello"}}
{"type":"message","timestamp":"...","message":{"role":"assistant","content":[...]}}Storage Paths
Both features have sensible defaults. Directories are auto-created.
| Feature | Default Path | Custom Config |
|---|---|---|
| Memory | ~/.agent-core/memory/<cwd-hash>/ |
memory.memoryDir |
| Session | ~/.agent-core/sessions/ |
persistence.storageDir |
Test Coverage
| Module | v0.1.2 | v0.2.0 |
|---|---|---|
| Overall | 59% (225 tests) | 75% (326 tests) |
| src/memory | 27% | 96% |
| src/tools | 53% (0% funcs) | 95% (100% funcs) |
| session-storage.ts | — | 99% |
Other Improvements
- Query tracking —
chainId+depthfor debugging multi-turn conversations - Enhanced stop hooks —
preventContinuationand retry limit support - Comprehensive documentation — updated README (EN/CN), configuration guide, architecture docs, session guide