Skip to content

Rename memory to history + build new memory system#36

Merged
priyanshujain merged 34 commits intomasterfrom
memory-system-redesign
Mar 9, 2026
Merged

Rename memory to history + build new memory system#36
priyanshujain merged 34 commits intomasterfrom
memory-system-redesign

Conversation

@priyanshujain
Copy link
Copy Markdown
Collaborator

Summary

  • Renames source/memory/source/history/ (conversation transcripts are history, not memory)
  • Creates new memory/ top-level package for durable personal facts about the user (identity, preferences, relationships, projects)
  • Adds CLI commands (obk memory list/add/delete/extract), extraction pipeline, reconciliation, and agent skill

What changed

Part 1 — Rename memory → history (mechanical renames, no logic changes):

  • source/memory/source/history/ with updated package, struct, table names (memory_conversationshistory_conversations, etc.)
  • config.MemoryConfigconfig.HistoryConfig, MemoryDataDSN()HistoryDataDSN()
  • internal/cli/memory/internal/cli/history/ (capture command)
  • skills/memory-read/skills/history-read/
  • All tests, docs, and hook command updated

Part 2 — New memory system:

  • memory/types.goMemory struct with Category constants (identity, preference, relationship, project)
  • memory/schema.go — SQLite/PostgreSQL schema for memories table
  • memory/store.go — CRUD: Add, Get, Update, Delete, List, ListByCategory, Search, Count
  • memory/format.goFormatForPrompt() groups memories by category into markdown for LLM system prompts
  • memory/extract.go — Pre-filters trivial messages, calls LLM to extract personal facts as JSON
  • memory/reconcile.go — Keyword search + LLM reconciliation (ADD/UPDATE/DELETE/NOOP) against existing memories
  • config.UserMemoryConfig with UserMemoryDataDSN()~/.obk/user_memory/data.db

Part 3 — CLI + integration:

  • obk memory list [--category <cat>], obk memory add, obk memory delete, obk memory extract [--last <n>]
  • skills/memory-save/SKILL.md — agent skill for "remember this" use case
  • Hook: obk history capture && obk memory extract &
  • Doctor: UserMemory DB health check

Test plan

  • go build ./... passes
  • go test ./source/history/... — schema, store, capture tests pass
  • go test ./memory/... — schema, CRUD, format, extraction parsing, reconciliation tests pass
  • go test ./internal/skills/... — install with updated skill names passes
  • go test ./agent/tools/... — skill search/load with updated names passes
  • CLI integration tests for obk memory list/add/delete/extract (not yet written)
  • End-to-end test with real LLM for extraction pipeline (requires configured provider)

Conversation transcripts are history, not memory. Renames
source/memory/ to source/history/ with updated package names,
struct names, table names, and index names.
Updates config struct, defaults, DSN method, and doctor check
to use History instead of Memory.
Moves internal/cli/memory/ to internal/cli/history/ and updates
root.go to register the history command.
Updates import, source registration, and switch case from
memory to history.
Renames skill directory, updates SKILL.md DB paths and table
references, and updates builtinSkills map in install.go.
Updates all test references from memory-read to history-read,
updates hook command and README.
Defines Memory struct and Category constants for the new
personal memory system (identity, preference, relationship, project).
Adds SQLite and PostgreSQL schema for the memories table with
indexes on category and source.
Adds Add, Get, Update, Delete, List, ListByCategory, Search,
and Count functions for the memories table.
Adds UserMemory config section with SQLite default, DSN method,
and defaults initialization.
Creates CLI commands for managing personal memories:
list (with --category filter), add, and delete.
Formats memories grouped by category into markdown suitable
for inclusion in LLM system prompts.
Adds Extract function with pre-filtering (trivial messages, acks)
and LLM-based fact extraction from conversation messages.
Adds Reconcile function that compares candidate facts against
existing memories using keyword search and LLM-based decision
making (ADD/UPDATE/DELETE/NOOP).
Extracts personal facts from recent conversation history using
LLM-based extraction and reconciliation pipeline.
Updates Stop hook to chain memory extraction after capturing
conversation history. Backgrounds extraction to avoid blocking.
Creates memory-save skill with SKILL.md, registers it as a
built-in skill, and updates install tests.
Includes UserMemory database in the health check alongside
other data stores.
Renames memory/ to history/ and adds user_memory/ directory
to reflect the new architecture.
Replaces concrete *provider.Router with LLM interface in Extract
and Reconcile. Adds RouterLLM adapter. Enables mock-based testing.
Unit tests: Extract with mock LLM (verifies prompt construction,
JSON parsing, filtering), Reconcile with mock (NOOP, UPDATE,
DELETE, ADD decisions).

Integration tests: real LLM extraction and end-to-end
extract→reconcile flow, skipped when no API keys set.
Support GOOGLE_CLOUD_PROJECT env var for Gemini testing via Vertex AI,
matching the pattern used in agent/integration_test.go.
Get() was scanning created_at/updated_at directly into time.Time, but
SQLite returns datetime as strings. Use parseTime() like queryMemories().
Each obk chat session generates a unique session ID and saves all
user/assistant messages to the history DB, making them available
for memory extraction via obk memory extract.
gemini-2.0-flash is no longer available to new API keys. Update all
integration tests to use gemini-2.5-flash and increase MaxTokens
since thinking models use tokens for internal reasoning.
@priyanshujain priyanshujain merged commit dc18e2d into master Mar 9, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant