Skip to content

Tie repository-specific memories to their repository #2129

Open

Description

@sentry-junior

Memory has no structured way to say which repository a memory applies to. Repo-specific facts such as commands, CI setup, file paths, and conventions can be recalled into work on a different repository, and recall has no repository signal to bias or reject them.

Current behavior

  • A memory row stores visibility (scope), subject_type (user / conversation / general), optional location_id and conversation_id, and content (packages/junior-memory/src/db/schema.ts). None of these identify a repository. Location only records where Junior learned a memory and does not grant access (packages/junior-memory/README.md).
  • Recall fuses vector and full-text ranks, then the relevance model sees only memory id + content and the request text (recall.ts, selectRelevantMemories in agent.ts). Its prompt already says to prefer matches on "the exact repository" (agent.ts), but it gets no structured repository for the memory or for the current turn.
  • UserPromptContext (junior-plugin-api/src/prompt.ts) and PluginRunContext (junior-plugin-api/src/tasks.ts) expose no Conversation annotations or Location configuration. The memory plugin cannot see repository signals that core already holds: GitHub object annotations keyed owner/repo#number (junior-github/src/annotations.ts), the Location github.repo default, or the active Workspace.
  • feat(memory): add recall-layer relevance gate to filter low-relevance vector matches #679 recorded the production symptom: a query about CI in getsentry/junior recalled getsentry/sentry autofix memories, because repository vocabulary embeds similarly.

Gap

  • Repo-specific memories cannot be biased toward their repository or kept out of work on other repositories.
  • Many memories are not repo-specific: user preferences, company facts, and cross-repo procedures. A repository on every memory would be wrong for these.

Proposed direction (David Cramer)

  • Add optional annotations to memories, starting with the repository a memory applies to.
  • In recall, bias repo-specific memories toward their repository, and possibly disqualify them from work on other repositories.
  • Memory annotations are likely not the same thing as Conversation annotations. One conversation can touch several repositories, while a memory from it applies to one or none.
  • Annotation can be expensive and is not always useful, so cost must stay low.

Open questions

  • Naming: TERMINOLOGY.md defines Annotation as attached to one Conversation. Reuse the term, or use a new one?
  • Source at capture time: the existing extraction / review model call, deterministic conversation signals, or both. Existing memories: backfill or leave untagged.
  • Current repository at recall time: which signals are strong enough to disqualify a memory, and which only bias ranking (for example, a Location default versus a repository named in the request).
  • Provider boundary: the memory plugin should not parse GitHub keys (policies/provider-boundaries.md).

Related: #679, #1861 (moving Memory into core changes where this lives), #1784.

via David Cramer.

--

View Junior Session [Sentry]

Activity

  1. sentry-junior commented on Nov 20, 2026

    @sentry-junior
    ContributorAuthor

    Adding a related angle from #2483, a draft prototype I'm closing in favor of this issue.

    Commit and file provenance for code memories. Besides the repository, a memory that came from reading code could record the commit and the files its evidence came from, at capture time. That would let a periodic check flag a memory as stale when its file changes or disappears. Lore does something like this with its reference check, lowering confidence instead of deleting.

    Lessons from #2483:

    • Link files only to the evidence a memory actually cites, not to every file the run touched. It's tighter than Lore's per-session links.
    • Key files on owner/repo plus a path relative to the repo, not on the sandbox checkout path (repos/<name>/…). Two repos with the same name collide otherwise.
    • bash, grep and findFiles reads need coverage too. Agents read a lot of code through bash.
    • Memories created with createMemory would get no links unless they're handled separately.

    Gate: build the commit and file part only once data shows it matters, meaning a meaningful share of active memories cite file-read evidence, and those memories get retired as contradicted (the retirement signals from #3770). The contradiction check from #3758 already covers stale memories when a Turn's evidence shows the conflict.

    After #3774, Memory lives in core, so this would be a core migration under packages/junior/migrations/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions