Skip to content

feat: project memory layer (tool + system context source) - #44539

Closed
savagelysubtle wants to merge 2 commits into
anomalyco:devfrom
savagelysubtle:agent-memory
Closed

feat: project memory layer (tool + system context source)#44539
savagelysubtle wants to merge 2 commits into
anomalyco:devfrom
savagelysubtle:agent-memory

Conversation

@savagelysubtle

Copy link
Copy Markdown

Summary

Adds a Claude-style file-based memory layer so agents accumulate knowledge across sessions.

memory tool (packages/opencode/src/tool/memory.ts)

  • Actions: list / read / write / delete, namespaced names supported (architecture/decisions)
  • Storage: <xdg-data>/opencode/memory/<project-slug>/*.md — per-project isolation via a worktree slug
  • Path traversal guarded; permission-gated like other tools

core/memory system context source

  • Registers a refreshable context source that injects a memory index (file names + first meaningful line, capped at 50 entries) into the prompt baseline
  • Uses the existing SystemContext algebra — memory updates render as context updates without restarting sessions

Design note

Follows Anthropic's memory-tool pattern: files curated by the agent itself rather than an embedding pipeline — just-in-time retrieval, works with compaction/context editing instead of against them.

Test plan

  • New test/tool/memory.test.ts: write → list → read → delete round-trip; path traversal rejected
  • Full test/tool/: 341 passing (1 pre-existing failure in write permissions test, reproduced on clean tree)
  • bun typecheck clean in packages/core and packages/opencode

@github-actionsgithub-actionsBot added the needs:compliance This means the issue will auto-close after 2 hours. label Aug 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate PRs Found

Based on the search results, I found two related PRs that may be addressing similar memory functionality:

  1. PR feat(opencode): native auto-memory for cross-session learning #20344: feat(opencode): native auto-memory for cross-session learning

  2. PR feat(memory): implement persistent project memory and background extraction #43870: feat(memory): implement persistent project memory and background extraction

Both of these PRs seem to address the same problem space of persistent memory across sessions. You should check their implementation details and status to see if they cover the same scope or if there's an opportunity to consolidate.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actionsgithub-actionsBot removed the needs:compliance This means the issue will auto-close after 2 hours. label Aug 24, 2026
Sign up for freeto 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

@savagelysubtle