Skip to content

feat: add memory.disable_global config option to skip global scope#6

Closed
Edison-A-N wants to merge 3 commits into
joshuadavidthomas:mainfrom
Edison-A-N:main
Closed

feat: add memory.disable_global config option to skip global scope#6
Edison-A-N wants to merge 3 commits into
joshuadavidthomas:mainfrom
Edison-A-N:main

Conversation

@Edison-A-N
Copy link
Copy Markdown

Summary

This PR adds a memory.disable_global configuration option (via ~/.config/opencode/agent-memory.json) that allows users to completely disable the global memory scope, restricting all memory operations to project-scoped blocks only.

Motivation

In multi-project environments, global memory blocks (persona, human) are shared across all projects. This can cause unintended issues:

  • Context leakage: project A's preferences/conventions pollute project B's agent context
  • Unpredictable behavior: agents carry over stale or irrelevant global state across different codebases
  • Sensitive data: information written to global blocks becomes visible in every project

For users who run OpenCode across many distinct projects, the ability to opt out of global memory is essential.

Changes

Configuration

New field in ~/.config/opencode/agent-memory.json:

{
  "memory": {
    "disable_global": true
  }
}

Behavioral changes when disable_global: true

Operation Before After
ensureSeed() Creates persona + human + project Only creates project
listBlocks("global") Returns global blocks Returns []
listBlocks("all") Returns global + project Returns project only
setBlock("global", ...) Writes to global Throws error
replaceInBlock("global", ...) Replaces in global Throws error

Files changed

  • src/journal.ts — Added memory.disable_global to config schema (ConfigSchema)
  • src/memory.ts — Added MemoryStoreOptions.disableGlobal; createMemoryStore() accepts options and gates all global-scope operations
  • src/plugin.ts — Reads config and passes disableGlobal to memory store
  • src/tools.ts — Propagates store options through tool definitions
  • package.json — Published as @Edison-A-N/opencode-agent-memory on GitHub Packages for testing
  • .npmrc — GitHub Packages registry config (can be removed if merged upstream)

Questions for maintainer

Hi @joshuadavidthomas 👋

I've been using this plugin in a multi-project setup and found that global memory blocks were causing cross-project interference. This PR is my attempt to address that — I'd love your feedback on a few things:

  1. Is this the right approach? Adding a config flag felt minimally invasive, but I'm open to alternative designs (e.g., a per-project override, or making global scope opt-in rather than opt-out).

  2. Config location: I added memory.disable_global to the existing agent-memory.json config schema alongside journal. Does this feel right, or would you prefer a different structure?

  3. Scope of the PR: The .npmrc and package.json changes are specific to my fork's publishing setup. Happy to clean those up if this is headed toward a merge.

  4. Testing: The existing tests pass. I haven't added dedicated tests for disable_global yet — happy to add them if the approach looks good.

Thank you for building this plugin — the Letta-style memory model is a great fit for OpenCode. Looking forward to your thoughts!

@Edison-A-N
Copy link
Copy Markdown
Author

Duplicate of #7, closing.

@Edison-A-N Edison-A-N closed this Mar 21, 2026
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