Skip to main content

Outcome-based persistent memory for AI coding tools (Claude Code, OpenCode)

Project description

Roampal - Outcome-Based Memory for AI Coding Tools

Roampal — Outcome-Based Persistent Memory MCP Server

Tests PyPI Downloads Stars License Python Discord roampal-core MCP server

Two commands. Your AI coding assistant gets outcome-based memory.
Works with Claude Code and OpenCode.


Why?

AI coding assistants forget everything between sessions. You explain your architecture, your preferences, your conventions — again. When they give bad advice, there's no mechanism to learn from it.

Roampal is an MCP server that gives your AI persistent, outcome-based memory across every session. Good advice gets promoted. Bad advice gets demoted. Your AI learns what works and what doesn't — automatically, with zero workflow changes.


Quick Start

pip install roampal
roampal init

Auto-detects installed tools. Restart your editor and start chatting.

Target a specific tool: roampal init --claude-code or roampal init --opencode

roampal init demo

Platform Differences

The core loop is identical — both platforms inject context, capture exchanges, and score outcomes. The delivery mechanism differs:

Claude Code OpenCode
Context injection Hooks (stdout) Plugin (system prompt)
Exchange capture Stop hook Plugin session.idle event
Scoring Main LLM via score_memories tool Independent sidecar (your chosen model > Zen free)
Self-healing Hooks auto-restart server on failure Plugin auto-restarts server on failure

Claude Code prompts the main LLM to score each exchange via the score_memories tool. OpenCode never self-scores — an independent sidecar (a separate API call) reviews each exchange as a third party, removing self-assessment bias. The score_memories tool is not registered on OpenCode. During roampal init or roampal sidecar setup, Roampal detects local models (Ollama, LM Studio, etc.) and lets you choose a scoring model. If configured, these take priority (Zen is skipped for privacy). A cheap or local model works great — scoring doesn't need a powerful model. Defaults to Zen free models (remote, best-effort) if you skip setup.

How It Works

When you type a message, Roampal automatically injects relevant context before your AI sees it:

You type:

fix the auth bug

Your AI sees:

═══ KNOWN CONTEXT ═══
• JWT refresh pattern fixed auth loop [id:patterns_a1b2] (3d, 90% proven, patterns)
• User prefers: never stage git changes [id:mb_c3d4] (memory_bank)
═══ END CONTEXT ═══

fix the auth bug

No manual calls. No workflow changes. It just works.

The Loop

  1. You type a message
  2. Roampal injects relevant context automatically (hooks in Claude Code, plugin in OpenCode)
  3. AI responds with full awareness of your history, preferences, and what worked before
  4. Outcome scored — good advice gets promoted, bad advice gets demoted
  5. Repeat — the system gets smarter every exchange

Five Memory Collections

Collection Purpose Lifetime
working Current session context 24h — promotes if useful, deleted otherwise
history Past conversations 30 days, outcome-scored
patterns Proven solutions Persistent while useful, promoted from history
memory_bank Identity, preferences, goals Permanent
books Uploaded reference docs Permanent

Commands

roampal init                # Auto-detect and configure installed tools
roampal init --claude-code  # Configure Claude Code explicitly
roampal init --opencode     # Configure OpenCode explicitly
roampal init --no-input     # Non-interactive setup (CI/scripts)
roampal start               # Start the HTTP server manually
roampal stop                # Stop the HTTP server
roampal status              # Check if server is running
roampal status --json       # Machine-readable status (for scripting)
roampal stats               # View memory statistics
roampal stats --json        # Machine-readable statistics (for scripting)
roampal doctor              # Diagnose installation issues
roampal summarize           # Summarize long memories (retroactive cleanup)
roampal score               # Score the last exchange (manual/testing)
roampal context             # Output recent exchange context
roampal ingest <file>       # Add documents to books collection
roampal books               # List all ingested books
roampal remove <title>      # Remove a book by title
roampal sidecar status      # Check scoring model configuration (OpenCode)
roampal sidecar setup       # Configure scoring model (OpenCode)
roampal sidecar disable     # Remove scoring model configuration (OpenCode)

MCP Tools

Your AI gets these memory tools:

Tool Description Platforms
search_memory Deep search across all collections Both
add_to_memory_bank Store permanent facts (identity, preferences, goals) Both
update_memory Correct or update existing memories Both
delete_memory Remove outdated info Both
score_memories Score previous exchange outcomes Claude Code
record_response Store key takeaways from significant exchanges Both

How scoring works: Claude Code's hooks prompt the main LLM to call score_memories every turn. OpenCode uses an independent sidecar that scores silently in the background — the model never sees a scoring prompt and score_memories is not registered as a tool. If the sidecar is unavailable, a warning prompts the user to run roampal sidecar setup. Choose your scoring model during roampal init or via roampal sidecar setup.

What's Different?

Without Roampal With Roampal
Forgets everything between sessions Remembers you, your preferences, what worked
You repeat context every time Context injected automatically
No learning from mistakes Outcomes tracked — bad advice gets demoted
No document memory Ingest docs, searchable forever

Benchmarks

Tested across 10 adversarial scenarios designed to trick similarity search (200 total tests):

Condition Top-1 Accuracy
RAG baseline (vector search only) 10%
+ Cross-encoder reranking 20%
Full Roampal (outcomes + reranking) 10% → 60% at maturity

Outcome learning provides a 5x improvement over reranking alone (+50 pts vs +10 pts). Roampal vs plain vector DB: 40% vs 0% accuracy on adversarial queries (p=0.000135).

Full benchmark data: dev/benchmarks/results/

How Roampal Compares

Feature Roampal Core .cursorrules / CLAUDE.md Mem0
Learns from outcomes Yes — bad advice demoted, good advice promoted No No
Zero-config context injection Yes — injected automatically (hooks or plugin) Manual file editing API calls required
Works across sessions Yes — 5 memory collections with promotion Per-project static files Yes
Fully local / private Yes — all data on your machine Yes Cloud or self-hosted
Open source Apache 2.0 N/A Apache 2.0
Architecture
┌─────────────────────────────────────────────────────────┐
│  pip install roampal && roampal init                    │
│    Claude Code: hooks + MCP → ~/.claude/                │
│    OpenCode:    plugin + MCP → ~/.config/opencode/      │
└─────────────────────────────────────────────────────────┘
                         │
                         ▼
┌─────────────────────────────────────────────────────────┐
│  HTTP Hook Server (port 27182)                          │
│    Auto-started on first use, self-heals on failure     │
│    Manual control: roampal start / roampal stop         │
└─────────────────────────────────────────────────────────┘
                         │
                         ▼
┌─────────────────────────────────────────────────────────┐
│  User types message                                     │
│    → Hook/plugin calls HTTP server for context          │
│    → AI sees relevant memories, responds                │
│    → Exchange stored, scored (hooks or sidecar)         │
└─────────────────────────────────────────────────────────┘
                         │
                         ▼
┌─────────────────────────────────────────────────────────┐
│  Single-Writer Backend                                  │
│    FastAPI → UnifiedMemorySystem → ChromaDB             │
│    All clients share one server, isolated by session    │
└─────────────────────────────────────────────────────────┘

See dev/docs/ for full technical details.

Requirements

  • Python 3.10+
  • One of: Claude Code or OpenCode
  • Platforms: Windows, macOS, Linux (primarily developed and tested on Windows)

Troubleshooting

Hooks not working? (Claude Code)
  • Restart Claude Code (hooks load on startup)
  • Check HTTP server: curl http://127.0.0.1:27182/api/health
MCP not connecting? (Claude Code)
  • Verify ~/.claude.json has the roampal-core MCP entry with correct Python path
  • Check Claude Code output panel for MCP errors
Context not appearing? (OpenCode)
  • Make sure you ran roampal init --opencode
  • Check that the server auto-started: curl http://127.0.0.1:27182/api/health
  • If not, start it manually: roampal start
Server crashes and recovers?

This is expected. Roampal has self-healing -- if the HTTP server stops responding, it is automatically restarted and retried.

Still stuck? Ask your AI for help — it can read logs and debug Roampal issues directly.

Support

Roampal Core is completely free and open source.

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

roampal-0.4.3.tar.gz (246.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

roampal-0.4.3-py3-none-any.whl (273.3 kB view details)

Uploaded Python 3

File details

Details for the file roampal-0.4.3.tar.gz.

File metadata

  • Download URL: roampal-0.4.3.tar.gz
  • Upload date:
  • Size: 246.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for roampal-0.4.3.tar.gz
Algorithm Hash digest
SHA256 42cbf8fb35fc003b43661ecf7631928b0badcc8286e240bc859759e5ed07f80d
MD5 a2b738edbc4a8801a5c00d2f4309bc4b
BLAKE2b-256 ca1188df03b7be0f6e96c9145857700c597dd477640fe18a1aa99ca9d5e05324

See more details on using hashes here.

File details

Details for the file roampal-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: roampal-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 273.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for roampal-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d10067a1c47a4b0ff586caaafabf85140f4cdc575ee0770c82129790d1d818d7
MD5 500125f3226d4d95101a967c41153a4a
BLAKE2b-256 2b7a100418c26e216ed59bd5ab0849b7fc0ed22f4a51e1b42c0dbcf01def24fe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page