Skip to content

[integrations] Add OpenCode V2 Agent Memory adapter with optional evidence review - #524

Closed
dikoga wants to merge 2 commits into
NateBJones-Projects:mainfrom
dikoga:feat/opencode-agent-memory
Closed

dikoga wants to merge 2 commits into
NateBJones-Projects:mainfrom
dikoga:feat/opencode-agent-memory

Conversation

@dikoga

@dikoga dikoga commented Nov 3, 2026 •

Copy link
Copy Markdown

OpenCode currently needs explicit memory-tool calls to retrieve OB1 context. This contribution adds a native OpenCode V2 plugin that recalls bounded, project-scoped memory before primary model requests optionally saves compact findings after successful completion or before compaction, and can use an explicitly selected reviewer to approve supported routine findings as generated evidence. OpenCode keeps its own session history and compaction; OB1 remains the shared durable memory backend.

Behavior and boundaries

  • Use the existing remote Agent Memory API, without changing core infrastructure, schemas, or adding an MCP server.
  • Enforce memory use policies, workspace/project scope, session isolation, a hard context byte budget, bounded caching, and network deadlines.
  • Keep automatic write-back off by default. When enabled, extract only visible user/assistant text into compact structured findings; exclude tool payloads and reasoning, require review, and use durable receipts plus idempotency keys.
  • Keep model-assisted review independently opt-in. Only source-supported findings from the same session may become evidence-only; no instruction promotion, automatic deletion, or cross-project queue sweep. Preserve capture receipts across review failures.
  • Preserve existing explicit MCP tools for review and manual actions. Do not report context injection as actual memory use.
  • Include a design plan, configuration and troubleshooting guide, metadata, offline tests, and reproducible native/live smoke checks.

Requirements

OpenCode 2.2.5, Node.js 22+, npm for building, a working OB1 Agent Memory schema/API, and an API credential supplied through the server environment or a protected file. The built plugin has no runtime npm dependencies. No specific model or paid model service is required.

Validation

  • npm test: 20 tests passed, covering scope/policy filtering, byte budgets, concurrent recall, failure backoff, capture opt-in, reasoning/tool exclusion, duplicate checkpoints, retry identities, reviewer failures, exact source quotes, forbidden review actions, and intervening human edits.
  • npm run check: passed.
  • Native OpenCode 2.2.5 smoke: plugin loaded, recalled context reached the actual model HTTP request, completion checkpoint reached a local fixture backend, native compaction completed, and evidence-only review reached the fixture backend. The fixture isolates global configuration and refuses unrelated plugins before making model requests. The test uses a fake model/API, performs no external writes, and removes its synthetic session.
  • Tested against my own running OB1 instance: authenticated read-only recall succeeded with a real request ID and zero write-back calls. The isolated project returned no memories; this verifies connectivity and response handling, not useful retrieval quality. A subsequent live run verified native capture and review through a ChatGPT-authenticated Astra model: four generated findings were saved, one became evidence-only, and three stayed pending. Approved evidence retained generated provenance and could not be used as an instruction. The instance needed a separately scoped local policy change because its existing review route was personal-project-only; that deployment policy is not part of this contribution.
  • Metadata schema validation, scoped Markdown lint, relative-link checks, private-content scan, and git diff --check: passed.
  • npm audit --omit=dev: zero vulnerabilities. The pinned upstream SDK's build-time dependency tree currently reports moderate advisories; it is not bundled into the plugin runtime.

Completion checkpoints are best effort and need the OpenCode server to remain alive. Generated findings stay review-required unless the operator explicitly enables evidence-only model review; no automatic verdict becomes a trusted instruction. Secret-pattern checks are defense in depth, not comprehensive redaction. Capture should only be enabled for projects whose findings may be retained.

@github-actions github-actions Bot added the integration Contribution: MCP extension or capture source label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Hey @dikoga — welcome to Open Brain Source! 👋

Thanks for submitting your first PR. The automated review will run shortly and check things like metadata, folder structure, and README completeness. If anything needs fixing, the review comment will tell you exactly what.

Once the automated checks pass, a human admin will review for quality and clarity. Expect a response within a few days.

If you have questions, check out CONTRIBUTING.md or open an issue.

@dikoga dikoga changed the title [integrations] Add OpenCode V2 Agent Memory adapter [integrations] Add OpenCode V2 Agent Memory adapter with optional evidence review Nov 3, 2026
@dikoga dikoga closed this Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration Contribution: MCP extension or capture source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant