[WIP] B1.5: door-context bridging for the Letta brain (stacked on #96) — do not merge#101
Closed
juniperbevensee wants to merge 1 commit into
Conversation
Productionizes the #96 prototype's door-context gap (B1.5, ratified: sender- tagged message text). A shared Letta brain sees only the message text over REST, so it can't tell who is speaking or which group — multiplayer is broken. We prepend a compact one-line tag; Letta's server-side history then accumulates identity turn over turn. Current-turn sender + group label only, NOT transcripts. - letta_brain.py: build_sender_tag()/apply_sender_tag() + send_message() gains sender/group params. Documents the no-trailing-slash /messages requirement. - run.py: _run_agent_via_letta derives sender (user_name) + group (chat_name, else type:id; None for DMs) from the SessionSource and passes them through. Validated live 2026-07-21 (self-hosted Letta on Primo): given '[from Alice in #family] ...' the agent replied 'Alice is messaging me from the group #family.' — the inline tag conveys identity, no memory-sync needed. 12/12 tests (8 new: tag construction, send forwarding, DM vs group vs chat_name dispatch). ruff clean. Draft — real B1 also needs SSE streaming + per-agent serialization (spec B3); this lands the door-context bridge. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slice B1.5 of Swarm Map v1 — the door-context bridge (v1 spec §2 B1.5). Stacked on #96 (the slice-0 prototype). Draft/do-not-merge.
The gap (from #96)
A shared Letta brain sees only the message text over REST — Letta owns its own server-side history, so the rich per-turn context the native loop builds never reaches it. Without it the brain can't tell who is speaking or which group it's in, and multiplayer is broken.
Decision (ratified): sender-tagged message text
Prepend a compact one-line tag to the forwarded message; Letta's history then accumulates identity turn over turn. Chosen over memory-sync (conflates transient routing context with durable memfs memory) and per-turn system-prefix (fights memfs's system prompt). Rationale + memfs grounding in the org decision memory.
letta_brain.py:build_sender_tag()/apply_sender_tag()+send_message()gainssender/group. Documents the no-trailing-slash/messagesrequirement (learned live —/messages/307-redirects and drops the POST body).run.py:_run_agent_via_lettaderivessender(user_name) andgroup(chat_name, elsetype:id;Nonefor DMs) from theSessionSource.Live-validated 2026-07-21
Stood up a self-hosted
letta/lettaserver (Primo, torn down clean). Given[from Alice in #family] ..., the agent replied "Alice is messaging me from the group #family." — the inline tag conveys identity, no memory-sync needed. Same run confirmed the A2 create payload (letta_v1_agent+systemaccepted) and the A3/core-memory/blockspath.Tests / lint
12/12 (8 new: tag construction across sender/group/empty, send-message forwarding, and DM vs group vs chat_name dispatch). ruff clean.
Still ahead for full B1 (spec)
SSE streaming (reuse proxy mode's consumer) + per-agent message serialization (B3). This PR lands the door-context bridge that gated them.
🤖 Generated with Claude Code