Skip to content

feat(memory): SharedMemoryStore — cross-agent shared memory with scoped FTS recall#7758

Draft
leavedrop wants to merge 3 commits into
microsoft:mainfrom
leavedrop:feat/shared-memory-store
Draft

feat(memory): SharedMemoryStore — cross-agent shared memory with scoped FTS recall#7758
leavedrop wants to merge 3 commits into
microsoft:mainfrom
leavedrop:feat/shared-memory-store

Conversation

@leavedrop
Copy link
Copy Markdown

Summary

Implementation of the SharedMemoryStore proposed in #7748 — a cross-agent shared memory store with scoped FTS recall for autogen-ext.

  • SQLite + FTS5 backend, zero external dependencies (uses Python's built-in sqlite3)
  • Three scopes: agent (private), group (per-team), global (cross-runtime)
  • Tool-shaped capsule recall via memory_search / memory_remember / memory_forget — facts land in tool-result position, not prefix-loaded
  • Provenance on every read: created_by, scope, confidence, timestamp, fact_hash — so consuming agents can distinguish claims from verified facts
  • Write authorization: per-scope policy; global writes restricted by default (addressing the memory-poisoning concerns from @msaleme and @redbotster in RFC: Cross-agent shared memory store with on-demand capsule recall (agent/group/global scopes) #7748)
  • Soft-delete with tombstones for audit trail
  • Configurable max capsule size to bound recall payload

v1 scope (per discussion in #7748)

This PR covers the minimal v1 shape the community converged on:

  • Global + group + agent scopes with FTS-only search (no embeddings)
  • Write receipts with provenance metadata
  • Per-scope write authorization
  • Optimistic concurrency via version field
  • FunctionTool factories for easy agent integration
  • Implements the Memory protocol — works with AssistantAgent(memory=[...])
  • should_recall_memory policy hook (deferred — needs runtime integration discussion)
  • Embedding column (intentionally deferred; FTS-first per @scosemicolon's suggestion)

Test plan

  • 20 tests passing covering:
    • Remember/search round-trip with provenance
    • Scope isolation (agent facts invisible to other agents)
    • Group scope sharing across agents
    • Global write authorization (denied for unauthorized, allowed for authorized)
    • Soft-delete with tombstone preservation
    • Capsule size truncation
    • TTL expiry
    • Memory protocol compliance (add, query, clear)
    • FunctionTool integration (search, remember, forget via run_json)
    • File-backed SQLite persistence across store instances

leavedrop and others added 2 commits May 27, 2026 10:13
…scoped FTS recall

Adds a new memory extension (autogen-ext) implementing the SharedMemoryStore
proposed in microsoft#7748. Key design points from community discussion:

- SQLite + FTS5 backend, zero external dependencies
- Three scopes: agent (private), group (per-team), global (cross-runtime)
- Capsule-shaped recall via tool-result position, not prefix-loaded
- Write receipts with provenance (agent_id, scope, timestamp, fact_hash)
- Per-scope write authorization (global restricted by default)
- Soft-delete with audit tombstones
- Configurable max capsule size to bound recall payload
- FunctionTool factories (memory_search/remember/forget) for agent tool use

20 tests covering scope isolation, auth, TTL, persistence, tools, and
Memory protocol compliance.

Refs microsoft#7748

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- _scope_filter now returns (where_clause, params) tuple instead of
  interpolating agent_id/group_id into SQL strings directly
- Strip quote characters from FTS5 search terms to prevent query syntax
  injection
- Remove unused imports (json, Optional, Any)
- Fix capsule size test that silently passed on empty results

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@leavedrop
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

stale_after + stale_writer fields bind TTL expiry to the asserting
agent rather than a bare clock tick, so consumers can refuse staleness
per-writer instead of per-timestamp.

shadowed_by annotation on scope=all queries marks broader-scope facts
when a narrower-scope fact with the same fact_hash exists, closing the
authority-drift gap discussed in microsoft#7748.
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