Skip to content

[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
dev/juniperbevensee/letta-backed-protofrom
dev/juniperbevensee/b1-letta-door-context
Closed

[WIP] B1.5: door-context bridging for the Letta brain (stacked on #96) — do not merge#101
juniperbevensee wants to merge 1 commit into
dev/juniperbevensee/letta-backed-protofrom
dev/juniperbevensee/b1-letta-door-context

Conversation

@juniperbevensee

Copy link
Copy Markdown
Collaborator

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() gains sender/group. Documents the no-trailing-slash /messages requirement (learned live — /messages/ 307-redirects and drops the POST body).
  • run.py: _run_agent_via_letta derives sender (user_name) and group (chat_name, else type:id; None for DMs) from the SessionSource.

Live-validated 2026-07-21

Stood up a self-hosted letta/letta server (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 + system accepted) and the A3 /core-memory/blocks path.

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

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>
@juniperbevensee

Copy link
Copy Markdown
Collaborator Author

Superseded by #104 — the B1.5 sender-tag commit rides in #104, rebased onto current main under the production B1.

@juniperbevensee
juniperbevensee deleted the dev/juniperbevensee/b1-letta-door-context branch July 22, 2026 04:23
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