Repository navigation
feat(memory): configurable git sync backend - #707
Merged
Merged
Conversation
Back the persistent memory directory (#670) with an optional git remote so memory can be shared and durable across machines and ephemeral headless runs (issue #683). - memory.backend config: type local (default, behavior unchanged) | git, with repo/branch/commit_message/timeout and sync.on_start/on_finish; validation and INFER_MEMORY_BACKEND_* env overrides. - domain.MemoryBackend with a local no-op and a git implementation selected by a factory (mirrors the storage backend pattern). - SyncIn clones-or-pulls once per process at session start; SyncOut commits and pushes only when the memory dir changed, with a bounded push/pull-rebase retry loop plus a per-host flock so concurrent runs don't clobber each other. - Wired best-effort at the agent hook seams: chat pulls at start and pushes via the Memory tool on write/delete; headless infer agent pulls on start and pushes at run finish. A sync failure logs and never aborts the run. - Auth uses the user's default git config (no ssh/env override); the per-op timeout prevents hangs on credential prompts. - Add a periodic memory-hygiene reminder (every 4 turns) nudging the agent to record durable facts.
edenreich
commented
Jul 1, 2026
edenreich
commented
Jul 1, 2026
edenreich
commented
Jul 1, 2026
edenreich
commented
Jul 1, 2026
edenreich
commented
Jul 1, 2026
edenreich
commented
Jul 1, 2026
edenreich
commented
Jul 1, 2026
edenreich
commented
Jul 1, 2026
edenreich
commented
Jul 1, 2026
edenreich
commented
Jul 1, 2026
edenreich
commented
Jul 1, 2026
edenreich
commented
Jul 1, 2026
Co-authored-by: Eden Reich <[email protected]>
init is create-if-missing, so an existing reminders.yaml never gains a newly added built-in reminder (memory-hygiene) - LoadReminders reads the file wholesale. Reconcile the built-in memory reminders against the memory flag at load: inject any missing ones when memory is enabled (so the feature ships to existing users without regenerating the file) and prune them when disabled. MemoryReminders() is now the single source of truth for both seeding and reconciliation; only absent reminders are added, so user edits are preserved.
--overwrite only relaxed the pre-flight guard; the userspace-only files (keybindings, reminders, heartbeat) were still written create-if-missing, so init --overwrite silently left them stale - e.g. an existing reminders.yaml never gained the memory-hygiene reminder. Thread overwrite into createFileIfAbsent so home-mode --overwrite regenerates them, while --project init still never clobbers files owned by a prior home init. memory.yaml stays protected by design (it holds the user's memory/backend config).
Revert the load-time injection of built-in memory reminders: reminders.yaml is the single source of truth, seeded by init / init --overwrite. At load we only prune the memory reminders when memory is disabled (the original #670 posture), so runtime never silently diverges from the file. MemoryReminders() remains the single definition used to seed the file and to identify which to prune.
Memory git sync ran silently: the only failure signal for a bad remote was a single "exit status 128" warning that scrolled past at session start, so a misconfigured repo looked like nothing happened. - Surface git's own stderr on an unreachable remote (ls-remote output) instead of the opaque exit code, so "Repository not found" / "Permission denied (publickey)" reaches the log. - Add debug logs across the whole lifecycle - backend selection (git vs local no-op), sync-in start/clone/pull, sync-out start, nothing-to-push, commit, push - and at each trigger seam (chat pre_session, memory-tool mutation, headless pre/post_session) so the actions are greppable when e2e testing.
Once the memory dir was initialized, ensureRepo returned early and never touched the origin remote, so changing memory.backend.git.repo (e.g. switching ssh -> https) was silently ignored: pushes kept going to the URL captured at first init. ensureRepo now reconciles origin to the configured repo on every sync, adding it when missing and updating it when it drifted.
Sync-in ran git pull against an already-initialized memory dir even when the remote branch did not exist yet, failing with "couldn't find remote ref main" and never uploading the local memory. Sync-in now checks the remote first: it pulls only when the branch exists, and otherwise seeds the remote - creating the branch and pushing whatever local memory is present (both for an existing repo and a fresh dir initialized in place). The commit+push path is shared with sync-out via stageCommitPush.
…eOrigin methods in git backend
… adopt) Two robustness gaps in the git memory backend surfaced by review: - Supply a fallback commit identity for whichever of user.name/user.email the ambient git config leaves unset, so sync-out commits succeed in an identity-less environment (a fresh container or CI runner where the channels/scheduler/heartbeat daemon runs) instead of silently failing with "Please tell me who you are". A configured identity - or one from GIT_AUTHOR_*/GIT_COMMITTER_* - is preserved; the fallback only fills a gap. - Adopt an already-populated remote branch on sync-in when the local memory dir already has content (non-git, non-empty): fetch and merge with --allow-unrelated-histories (-X ours) so later push/pull reconcile normally, instead of leaving an unrelated-history repo that can never push or pull.
Memory tools run in the agent's parallel execution pool (Memory never requires approval), so two writes in one turn race the MEMORY.md read-modify-write and the second's atomic rewrite silently drops the first's entry - a file-level loss the -race detector can't see. Guard the index upsert/remove with a package mutex and add a concurrent-writes test that asserts every entry survives (it loses 15 of 16 without the lock).
This was referenced Jul 2, 2026
inference-gateway-releaser Bot
added a commit
that referenced
this pull request
Jul 2, 2026
## [0.127.0](v0.126.0...v0.127.0) (2026-07-02) ### 🚀 Features * **plan:** compact context and start a fresh session when a plan is approved ([#705](#705)) ([28ddba7](28ddba7)) * **memory:** configurable git sync backend ([#707](#707)) ([6a68c3d](6a68c3d)), closes [#670](#670) [#670](#670) * **history:** each subagent gets its own history file ([#711](#711)) ([16c8fa1](16c8fa1)), closes [#699](#699) ### 🐛 Bug Fixes * **plan:** accepting a plan switches to auto-accept mode by default ([#714](#714)) ([7b0befc](7b0befc)), closes [#710](#710) * **tools:** guard concurrent gitignore and screenshot caches ([#713](#713)) ([0ff4276](0ff4276)), closes [#712](#712) * **tools:** guard Registry.tools with RWMutex against concurrent MCP registration ([#709](#709)) ([8a70871](8a70871)), closes [#708](#708) * **ui:** update dim color from [#565f89](https://github.com/inference-gateway/cli/issues/565f89) to [#7a7f9a](https://github.com/inference-gateway/cli/issues/7a7f9a) for improved contrast ([#706](#706)) ([b2ee67e](b2ee67e)) ### 🔧 Build System * **deps:** bump github.com/go-telegram/bot from 1.21.0 to 1.22.0 in the gomod group ([#703](#703)) ([3de5136](3de5136)) * **deps:** bump the github-actions group with 5 updates ([#704](#704)) ([80221f7](80221f7))
Contributor
|
🎉 This PR is included in version 0.127.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This was referenced Jul 3, 2026
inference-gateway-releaser Bot
added a commit
to inference-gateway/infer-action
that referenced
this pull request
Jul 3, 2026
## [0.21.0](v0.20.3...v0.21.0) (2026-07-03) ### Features * support the persistent memory git backend ([#142](#142)) ([c8d9ff7](c8d9ff7)), closes [#140](#140) [cli#707](inference-gateway/cli#707) [#140](#140) [#141](#141) ### Maintenance * **deps:** bump the github-actions group with 2 updates ([#141](#141)) ([81360c0](81360c0))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #670 (persistent agent memory). #670 shipped a local file-based memory — a directory of Markdown fact-files under
~/.infer/memory, catalogued byMEMORY.mdand injected into context at session start. This adds a configurable memory sync backend so that directory can be backed by a git remote: pull on run start, commit + push on change.type: local(the default) preserves today's behavior exactly.Closes #683.
Config (
memory.yaml)Env overrides follow the
INFER_MEMORY_BACKEND_*convention (e.g.INFER_MEMORY_BACKEND_TYPE,INFER_MEMORY_BACKEND_GIT_REPO,INFER_MEMORY_BACKEND_GIT_BRANCH, ...).Design
domain.MemoryBackend(SyncIn/SyncOut) with alocalno-op and agitimplementation, selected by a factory that mirrors the storage backend pattern (internal/infra/memory/).ls-remoteprobe decides clone vs. init-in-place (for an empty remote or pre-existing local memory).git status --porcelain), with a bounded push → pull-rebase → retry loop plus a per-hostflockso concurrent runs (channels / scheduler / heartbeat) don't clobber each other.infer agentpulls on start and pushes at run finish. All best-effort — a sync failure logs and never aborts the run.GIT_*); the backend injects no ssh/env override. A per-op timeout prevents hangs on credential prompts. A warning is logged if the repo URL embeds credentials (they persist in.git/config) — ssh is preferred.Testing
internal/infra/memorybackend tests use a real bare repo as the remote: clone-on-missing, pull-on-present, push-when-dirty, concurrent-push rebase, no-op-when-clean, adopt-empty-remote, sync-in-once, failure-degrades; plus local no-op and factory selection.SyncOutand read does not.INFER_MEMORY_BACKEND_*env-override tests; reminder interval + prune tests.task test,task lint(0 issues), andtask buildall pass.Notes
type: localis a pure no-op — existing users see no change.