Skip to content

Memories from one repo are injected into sessions in other repos #8

Closed

Description

@WhollyMindless

Summary

All memories live in one global store (~/.config/opencode/memory), and nothing records which repo a memory came from. Every read path that feeds the model scores or lists all active memories, so knowledge from one project is injected into sessions in unrelated projects.

This is probably just an oversight rather than a design choice, and sharing is often convenient: preferences and general tooling habits should follow you between projects. It becomes a problem when projects are meant to stay separate, for example different clients, work vs. personal, or a fork next to its upstream. Then one repo's commands, decisions and open threads surface as "durable memory" somewhere they don't belong.

Reproduction

  1. In repo A, have the agent store:
    memory_remember type=pattern scope=billing-service content="Staging deploys require the VPN and make deploy-staging"
  2. Open opencode in an unrelated repo B and ask: "how do I deploy to staging?"
  3. The system prompt for repo B now contains:
    ## Relevant durable memory
    - [2026-10-21] pattern/billing-service: Staging deploys require the VPN and make deploy-staging
    

The agent in repo B now has repo A's deploy steps as "durable memory" and may follow them.

Where

At commit 2674b54, every one of these reads from loadAll() with no repo filter:

  • relevantKnowledge() – per-epoch injection
  • contextualPull() – memories appended to grep/glob/read results
  • systemDigest() – memory count, plus the open-thread "frontier", which surfaces open threads from other projects
  • compactionAnchor() – the summarizer is told to preserve the newest memories "verbatim", whichever repo they came from
  • memory_recall with no filters returns the most recent memories from all repos

/repo-init scopes its memories by basename(root), so two checkouts with the same folder name (e.g. api, or a fork next to its upstream) share init stamps and script memories too.

Expected

Memories written in a repo are visible only in that repo by default, with an explicit way to mark a memory as cross-project (user preferences, global tooling habits).

Suggested approach

  • Record a repo= field on every row at write time: the git toplevel path, or a hash of the origin remote URL so it survives re-clones.
  • Filter injection, pull, digest, compaction anchor and default recall to repo == current || repo == global.
  • Let memory_remember take global: true (or a reserved global scope) for cross-project memories; preference might default to global.
  • Treat existing rows without repo= as global, so upgrading is non-breaking, and add a one-time helper in the viewer to assign them to a repo.
  • Use the same repo key for /repo-init instead of basename(root).

Happy to send a PR if this direction works for you.

Activity

  1. added a commit that references this issue on Oct 22, 2026
    3ba338e
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions