Repository navigation
Closed
Labels
Description
Context
Currently Uteke stores memories as flat text strings. The metadata enrichment feature (v0.0.13) added entity, category, and meta fields, but the actual memory content remains unstructured text. SurrealDB's nested document model inspired supporting structured memory payloads.
Problem
- Flat text limits what agents can query and filter
- No way to store structured facts (e.g.,
{"name": "Alice", "role": "CTO", "timezone": "UTC+7"}) as a single memory - Recall results require post-processing to extract structured data
- FTS5 works on text only β structured fields can't be indexed efficiently
Proposed Implementation
Phase 1: Content type detection
- Auto-detect JSON content in
remember()input - Store as
content_type = 'json'vs'text'in the memories table - JSON content stored as-is in SQLite JSON column (not serialized string)
Phase 2: Structured recall
- New CLI flag:
uteke recall --format jsonβ returns raw JSON memories - Field-level filtering:
uteke recall --where "meta.role = CTO" - API endpoint:
GET /recall?format=json&where=meta.role:eq:CTO
Phase 3: Hybrid queries
- Semantic search still works on JSON (auto-flatten to text for embedding)
- Combine semantic + structured filtering in one query
- Example:
recall("team structure")finds JSON memories about org structure semantically
Schema Changes
ALTER TABLE memories ADD COLUMN content_type TEXT DEFAULT 'text';
-- content column stays TEXT but can hold JSON when content_type='json'
-- SQLite JSON1 functions available for queries: json_extract(), json_each()Acceptance Criteria
-
remember()auto-detects JSON input and setscontent_type - JSON memories stored as valid JSON (not escaped string)
-
recall --format jsonreturns structured results -
--whereclause supports JSON path expressions - Semantic search works on JSON content (text extraction for embedding)
- Existing flat text memories unaffected (backward compatible)
- Documentation updated
Effort
~2-3 days (Phase 1 + 2). Phase 3 can be deferred.
References
- SurrealDB nested document model: https://surrealdb.com/docs/surrealql
- Metadata enrichment (v0.0.13): issue feat: metadata enrichment β entity, category, and structured metadata via CLI flagsΒ #251 (closed)
Activity
feat(#293): structured memory β JSON content support (schema v6) (#331)
release: v0.2.0 β version bump, CHANGELOG, docs update (#344)
docs: fix v0.2.0 consistency issues across README and VitePress docs (#β¦
feat(#293): structured memory β JSON content support (schema v6) (#331)
release: v0.2.0 β version bump, CHANGELOG, docs update (#344)
docs: fix v0.2.0 consistency issues across README and VitePress docs (#β¦