openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Measure hosted memory's per-turn cost and stability: ingest paths, pack budget, prompt cache, PII, soak

Open CodeGhost21 opened this issue 1 month ago • 5 comments

Summary

Measure what hosted memory costs each turn, and prove it stays stable: every ingest path, re-ingest without duplicates, the per-turn pack's budget and prompt-cache behaviour, the effect of PII redaction on recall, and a soak run. Record the numbers on this issue.

Problem / Context

Split out of #6718 (Phase 3). Memory v2 (#6949, #6993) changed the shape of several of these criteria:

  • context.md is gone. Each turn now recalls a token-budgeted memory pack ([memory.recall]). MemoryPackMiddleware adds it to every model request of the turn with push_ephemeral_instruction, as a request-only tail, and it is never persisted. On models that hoist system turns (DeepSeek, native Anthropic) it rides the tail user or tool message instead (#6962). The design keeps the cached prefix intact, but nobody has checked that from real request bodies. This is the cost risk #6718 raised, the same class as #6655, and it bears on #7007's 92% cache-hit target.
  • Only beliefs lag. Writes are WaitFor::Visible. #7014 covers what the UI says while beliefs are still being built.
  • Every write is scrubbed by memory::guard::ScrubbingEngine. Redaction changes what gets stored, so its cost to recall needs measuring, not assuming. #6718 saw pii_redactions=8 on a single insert.

Scope

  • In: measurements and the fixes they turn up, on a desktop build signed in to a hosted-memory account.
  • Out: live conformance and the recall-quality bar (sibling issue), bulk-ingest 408 (tinyhumansai/tinysweeper#147), isolation (#7002).

Acceptance criteria

  • [ ] Ingest paths: each path writes to hosted memory and is recalled afterwards: brain documents (memory_brain_ingest, including PDF and image conversion), each synced source kind (folder, file, link, GitHub, RSS, Composio), conversation turns, learnings, and the v1 import (#7005 / #7011).
  • [ ] Re-ingest: re-syncing a source, re-running backfill and resuming an import never silently duplicate or drop records, checked by counting items before and after.
  • [ ] Pack budget: against a large store, the pack stays within [memory.recall]'s token budget. The measured size is recorded.
  • [ ] Prompt-cache stability: captured request bodies across consecutive turns of one thread show the prefix up to the last committed message unchanged, with the pack only at the tail. Verified on a default model and on DeepSeek.
  • [ ] Cost per turn: pre-turn recall latency (p50 / p95), tokens the pack adds, and cache hit rate with memory on vs off, all recorded.
  • [ ] PII redaction: recall quality on a fixture with PII-bearing notes, measured with scrubbing as shipped. The loss, if any, is recorded.
  • [ ] Soak: a long conversation over a realistic store size shows no unbounded growth in pack size, recall latency or cost per turn.
  • [ ] Diff coverage ≥ 80%: any fix this turns up meets the changed-lines coverage gate.

Related

  • Part of #6718
  • #6655 · #6962 · #7007 · #7005 · #7011 · #7013 · #7014 · tinyhumansai/tinysweeper#147
  • Spec: docs/specs/memory-v2.md

CodeGhost21 avatar Oct 06 '26 06:10 CodeGhost21

Live ingest paths and re-ingest on production, 2026-10-06

The real openhuman-core from main, headless in a throwaway HOME, bound to hosted memory (tinyhumans, status ok) with a memory-scoped test key. Every write was forgotten afterwards; a follow-up listing confirmed 0 stray documents. Core logs contained 0 key occurrences.

Path Result Re-ingest / re-sync
Learning (memory_learn) ✅ stored ✅ the same text again returns the same id
Brain text (memory_brain_ingest text) ✅ filed under markdown ✅ the second call returns replayed: true, same id
Brain file: markdown ✅ listed in 15 s, text extracted n/a
Brain file: PDF ❌ refused: "the native converter does not handle pdf" → fixed in #7034 (office converter: PDF/DOCX/PPTX/XLSX) n/a
Brain file: image (PNG) ❌ refused: no converter for images. Open; CortexDB has server-side image extraction (CORTEX_IMAGE_*) as a possible route n/a
Folder source ⚠️ both files read, second write lost to HTTP 502 Bad Gateway from memory/events ~65 s in (see tinyhumansai/cortexdb-saas#14) ✅ no duplicates
File source ✅ 1 document ✅ no duplicates
Link source ✅ 1 document (64 s) ✅ no duplicates
RSS source ✅ a 3-item text feed: all read, 2 visible within 150 s, the third still syncing (hosted latency). An image-only feed (xkcd) correctly stores nothing: "has no text to store" n/a

Pinned by tests in #7034 (in-memory reference engine; no behaviour change needed):

  • Prompt-cache stability: turn two's request reuses all of turn one's messages as the cached prefix, and turn one's pack never reaches turn two. On hoisting models (DeepSeek, native Anthropic), only the previous tail message drops out of the cache.
  • Pack budget: with 1,500 learnings, a turn pack stays within budget_tokens and repeats nothing.

Bug found and fixed upstream: a turn resumed after compaction pasted start_session's pack beside pre_turn's. That is two budgets, with every learning injected twice (19 repeated lines in a test). The fix is tinyhumansai/tinymemory#206 (PreTurn::resumed, one pack); the OpenHuman side follows once it is pinned.

Still open here: cost per turn, PII-redaction recall, soak, conversation-turn and v1-import ingest live. Most need recall latency fixed first (cortexdb-saas#14; likely tinyhumansai/tinymemory#204).

CodeGhost21 avatar Oct 06 '26 16:10 CodeGhost21

Triage: valid — Current review confirms this is a concrete, in-scope engineering issue or request: “Measure hosted memory's per-turn cost and stability: ingest paths, pack budget, prompt cache, PII, soak”. No complete resolution is evident in current main.

senamakel avatar Oct 09 '26 17:10 senamakel

Triage: needs opinion — “Measure hosted memory's per-turn cost and stability: ingest paths, pack budget, prompt cache, PII, soak” needs a maintainer decision on product scope/priority or fresh reproduction evidence before its status can be settled. Please advise whether to pursue, narrow, or close it.

senamakel avatar Oct 09 '26 17:10 senamakel

Triage correction: valid — Current review confirms “Measure hosted memory's per-turn cost and stability: ingest paths, pack budget, prompt cache, PII, soak” is an actionable, in-scope gap; no complete resolution is evident in current main.

senamakel avatar Oct 09 '26 17:10 senamakel

An update: the double-pack-after-compaction fix from tinymemory#206 is now in the TinyMemory version OpenHuman uses (the host marks resumed turns), so that item is done on our side. Still open from the list here: cost per turn, the effect of PII redaction on recall, the soak run, and turn/v1 import ingest. When those are measured, please record the numbers here.

M3gA-Mind avatar Nov 16 '26 16:11 M3gA-Mind