This PR integrates agentmemory as a persistent memory backend for Levi agents. Currently, agents operate statelessly — each run starts fresh with no recall of previous decisions, context, or project history. This forces
repetitive re-explanation and limits effectiveness on long-running tasks. The goal is to give agents searchable, scoped memory that persists across sessions while maintaining company/project boundaries and token budgets.
Changes Made
Server
- server/src/memory/AgentMemoryClient.ts — HTTP client adapting Levi's MemoryService to agentmemory's REST API (/remember, /search, /forget)
- server/src/memory/MemoryService.ts — core interface with namespace isolation (company → project → agent)
- server/src/memory/MemoryNamespace.ts — hierarchical namespace rules enforcing company-scoped access
- server/src/memory/MemoryTypes.ts — shared types for store/query/delete operations
- server/src/memory/MemoryCapture.ts — extracts memories from agent runs (goals, decisions, errors)
- server/src/memory/MemoryInjector.ts — injects relevant retrieved memories into agent prompts
- server/src/memory/MemoryMigration.ts — CLI migration command for switching memory backends
- server/src/memory/MemoryTokenCost.ts — token-budget aware retrieval to prevent context overflow
- server/src/memory-server/proxy.ts — Express proxy translating Levi's /observations API to agentmemory's /agentmemory/* endpoints
- server/src/routes/memory.ts — API routes: POST /api/memory/store, POST /api/memory/query, DELETE /api/memory/:id, GET /api/memory/health
- server/src/app.ts — mounts memory routes and proxy
- server/src/index.ts — initializes memory service on startup
Adapters
- All local adapters (Claude, Codex, Cursor, Grok, OpenCode) inject memory_context into agent prompts when memory is enabled
- packages/adapter-utils/src/server-utils.ts — shared memory context formatting
Config
- packages/shared/src/config-schema.ts — new memory block: enabled, backend (native | agentmemory), baseUrl, autoStart, secret
- AGENTS.md — updated conventions for memory-aware agents
Bug Fix
- Fixed infinite loop in agent_wakeup_requests trigger config parsing (b976af60)
Testing Performed
- pnpm test server/src/memory/ — unit tests for memory service components
- pnpm test server/src/routes/memory.integration.test.ts — integration tests for memory API
- pnpm test server/src/tests/memory-integration.test.ts — end-to-end memory flow tests
- Verified memory proxy starts and connects to agentmemory on ports 3111/3112
- Tested namespace isolation — cross-company queries are rejected
- Tested token budget enforcement — retrieval respects configured limits
Related Issue
Fixes #184
Notes
- No database schema changes required
- Memory is opt-in via memory.enabled config
- No breaking changes — agents run statelessly when memory is disabled
- Proxy auto-starts when memory.autoStart is true; manual start supported otherwise
- Existing heartbeat and issue workflows remain unaffected
Summary