Skip to content

feat: scope memory entries by project - #759

Merged
edenreich merged 3 commits into
mainfrom
feat/memory-project-identifier
Jul 6, 2026
Merged

edenreich merged 3 commits into
mainfrom
feat/memory-project-identifier

Conversation

@edenreich

@edenreich edenreich commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #758. Memory fact-files lived in one flat global directory with no way to tell which project a fact belonged to; cross-project slugs could collide, and the whole index was injected into every session.

  • Per-project subdirectories: project facts live at <project-slug>/<slug>.md (e.g. inference-gateway-cli/build-commands.md); global facts stay at the root. Legacy flat files keep working as global — no migration needed.
  • Project detection: new internal/project package — git remote origin → org/repo, fallback cwd basename, else global; cached per process.
  • Frontmatter provenance: metadata.project (human-readable org/repo) and metadata.session (the session that last wrote the fact; chat now injects the conversation ID into the tool context, headless already had one).
  • Write semantics: optional project arg; defaults by type — user facts are global, feedback/project/reference go under the detected project; "global" forces the root; name accepts slug or project/slug exactly as shown in the index (traversal names are now rejected outright).
  • Token-efficient recall: the injected MEMORY.md index is filtered to current-project + global entries plus one line naming other projects; the injection cap default drops 4000 → 2000 chars (memory.max_chars, INFER_MEMORY_MAX_CHARS). The Memory tool's index read still returns the full index.
  • Per-entry cap: new memory.max_entry_chars (default 2000, INFER_MEMORY_MAX_ENTRY_CHARS); over-cap writes are rejected with an actionable error. Zero/missing means default, so existing memory.yaml files keep loading.

Acceptance criteria (#758)

  • Easier to sort memory files by project (directory layout)
  • Easier to look up memory files by project (index paths carry the project; read by project/slug)
  • Recall optimized for relevant info (project-filtered injection)
  • No vectorization — plain files + flat index
  • Token-efficient entries with caps (max_chars 2000 default, new max_entry_chars 2000 default)

Cross-repo impact

  • infer-action: references the built-in memory reminders by name; names and texts are unchanged → no change required.
  • Shared .memory git remotes: subdirectories sync via the existing git add -A; mixed old/new CLI versions against one remote are safe (both index-line forms share one grammar; old CLIs treat everything as flat/global).
  • docs: needs a [DOCS] follow-up for the new layout, project arg, max_entry_chars, and the 2000-char default (see docs ticket).
  • Stale user prompts.yaml keeps the old Memory tool description until infer init --overwrite; bare names remain valid, so behavior degrades to "no project awareness", never breaks.

Testing

  • task test green, task lint 0 issues.
  • New tests: project scoping (auto-prefix, user-type global default, explicit/conflicting project arg, name-embedded project), read/delete by project/slug and legacy bare slug, index isolation of x vs p/x, sanitizeName table incl. traversal rejection, entry-cap boundaries, session-ID frontmatter, filterMemoryIndex table, Slugify/remote-URL parsing, config validation and env overrides.

Memory fact-files were one flat global directory with no way to tell
which project a fact belonged to (#758). Now:

- Project facts live in per-project subdirectories
  (<project-slug>/<slug>.md); global facts stay at the root. Legacy
  flat files keep working as global - no migration.
- New internal/project package detects the project (git remote origin
  -> org/repo, fallback cwd basename) once per process.
- Frontmatter records metadata.project (human-readable org/repo) and
  metadata.session (the session that last wrote the fact).
- Memory write gains an optional project arg; defaults: user facts are
  global, feedback/project/reference go under the detected project;
  "global" forces the root.
- The injected MEMORY.md index is filtered to current-project + global
  entries, with one summary line naming other projects; the injection
  cap default drops 4000 -> 2000 chars (memory.max_chars).
- New per-entry write cap memory.max_entry_chars (default 4000,
  INFER_MEMORY_MAX_ENTRY_CHARS); zero means default so existing
  memory.yaml files keep loading.
- Chat tool context now carries the conversation ID as the session ID
  so provenance works in both chat and headless modes.

Closes #758
@edenreich
edenreich requested a review from a team as a code owner July 6, 2026 11:17
@edenreich
edenreich merged commit cabda08 into main Jul 6, 2026
1 check passed
@edenreich
edenreich deleted the feat/memory-project-identifier branch July 6, 2026 11:27
inference-gateway-releaser Bot added a commit that referenced this pull request Jul 6, 2026
## [0.133.0](v0.132.1...v0.133.0) (2026-07-06)

### 🚀 Features

* add nvidia provider support ([#753](#753)) ([e9ea883](e9ea883)), closes [#751](#751)
* **agent:** cap rendered skills list and harden system prompt injection ([#761](#761)) ([cb0f36e](cb0f36e))
* scope memory entries by project ([#759](#759)) ([cabda08](cabda08)), references [#758](#758)
* **chat:** show session continuation instructions on exit ([#757](#757)) ([8d04a3a](8d04a3a)), closes [#756](#756)

### 🐛 Bug Fixes

* **chat:** add --session-id flag and fix exit message ([#760](#760)) ([a2202ba](a2202ba))
* **ci:** release notes are not being generated ([32b7acf](32b7acf))
* replace /compact with /new when plan is accepted ([#755](#755)) ([30304ed](30304ed)), closes [#754](#754)

### ♻️ Code Refactoring

* **agent:** remove comments about skill description capping ([e50aa30](e50aa30))

### 🧹 Maintenance

* **deps:** bump claude-code-action v1.0.161 -> v1.0.165 ([#752](#752)) ([44d1985](44d1985))
* **deps:** update flox packages ([8a35d5e](8a35d5e))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.133.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TASK] Memory entry should contain a project identifier

1 participant