Skip to content

feat: cross-run project memory (.ralph/memory.md) - #277

Merged
rubenmarcus merged 3 commits into
mainfrom
feat/agent-memory
Mar 9, 2026
Merged

feat: cross-run project memory (.ralph/memory.md)#277
rubenmarcus merged 3 commits into
mainfrom
feat/agent-memory

Conversation

@rubenmarcus

Copy link
Copy Markdown
Owner

Summary

  • Adds persistent memory file .ralph/memory.md that survives between runs
  • Memory loaded at loop start and injected into agent context (iteration 1)
  • Run summary (task, result, iterations, cost) auto-saved after each run
  • Agent can also write to .ralph/memory.md to record project conventions
  • Auto-truncated to 8KB to keep context window usage reasonable

How It Works

Run 1: "Fix tests" → agent discovers project uses pnpm, saves to memory
Run 2: "Add auth"  → agent sees memory, immediately uses pnpm

Files Changed

  • NEW src/loop/memory.ts — Read/write/format memory with truncation
  • NEW src/loop/__tests__/memory.test.ts — 6 tests
  • src/loop/executor.ts — Inject memory into context, save run summary
  • src/index.ts — Export SDK API

Test plan

  • All 219 tests pass (6 new + 213 existing)
  • Build passes clean
  • Manual: run twice in same project, verify second run sees memory from first

Closes ENG-1555

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@github-actions

github-actions Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Issue Linking Reminder

This PR doesn't appear to have a linked issue. Consider linking to:

  • This repo: Closes #123
  • ralph-ideas: Closes multivmlabs/ralph-ideas#123

Using Closes, Fixes, or Resolves will auto-close the issue when this PR is merged.


If this PR doesn't need an issue, you can ignore this message.

@github-actions

github-actions Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

✔️ Bundle Size Analysis

Metric Value
Base 2563.98 KB
PR 2576.91 KB
Diff 12.93 KB (0%)
Bundle breakdown
156K	dist/auth
80K	dist/automation
4.0K	dist/cli.d.ts
4.0K	dist/cli.d.ts.map
20K	dist/cli.js
12K	dist/cli.js.map
584K	dist/commands
28K	dist/config
4.0K	dist/index.d.ts
4.0K	dist/index.d.ts.map
4.0K	dist/index.js
4.0K	dist/index.js.map
896K	dist/integrations
100K	dist/llm
1.1M	dist/loop
188K	dist/mcp
60K	dist/presets
92K	dist/setup
40K	dist/skills
392K	dist/sources
76K	dist/ui
144K	dist/utils
336K	dist/wizard

Comment thread src/loop/__tests__/memory.test.ts Fixed
Comment thread src/loop/__tests__/memory.test.ts Fixed
rubenmarcus and others added 3 commits March 9, 2026 14:07
Persistent memory that survives between separate ralph-starter runs:
- Reads .ralph/memory.md at loop start and injects into agent context
- Saves a run summary (task, result, iterations, cost) after each run
- Agent can also write to memory.md to record project conventions
- Auto-truncates to 8KB to keep context usage reasonable

Exported as SDK API: readProjectMemory(), appendProjectMemory()

Closes ENG-1555

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace predictable tmpdir + Date.now() pattern with mkdtempSync
to resolve CodeQL "Insecure temporary file" alert.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The memory test file used mkdirSync but did not include it in the
node:fs import, causing TypeScript compilation to fail.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rubenmarcus
rubenmarcus merged commit f572eb0 into main Mar 9, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants