Repository navigation
feat(memory)!: keep a souled agent's memory and wiki pages per user - #767
Conversation
…and what it refuses Signed-off-by: jddunn <[email protected]>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough
Merge Risk:
|
Reviewer's GuideSchema and migrationsAdd the conversation-scope registry and per-subject wiki-page tables, and register eligible existing conversation scopes during Brain initialization.
Data structuresDefine the versioned conversation-scope key and the memory and wiki-page data types that depend on it.
APIExpose the conversation-scope utilities, registry operations, page stores, and new memory facade methods and row types to callers.
Implement the facade's conversation-scope validation, registration, filtered reads, page-row persistence, and deletion behavior.
ImplementationImplement registration of conversation scopes from their keys and a wiki-page store whose reads, writes, and chunk operations stay within one subject.
DocumentationDocument the scope-key format, registry and page-row tables, page operations, deletion behavior, and initialization changes.
TestsVerify key encoding and parsing, scope registration and equality-based reads, and per-subject wiki-page persistence across SQLite and Postgres.
Cover operator-page indexing, cleanup, legacy-page exclusion, and the resulting catalogs and prompts for souled agents.
Check wiki attachment and page-store behavior, including indexing failures, deletion, page-origin handling, and prompt loading.
Other changesFiles not grouped.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Signed-off-by: jddunn <[email protected]>
…ope id column Signed-off-by: jddunn <[email protected]>
…nd read scopes by their column Signed-off-by: jddunn <[email protected]>
…scope key Signed-off-by: jddunn <[email protected]>
Signed-off-by: jddunn <[email protected]>
Signed-off-by: jddunn <[email protected]>
…r-wiki Signed-off-by: jddunn <[email protected]>
…ier version compiled left out of every prompt Signed-off-by: jddunn <[email protected]>
…rlier compiled pages out of the index, the prompt and recall Signed-off-by: jddunn <[email protected]>
Signed-off-by: jddunn <[email protected]>
…operator's alone Signed-off-by: jddunn <[email protected]>
…ker, whatever the user id Signed-off-by: jddunn <[email protected]>
…en read_memory_page finds its asker A session whose id or user id is one of the anonymous words was read as no user: it was served and listed the pages an earlier version compiled into the folder, and could not read its own pages. The subject in the tool context is the key the turn's memory is filed under, so it now decides the asker first. Signed-off-by: jddunn <[email protected]>
|
Review fix: Failing input: a session whose id is one of the anonymous words (
|
…ation key A store writes text as UTF-8, where a lone surrogate becomes U+FFFD, so a key built from 'm\uD800' is stored and matched as the key of 'm\uFFFD': the two subjects would read one another's pages and recall. Signed-off-by: jddunn <[email protected]>
…rrogate The store writes text as UTF-8, where a lone surrogate becomes U+FFFD, so the key of 'm\uD800' was stored and matched as the key of 'm\uFFFD': each subject read the other's pages and recall. conversationScopeKey now refuses such an agent or subject id with a TypeError, and parseConversationScopeKey reads a string that holds one as no key, so remember() and UserWikiStore refuse it too. Signed-off-by: jddunn <[email protected]>
|
Review fix: A conversation key is refused for an agent id or a user or session id that holds a lone surrogate. Failing input: User Expected: No key for such an id.
|
…r-wiki Signed-off-by: jddunn <[email protected]>
… one log handle Signed-off-by: jddunn <[email protected]>
…and the shared-memory option Signed-off-by: jddunn <[email protected]>
Signed-off-by: jddunn <[email protected]>
…with a watermark each Signed-off-by: jddunn <[email protected]>
Two compiles of one scope at once (two compileWiki() calls, or close() beside an explicit compile) both read the watermark before the first entered the scope's queue. The second then compiled from the old watermark and sent the same traces to the model again. The watermark is now read once the compile's turn comes, so a compile that waited starts where the earlier one left it; a scope deleted meanwhile is skipped. Signed-off-by: jddunn <[email protected]>
…d changes .meta/index.json recorded only the key version, so a folder indexed for one agent id and opened under another (agentId or name edited, or a second agent on the same folder) skipped every unchanged page: no chunk was filed under the new operator key and no turn recalled the operator's pages. The index now records the operator key it filed under. An index of another key is not used: every operator page is indexed again under the current key and the chunks filed under the other key are deleted. Signed-off-by: jddunn <[email protected]>
…pens, and close the store on a failed open An agent id conversationScopeKey refuses (a NUL or a lone surrogate) threw only after memory/.store/memory.sqlite was opened, and the handle was never closed. The key is now built before the store folder is made. Any later step of the open that throws (reading the store, attaching the wiki, agent() refusing its options) closes the store before the error reaches the caller. Signed-off-by: jddunn <[email protected]>
memory.legacy_traces counts the traces under the agent's plain id and under its encoded form, which differs when the id holds '/', '%' or ':'. The documented removal deleted the plain form alone, so the line kept counting traces a learning layer had re-filed. The docs now delete both, and encodePlainScopeId is exported so a host can name the encoded form. Signed-off-by: jddunn <[email protected]>
A seat's session id is prefixed seat:, and the memory tools are never among a seat's tools: a read_memory_page call from a seat is skipped as not available. The test opens a seat with the id of a user who holds a page and checks the call is skipped and no page text reaches the model. Signed-off-by: jddunn <[email protected]>
…tach Signed-off-by: jddunn <[email protected]>
|
Follow-ups from QA and a cold review of 9a0b0bb0, each with a failing test first. Tests-only commit dccd05fe and its red run, every new test failing for its stated reason: https://github.com/framerslab/agentos/actions/runs/43128152647. Green on head 19307fd3: https://github.com/framerslab/agentos/actions/runs/43129916434 (Test & Lint: 1195 files, 17686 tests passed, the Postgres leg included).
Not changed, with reasons: a seat opened with The test fixture that used a person's name now uses a neutral id. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 19307fd308
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…r process rewrote deletePageRows deletes the chunks it read, then the row by its id alone. When another process rewrites the page in between, the row goes and the new chunks stay with no row that lists them. Signed-off-by: jddunn <[email protected]>
…leted deletePageRows deleted the chunks it read and then the row by id alone, so a rewrite by another process in between left the new chunks live with no row. The row is now deleted only while it holds the text and the chunk list read with it; when it changed, it is read again and its chunks go first, up to the page write's attempt limit. Signed-off-by: jddunn <[email protected]>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 576e01ff73
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…n a page is rewritten meanwhile The export reads the traces, then the pages, as separate statements; a page rewritten in between comes out listing chunks the file does not hold. Signed-off-by: jddunn <[email protected]>
The JSON export read each table in a statement of its own, so a compile or a page rewrite that committed between the trace read and the page read put a page row in the file whose chunks the file did not hold. The export now reads every table through Brain.readConsistently, the view the SQLite export already reads from: a REPEATABLE READ transaction on Postgres and a read transaction on a second connection for a SQLite file in WAL mode. Signed-off-by: jddunn <[email protected]>
…nt view The tests that re-file a brain while its JSON export reads hooked brain.all, which the export no longer reads through. The hooks now wrap the reads of Brain.readConsistently too, so the re-file still lands mid-export. Signed-off-by: jddunn <[email protected]>
…e hook Signed-off-by: jddunn <[email protected]>
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
## What changed Move the workspace's `@framers/agentos` override from `^0.16.0` to `^0.19.0`, update 31 caret dev dependencies and the browser meeting capacity measurement dependency, update the meeting scheduler test image's exact 0.15.19 pin to 0.19.0, and commit the lockfile produced by the existing Lockfile workflow. The committed workspace previously resolved 0.16.0 and now resolves 0.19.0. Open peer ranges and `workspace:^` references keep their existing form; the override resolves the latter. No package version changes. ## Issue No issue ## Spec, plan and design None: dependency update ## Pictures None: no screen changes ## Docs No guide changes needed. Reviewed the release notes for [0.17.0](https://github.com/framerslab/agentos/releases/tag/v0.17.0), [0.17.1](https://github.com/framerslab/agentos/releases/tag/v0.17.1), [0.18.0](https://github.com/framerslab/agentos/releases/tag/v0.18.0), and [0.19.0](https://github.com/framerslab/agentos/releases/tag/v0.19.0), including the [per-user memory migration](framerslab/agentos#767) and [retrieved-text request shape](framerslab/agentos#834). ## Type of change - [x] Build or CI: dependency update ## Tests Validation runs exclusively in CI. [Lockfile resolution passed](https://github.com/framerslab/agentos-extensions/actions/runs/43735897379) using the repository's pnpm 10.34.7. Its artifact was copied unchanged; the diff contains only AgentOS resolution and peer-reference changes. No dependencies or validation commands ran locally. No filler tests were added for this manifest and lockfile change. All workflow checks passed on `09d56e10be677e323e7d029efb121413417afb79`: - [CI: build, extension suites and pack guards](https://github.com/framerslab/agentos-extensions/actions/runs/43736432139). The resolver and installed Gmail export check both report AgentOS 0.19.0. - [Meeting bot image and lifecycle](https://github.com/framerslab/agentos-extensions/actions/runs/43736432079), including the scheduler image on 0.19.0. - [Document parser on Node 24](https://github.com/framerslab/agentos-extensions/actions/runs/43736432131) and [document parser image lifecycle](https://github.com/framerslab/agentos-extensions/actions/runs/43736432152). - [Published source foundation](https://github.com/framerslab/agentos-extensions/actions/runs/43736432372) and [published Gmail source on Node 22 and 24](https://github.com/framerslab/agentos-extensions/actions/runs/43736432203). - [Dependency bump dry run](https://github.com/framerslab/agentos-extensions/actions/runs/43736432082), [Links](https://github.com/framerslab/agentos-extensions/actions/runs/43736432107), and [pull request title](https://github.com/framerslab/agentos-extensions/actions/runs/43736445549). Image publish jobs and the scheduled dependency-bump write job are skipped on pull requests. Superseded runs were cancelled automatically. ## How this was verified Read every AgentOS manifest, import/use site, workflow and the release notes above. The existing build, extension suites, installed consumer contracts, document parser tests, container lifecycle checks and dependency bump dry run provide the runtime checks. ## Migration notes - 0.17.0 changes recalled text placement and memory-hook timing. No extension installs those hooks or depends on the old placement. - 0.17.1 introduces per-user souled memory and database-backed wiki pages. Neither memory extension opens a souled store; both keep their own in-process records. No memory migration is needed here. - 0.18.0 requires retention for a shared souled store and adds per-user deletion, export and correction. There is no shared souled-store host here to configure. - 0.19.0 removes the implicit date tool and concise prompt profile and makes `AgentOS.create` preserve the factory's persistence setting. Production extensions do not construct a full runtime. The five auth examples use `new AgentOS().initialize` for auth demonstrations, with no model turn, implicit date-tool call or prompt-profile expectation; no demonstrated auth behavior needs changing. - 0.19.0 places retrieved text in an application note before the user's words. No request-capture parser or assertion here depends on the former `Context:` / `User Query:` wrapper. ## Checklist - [x] Existing suites cover the dependency update; no application behavior changed. - [x] Documentation impact reviewed. - [x] Package versions and release settings are unchanged. - [x] The title follows Conventional Commits. - [x] No secrets or private data are included. - [x] The diff has been read.
Summary
A souled agent kept one memory for everyone who talked to it: each turn was filed under the agent's id and recalled for whoever spoke next, compiled wiki pages mixed users, and
read_memory_pageread any page for anyone. This change files, recalls, compiles and reads that memory per subject: the session's user, or the session itself when it names none.conversationscope with one versioned key per agent and subject (conversationScopeKey,parseConversationScopeKey), matched by equality only. An id that holds a lone surrogate gets no key.memory_scopes), written with each scope's first trace, holding each scope's compile watermark;Memory.listScopes().memory_pages,UserWikiStore) on SQLite and Postgres. Pages undermemory/are the operator's: hand-written, shared, never written by a compile.souledAgent()files each turn under its subject's key, the user's message and the reply alike, and recalls that subject's memory and the operator's pages, and nobody else's.read_memory_pageanswers the asker's own pages and the operator's, lists them with{ "list": true }, and refuses a call that names a scope or a user.souledAgent()options:sharedMemory,compile,memoryPolicy,screen. The two hooks fail closed.memory_searchreads no conversation trace, consolidation leaves the conversation scope out, and a recall of the scope with no key is refused.Docs: docs/SOUL_FILES.md, docs/getting-started/HIGH_LEVEL_API.md, docs/memory/MEMORY_STORAGE.md, docs/getting-started/EXAMPLES.md, docs/GMI.md, README.md.
Linked issues
Part of #759
Spec, plan and design
None public
Pictures
No visible change
Type of change
How this was verified
CI only, on this pull request's runs. Final head 9a0b0bb0: CI (Test & Lint with the Postgres service, Browser tests, Batch-1 gated tests, Release dry run). The new suites:
souledAgent.scoped-memory.gmi.e2e.test.ts(the default runtime andruntime: 'gmi'),Memory.conversation-scope.e2e.test.ts(SQLite and the job's Postgres service),readMemoryPage.asker.e2e.test.ts,conversationScopeKey.test.ts. The breaking change gate stays red until the label it asks for is added.Each change was pushed test first; the failing run of each tests-only commit, then the passing run of its change:
conversationScopeKey.test.tscould not import the module); change e18641f4, passing.Memory.conversation-scope.e2e.test.ts, on SQLite and on Postgres: nomemory_scopestable, a trace with no key stored, both scopes listed); change e5bd377b, passing.UserWikiStore); change ab899471, passing.memory.legacy_pagesline,index.mdnot refreshed at attach, a soft-deleted chunk left, no chunk under the operator key); change e199a8b5, passing.readMemoryPage.asker.e2e.test.tsand 2 ofReadMemoryPageTool.test.ts: the asker's own page not found, no refusal line, a scope argument not refused, no listing); change 0b237117, passing.guestread as nobody); change c403af5d, passing.sharedMemory: tests 8b5395dc, failing (41 tests in 2 files, on both runtimes: another subject's fact recalled, traces under the agent's plain scope, a one-shot call filed, the shared-memory refusals missing, no.gitignore); change 9e6e8578, passing.memory/, no watermark a scope); change 2e2cc10f, passing.compile,memoryPolicy,screen: tests 5521f831, failing (27 tests ofsouledAgent.scoped-memory.gmi.e2e.test.ts, on both runtimes: the options were not read); change 53281259, passing in this run, whose only failures are the next item's tests, pushed with it.memory_searchreturned a conversation trace, a recall of the scope with no key resolved, the registry row was deleted while a page remained, a message deduped into a page chunk, two page writes at once left two chunk sets, consolidation merged the scope's traces, the import brought no page, an import left the file's chunks, a replace kept the receiving brain's rows); change 8c9e099b, passing.docs/SOUL_FILES.mdthat a compile writes no file undermemory/and refreshes no catalog, and gives three test fixtures a neutral user id; passing.Not covered:
souledAgent()opens SQLite alone, so its suite has no Postgres leg; the registry, the page rows and the per-scope compile run on Postgres in the facade suite. The export and import of the two new tables is tested on SQLite.Migration notes
souledAgent()files each turn under its subject, in a newconversationscope: the session'suserId, else the session. Recall across users and across sessions ends. On one person's own machine pass one stableuserId, or setsharedMemory: { as, reason }.generate()orstream()names no user: nothing is filed for it and it recalls the operator's pages alone, unlesssharedMemoryis set. Onememory.one_shot_unfiledlog line an agent says so. Useagent.session(id, { userId })for turns that should be remembered.memory_pagestable, never as files undermemory/.memory/index.mdlists the operator's pages only.close()compiles the subjects its turns wrote to; a trace stored another way waits foragent.memory.compileWiki().memory.compile_skippedlog line and the others compile.sources) stay on disk, and leave the index, the prompt, recall and every user's reads; a call with no user still reads them, and one log line counts them. Traces stored under the agent's plain scope id stay in the store and are read by no turn; onememory.legacy_traceslog line counts them. Nothing existing is moved, rewritten or deleted. To remove them:await agent.memory.deleteScope('persona', agentId), and, whenencodePlainScopeId('persona', agentId)differs (an id that holds/,%or:),deleteScopewith that encoded id too; then delete those page files.MEMORY.md; a line written by hand intomemory/index.mdoutside that block no longer reaches the prompt.Memory.forget().read_memory_pagetakes{ id }or{ list: true }. It answers not-found for another subject's page and for an earlier compiled page asked by a user, and an invalid-arguments result for a call that carriesscope,scopeId,userId,turnUserIdorsubject.Memory.compileWiki()compiles per scope and takes{ scopes };Memory.attachWiki()takes{ storeFor, compiler, beforeScopeCompile?, compileSkipReasonOf? };WikiCompiler.compile()takes the scope'sstore(WikiCompilerOptions.storeis optional);attachMemoryWiki()returnsstoreForbesidestore, and throws for an emptyagentId.recall()matchesscopeIdon thescope_idcolumn, so a row a release older than the column writes to the same brain after this process opened it is recalled by its scope id only after the next open.recentTraces()takesscopeId.remember()under theconversationscope needs a keyconversationScopeKey()built.recall()andrecentTraces()withscope: 'conversation'and noscopeIdthrow.memory_searchreturns no trace of theconversationscope and answers a search that names it with an error.Memory.consolidate()andmemory_reflectleave that scope's traces out.Memory.deleteScope('conversation', key)deletes the scope's traces and its registry row, and keeps the row while a page of the scope remains; delete a subject's pages withUserWikiStore.deleteAll()first.sqliteexport holdsmemory_scopesandmemory_pages, and a JSON export holds them asscopesandpages. An import of either keeps a page and a registry row the brain already holds; areplaceimport empties both tables first. The Markdown and Obsidian exports carry no page row.memoryPolicy,screenandsharedMemoryare refused with aTypeErroron an agent whose cognitive memory is on (runtime: 'gmi'with cognition memory): that memory lives in a store none of them reaches.Memory.deleteScope('conversation', key)andMemory.deletePageRows(key)run one after the other in a process: a delete made during a compile waits for it.recall(query)andrecentTraces(sinceMs)with no scope and no scope id read the whole brain, every subject's conversation traces among them: the host's own read of its store.MemoryScopegains'conversation'(aRecord<MemoryScope, number>gains a key);ReadMemoryPagePortisreadPage(id, asker)andlistPages(asker);MemoryIndexPortgainsdeleteTraces;WikiAttachableMemorygainsdeleteTraces, the page-row members (reindexPageRowamong them) andpageExistsOutside, and itsattachWikitakes the new shape.memory_scopes,memory_pages.memory/.store/.gitignoreis written when the store folder is made.Checklist
!before the colon for a change that breaks users (feat!:orfeat(api)!:).Summary by CodeRabbit
New Features
Bug Fixes
Documentation