Skip to content

πŸ“¦ Feature: Structured memory β€” nested JSON content instead of flat textΒ #293

Closed

Description

@ajianaz

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 sets content_type
  • JSON memories stored as valid JSON (not escaped string)
  • recall --format json returns structured results
  • --where clause 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

Activity

  1. added
    enhancement
    scope:core
    on Jun 12, 2026
  2. added this to the milestone on Jun 13, 2026
  3. added
    v0.2.0
    status:in-progress
    on Jun 13, 2026
  4. added a commit that references this issue on Jun 14, 2026
  5. removed
    status:in-progress
    on Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpriority:mediumscope:corev0.2.0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions