Skip to content

Assistant phase 2b: twin profile + Memory Palace context in system prompt #147

@jayzalowitz

Description

@jayzalowitz

Phase 1 (#139) ships a generic system prompt — "You are SkyTwin, reply concisely." The assistant has no idea who the user is, what their preferences are, or what the twin has learned about them. That's the whole point of having a personal twin.

Scope

  • Build a ContextBuilder in @skytwin/assistant that takes a userId and returns a context block to inject into the system prompt.
  • Pull from @skytwin/twin-model.TwinService.getOrCreateProfile (preferences, inferences, trust tier).
  • Pull from @skytwin/mempalace retriever for relevant episodic memories (top-K based on the conversation's first user message).
  • Compose into the system prompt — keep it under 2KB so it doesn't dominate the token budget.
  • Cache the profile read per-request (not per-message) since it's the same across all turns in one HTTP call.

Out of scope

  • Live/streaming context updates mid-conversation (phase 2 ships sync only).
  • Action routing — that's phase 2c.

Why

Without this, the assistant can't answer "what did I tell you about X last month?" or "what's my preference for Y?" — the two killer use cases that distinguish a personal twin from generic ChatGPT.

Acceptance

  • A user with a profile containing email.auto_archive=true (HIGH confidence) gets that context surfaced when asked about email habits.
  • An episodic memory written via mempalace within the last week shows up when relevant to the current question.
  • Tests: stub TwinService + mempalace retriever, assert the rendered system prompt contains the expected lines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions