Skip to content

feat: Shared Memory Phase 4 — Advanced Cross-Peer Features#80

Open
ajay-bhargava wants to merge 4 commits intostagingfrom
feat/shared-memory
Open

feat: Shared Memory Phase 4 — Advanced Cross-Peer Features#80
ajay-bhargava wants to merge 4 commits intostagingfrom
feat/shared-memory

Conversation

@ajay-bhargava
Copy link
Contributor

Summary

Implements Phase 4 of the Shared Memory plan (docs/SHARED_MEMORY_PLAN.md). Phases 0-3 (SDK evaluation, connections infrastructure, follow-up cross-peer queries, email reply cross-peer queries) were completed previously.

Phase 4 Changes

1. Optimize cross-peer queries with peer.representation()

  • Replaced peer.chat() with peer.representation({ target, searchQuery, searchTopK: 5, maxConclusions: 10 }) in followupsChat.ts and emailReply.ts
  • Faster lookups — skips Honcho's agentic reasoning step since BAML handles interpretation

2. Extend MemoryRecall handler for glasses cross-peer support

  • Added cross-peer queries to apps/application/src/handlers/memory.ts
  • New public query getActiveSharedMemoryConnectionsByMentraId in connections.ts (app layer can't access internal queries)
  • Queries up to 3 connected peers, gates through b.CheckSensitivity(), passes perspectives to b.SynthesizeMemory()
  • Updated baml_src/synthesis.baml with crossPeerPerspectives in MemoryContext

3. Add cross-peer context to web chat

  • Extended packages/convex/chat.ts sendMessage with full cross-peer pipeline
  • Updated baml_src/chat.baml ChatContext class with crossPeerPerspectives field and prompt section
  • Updated bamlActions.ts interpretChatMessage args

4. Group connections (3+ users sharing context)

  • Added connectionGroups and connectionGroupMembers tables to schema
  • Mutations: createConnectionGroup, acceptGroupInvite, leaveConnectionGroup, toggleGroupSharedMemory, updateGroupMemberLabel
  • Queries: getGroupsForUser (public), getActiveSharedMemoryGroupMembers (internal)

Post-merge steps

  • Run npx baml-cli generate to regenerate BAML TypeScript client
  • Run npx convex dev to push schema changes and regenerate Convex API types

Files changed (18)

  • packages/convex/schema.ts — new tables
  • packages/convex/connections.ts — new file with full CRUD + queries
  • packages/convex/followupsChat.ts — optimized cross-peer queries
  • packages/convex/emailReply.ts — optimized cross-peer queries
  • packages/convex/chat.ts — added cross-peer support
  • packages/convex/bamlActions.ts — updated interpretChatMessage args
  • baml_src/chat.baml — cross-peer in ChatContext + prompt
  • baml_src/synthesis.baml — cross-peer in MemoryContext + prompt
  • apps/application/src/handlers/memory.ts — glasses cross-peer support
  • apps/application/src/baml_client/* — regenerated types
  • packages/baml_client/* — regenerated types
  • docs/SHARED_MEMORY_PLAN.md — updated status to Phase 4 complete

ajay-bhargava and others added 3 commits February 27, 2026 10:26
Query-scoped cross-peer lookups via Honcho v3 dialectic API.
Integration surfaces: follow-ups and email replies.
Sensitivity filter with fixed categories.
Web-only connection setup, both users must be Pro.

Amp-Thread-ID: https://ampcode.com/threads/T-019ca559-525e-753e-adeb-e921592e6b58
Co-authored-by: Amp <amp@ampcode.com>
- Optimize cross-peer queries with peer.representation() instead of peer.chat()
- Extend MemoryRecall handler for glasses cross-peer support
- Add cross-peer context to web chat (chat.ts, chat.baml, bamlActions.ts)
- Add group connections schema and CRUD (connectionGroups, connectionGroupMembers)
- Update synthesis.baml with crossPeerPerspectives in MemoryContext
- Add public query getActiveSharedMemoryConnectionsByMentraId for app layer
- Add getActiveSharedMemoryGroupMembers internal query

Amp-Thread-ID: https://ampcode.com/threads/T-019ca5da-0bdc-71c4-b883-2d206a12db38
Co-authored-by: Amp <amp@ampcode.com>
@vercel
Copy link

vercel bot commented Feb 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clairvoyant Ready Ready Preview, Comment Mar 1, 2026 0:53am

Request Review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b41ea0db65

ℹ️ 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".

crossPeerContext: v.string(),
},
handler: async (_, { crossPeerContext }): Promise<SensitivityCategory> => {
const result = await b.CheckSensitivity(crossPeerContext);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add CheckSensitivity to BAML before invoking sensitivity gate

This action calls b.CheckSensitivity(...), but this commit does not add a CheckSensitivity function anywhere under baml_src or in the generated BAML client methods, so the call will throw at runtime whenever a cross-peer perspective is gated. In practice that means the new cross-peer pipeline in chat/followup/email silently falls back after errors instead of applying the intended sensitivity filter.

Useful? React with 👍 / 👎.

Comment on lines +69 to +73
crossPeerPerspectives: v.array(
v.object({
label: v.string(),
perspective: v.string(),
}),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Sync BAML context schemas with cross-peer arguments

The Convex layer now requires and forwards crossPeerPerspectives, but the corresponding BAML context schemas are not consistently updated in this commit (e.g. EmailContext/FollowupChatContext in baml_src still omit it, and generated artifacts are out of sync for chat), so this field is either ignored or rejected by runtime validation. That makes the new cross-peer lookup work ineffective for interpretation flows even when perspectives are fetched successfully.

Useful? React with 👍 / 👎.

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