feat: Shared Memory Phase 4 — Advanced Cross-Peer Features#80
feat: Shared Memory Phase 4 — Advanced Cross-Peer Features#80ajay-bhargava wants to merge 4 commits intostagingfrom
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 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); |
There was a problem hiding this comment.
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 👍 / 👎.
| crossPeerPerspectives: v.array( | ||
| v.object({ | ||
| label: v.string(), | ||
| perspective: v.string(), | ||
| }), |
There was a problem hiding this comment.
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 👍 / 👎.
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()peer.chat()withpeer.representation({ target, searchQuery, searchTopK: 5, maxConclusions: 10 })infollowupsChat.tsandemailReply.ts2. Extend MemoryRecall handler for glasses cross-peer support
apps/application/src/handlers/memory.tsgetActiveSharedMemoryConnectionsByMentraIdinconnections.ts(app layer can't access internal queries)b.CheckSensitivity(), passes perspectives tob.SynthesizeMemory()baml_src/synthesis.bamlwithcrossPeerPerspectivesinMemoryContext3. Add cross-peer context to web chat
packages/convex/chat.tssendMessagewith full cross-peer pipelinebaml_src/chat.bamlChatContextclass withcrossPeerPerspectivesfield and prompt sectionbamlActions.tsinterpretChatMessageargs4. Group connections (3+ users sharing context)
connectionGroupsandconnectionGroupMemberstables to schemacreateConnectionGroup,acceptGroupInvite,leaveConnectionGroup,toggleGroupSharedMemory,updateGroupMemberLabelgetGroupsForUser(public),getActiveSharedMemoryGroupMembers(internal)Post-merge steps
npx baml-cli generateto regenerate BAML TypeScript clientnpx convex devto push schema changes and regenerate Convex API typesFiles changed (18)
packages/convex/schema.ts— new tablespackages/convex/connections.ts— new file with full CRUD + queriespackages/convex/followupsChat.ts— optimized cross-peer queriespackages/convex/emailReply.ts— optimized cross-peer queriespackages/convex/chat.ts— added cross-peer supportpackages/convex/bamlActions.ts— updated interpretChatMessage argsbaml_src/chat.baml— cross-peer in ChatContext + promptbaml_src/synthesis.baml— cross-peer in MemoryContext + promptapps/application/src/handlers/memory.ts— glasses cross-peer supportapps/application/src/baml_client/*— regenerated typespackages/baml_client/*— regenerated typesdocs/SHARED_MEMORY_PLAN.md— updated status to Phase 4 complete