Skip to content

Add git-memory: persistent storage using orphaned git branches#4685

Closed
Copilot wants to merge 4 commits intomainfrom
copilot/memorygit-memory
Closed

Add git-memory: persistent storage using orphaned git branches#4685
Copilot wants to merge 4 commits intomainfrom
copilot/memorygit-memory

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 24, 2025

Implements git-based persistent storage for agentic workflows as an alternative to cache-memory. Uses orphaned git branches prefixed with memory/ to store state across workflow runs with fast-forward merge strategy (ours).

Configuration

Supports boolean, object, and array configurations:

tools:
  git-memory: true  # Creates memory/default branch

  # Custom branch with description
  git-memory:
    branch: memory/audit
    description: Audit workflow state

  # Multiple branches
  git-memory:
    - id: default
      branch: memory/default
    - id: session
      branch: memory/session

Implementation

Core components:

  • pkg/workflow/git_memory.go - Configuration parsing, branch validation, step generation
  • pkg/workflow/git_memory_prompt.go - Agent prompt generation explaining storage capabilities
  • Schema validation enforcing memory/ prefix on all branch names

Workflow steps generated:

  1. Checkout step (before AI execution) - Fetches existing branch or creates orphaned branch with initial commit
  2. Prompt injection - Informs agent about persistent git storage with usage examples
  3. Commit/push step (post-steps, if: always()) - Commits all changes, handles conflicts with merge -X ours

Integration points:

  • Added GitMemoryToolConfig to ToolsConfig struct
  • Added GitMemoryConfig to WorkflowData
  • Registered in built-in tools list (mcp_config_validation.go) to skip MCP validation
  • Schema added to main_workflow_schema.json with pattern validation for branch names

Example Usage

Counter workflow demonstrating persistence:

---
tools:
  git-memory:
    branch: memory/example
---

Check if `counter.txt` exists. If yes, increment the number. If no, create with value 1.
Log each run to `history.log` with timestamp.

Files persist across runs in the orphaned memory/example branch. Merge conflicts resolved automatically using current version.

Original prompt

Add a "git-memory" that is similar to "cache-memory" but uses the git repository as storage.

  • cache name is the branch name
  • if the branch does not exist, create orphaned branch
  • generated branch names are use prefix "memory/"
  • user can specify branch name
  • safe output is only allowed to create branches under the "memory/" route.

Compiler must generate checkout steps and commit/push steps. Apply fast forward merge strategy with take ours or assume current version wins.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits November 24, 2025 17:19
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add git-memory functionality for branch storage Add git-memory: persistent storage using orphaned git branches Nov 24, 2025
Copilot AI requested a review from pelikhan November 24, 2025 17:47
@pelikhan pelikhan closed this Nov 24, 2025
@pelikhan pelikhan deleted the copilot/memorygit-memory branch December 1, 2025 03:40
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.

2 participants