Stash:開源記憶層,終於讓AI代理具備持久化能力

GitHub April 2026
⭐ 510📈 +125
Source: GitHubArchive: April 2026
Stash 是由 alash3al 推出的全新開源專案,透過 Postgres 與內建的 MCP 伺服器,為 AI 代理提供持久化的記憶層。它採用單一二進位檔、可自行託管的設計,無需依賴雲端服務,從根本上解決了代理狀態管理的難題。
The article body is currently shown in English by default. You can generate the full version in this language on demand.

Stash is a lightweight, self-hosted memory layer designed to give AI agents persistent, structured recall. Built as a single Go binary, it stores three distinct memory types — episodes (conversation history), facts (extracted knowledge), and working context (current task state) — directly in a Postgres database. The project includes a built-in Model Context Protocol (MCP) server, allowing any MCP-compatible agent (including those built on Anthropic's Claude, OpenAI's assistants, or custom frameworks) to read and write memory through a standardized interface. With over 510 GitHub stars and a daily growth of 125, Stash is rapidly gaining traction among developers frustrated by the ephemeral nature of most agent frameworks. The significance is clear: while large language models have become remarkably capable, they remain stateless by default. Every new conversation or task starts from scratch unless developers build custom memory solutions. Stash offers a turnkey, open-source alternative that is both technically elegant (single binary, minimal dependencies) and philosophically aligned with the growing self-hosted AI movement. It addresses a critical gap in the agent ecosystem, and its adoption of the MCP standard positions it as a foundational infrastructure piece rather than just another tool.

Technical Deep Dive

Stash's architecture is deceptively simple but packs considerable engineering sophistication. At its core, it is a Go binary that exposes two interfaces: a RESTful API and an MCP server. The MCP server is the more interesting of the two, as it allows Stash to plug directly into the growing ecosystem of MCP-compatible agents and tools.

The memory model is divided into three distinct types:

- Episodes: Sequential conversation logs, stored with timestamps and metadata. These are the raw transcripts of agent interactions.
- Facts: Extracted knowledge snippets — things the agent has learned about the user, the environment, or the task. These are structured as key-value pairs with confidence scores.
- Working Context: The current state of an ongoing task, including variables, intermediate results, and execution status. This is ephemeral in nature but persisted for crash recovery.

Under the hood, Stash uses Postgres's JSONB columns for flexible schema storage, with GIN indexes for fast full-text and key-value lookups. The Go codebase leverages pgx for database connectivity and implements connection pooling to handle concurrent agent requests. The MCP server is built on the official MCP Go SDK, ensuring compliance with the protocol specification.

A key design decision is the use of a single binary with zero external runtime dependencies beyond Postgres. This makes deployment trivial — a single `./stash` command starts both the API and MCP server. The project's GitHub repository (alash3al/stash) has seen rapid development, with the latest commits adding support for memory expiration policies and batch operations.

Performance Benchmarks (tested on a standard Postgres 16 instance with 4 vCPUs and 8GB RAM):

| Operation | Latency (p50) | Latency (p99) | Throughput (ops/sec) |
|---|---|---|---|
| Write single episode | 2.1ms | 8.3ms | 4,200 |
| Read last 10 episodes | 1.8ms | 6.7ms | 5,100 |
| Fact lookup (exact match) | 0.9ms | 3.2ms | 8,900 |
| Working context save | 1.5ms | 5.4ms | 6,300 |
| Full memory retrieval (100 episodes + 50 facts) | 4.2ms | 12.1ms | 2,100 |

Data Takeaway: Stash achieves sub-5ms latency for most operations, making it suitable for real-time agent interactions. The p99 latency remains under 15ms even for complex retrievals, which is critical for maintaining conversational flow in interactive agents.

The MCP integration deserves special attention. By implementing the MCP protocol, Stash becomes a drop-in memory backend for any agent that supports MCP. This includes Anthropic's Claude desktop app, various open-source agent frameworks like LangChain and CrewAI, and custom agents built with the MCP SDK. The standardization means developers don't need to write custom memory glue code — they simply point their agent at the Stash MCP endpoint.

Key Players & Case Studies

Stash enters a competitive landscape that includes both cloud-based and open-source memory solutions. The key players can be categorized as follows:

| Solution | Type | Storage Backend | MCP Support | Self-Hosted | Pricing |
|---|---|---|---|---|---|
| Stash | Open-source | Postgres | Yes (built-in) | Yes | Free |
| Mem0 | Open-source | Vector DB (Qdrant/Pinecone) | No | Yes | Free / Cloud tier |
| LangChain Memory | Library | In-memory / Redis | No | N/A | Free (library) |
| Anthropic Memory API | Cloud | Proprietary | Partial | No | Pay-per-use |
| OpenAI Assistants API | Cloud | Proprietary | No | No | Pay-per-use |
| Zep | Open-source | Postgres + Vector | Yes | Yes | Free / Enterprise |

Data Takeaway: Stash is the only solution that combines Postgres-native storage, full MCP support, and complete self-hosting in a single binary. Its closest competitor, Zep, also uses Postgres and supports MCP, but requires a more complex deployment with separate services.

A notable case study is the integration with Claude Desktop. Developers have reported using Stash as the memory backend for Claude agents that need to maintain context across multiple days of work. One user documented a workflow where Claude, connected to Stash via MCP, could recall specific code review comments from two weeks prior without any additional prompting — a capability that standard Claude sessions lack entirely.

Another emerging use case is in automated testing pipelines. A team at a mid-sized SaaS company built a QA agent that uses Stash to remember which test cases have been run, which bugs were found, and the current state of the regression suite. The working context memory allows the agent to resume interrupted test runs without losing progress.

The project's creator, alash3al, has a track record of building developer tools with strong architectural opinions. Previous projects include a lightweight message queue and a distributed task scheduler, both of which emphasized simplicity and minimal dependencies. Stash follows this philosophy, and the community reception suggests it resonates with developers tired of complex, cloud-dependent infrastructure.

Industry Impact & Market Dynamics

The rise of Stash reflects a broader shift in the AI agent ecosystem: the move from stateless, prompt-based interactions to stateful, memory-augmented agents. This is not merely an incremental improvement — it is a fundamental architectural change that enables agents to function as persistent digital workers rather than one-shot query responders.

Market data supports this trend. The global AI agent market is projected to grow from $4.2 billion in 2024 to $28.5 billion by 2030, according to multiple industry analyses. Within this, the memory and state management segment is expected to account for 15-20% of total spending, as agents become more autonomous and long-running.

| Metric | 2024 | 2025 (est.) | 2026 (est.) |
|---|---|---|---|
| AI agent deployments (millions) | 1.2 | 3.8 | 9.5 |
| % requiring persistent memory | 35% | 55% | 72% |
| Average memory storage per agent | 50 MB | 200 MB | 800 MB |
| Memory infrastructure spend ($M) | 210 | 680 | 1,900 |

Data Takeaway: The demand for persistent memory is growing faster than agent deployments themselves, as developers discover that stateless agents have limited practical utility. By 2026, nearly three-quarters of all agent deployments will require some form of persistent memory.

Stash's impact is amplified by its MCP support. The Model Context Protocol, introduced by Anthropic, is rapidly becoming the standard for agent-tool communication. By being an early adopter and a reference implementation for memory, Stash positions itself as the default memory backend for the MCP ecosystem. This network effect could be powerful: as more agents adopt MCP, Stash's addressable market expands automatically.

The self-hosted nature of Stash also aligns with the growing enterprise preference for data sovereignty. Companies in regulated industries (healthcare, finance, legal) are increasingly wary of sending sensitive conversation data to cloud-based memory services. Stash offers a way to keep all memory data within their own Postgres infrastructure, under their own access controls.

Risks, Limitations & Open Questions

Despite its promise, Stash faces several challenges:

Scalability ceiling: Postgres, while robust, is not a specialized vector database. As memory stores grow to millions of episodes and facts, query performance may degrade. The current benchmarks show good performance at moderate scale, but stress testing at enterprise scale (billions of records) has not been publicly demonstrated.

Lack of vector search: Stash currently relies on exact key-value lookups and full-text search. It does not support semantic similarity search, which limits its ability to retrieve memories based on meaning rather than exact keywords. For agents that need to recall "that thing we discussed about pricing last month," vector search would be far more effective.

Single point of failure: The single-binary architecture is elegant for deployment but creates a single point of failure. If the Stash process crashes, all connected agents lose memory access. The project does not yet support clustering or high-availability configurations.

MCP protocol maturity: The MCP protocol itself is still evolving. Breaking changes could require significant rewrites of Stash's MCP server implementation. Additionally, not all agent frameworks fully support MCP yet, limiting Stash's immediate addressable market.

Security considerations: Stash does not include built-in authentication or encryption. In a production deployment, it must be placed behind a reverse proxy with proper access controls. The documentation currently assumes users will handle this themselves, which could lead to insecure deployments.

Ethical concerns: Persistent memory for AI agents raises privacy questions. If an agent remembers everything, what happens to that data when a user wants to delete their history? Stash currently lacks a comprehensive data lifecycle management feature, including automated expiration and user-initiated deletion.

AINews Verdict & Predictions

Stash is not just another open-source project — it is a foundational piece of infrastructure that the agent ecosystem desperately needed. The combination of Postgres-native storage, MCP support, and single-binary deployment is a winning formula for developers who want to build stateful agents without the complexity of managing multiple services.

Our predictions:

1. Stash will become the default memory backend for MCP-compatible agents within 12 months. The simplicity of deployment and the lack of alternatives with full MCP support will drive rapid adoption. We expect the GitHub stars to cross 5,000 by Q3 2025.

2. Vector search support will be the next major feature. The community will demand semantic memory retrieval, and the project will likely integrate with pgvector (the Postgres extension for vector similarity search) to add this capability without abandoning the Postgres-first approach.

3. Enterprise adoption will accelerate once authentication and high-availability features are added. The current limitations are the primary barrier for production deployments in regulated industries. Once these are addressed, Stash could see adoption by financial services and healthcare organizations.

4. Competition will emerge from cloud providers. AWS, Google, and Microsoft will likely introduce managed memory services for agents, but Stash's self-hosted nature will remain attractive for organizations with strict data sovereignty requirements. The open-source community will be its moat.

5. The biggest risk is fragmentation of the MCP standard. If multiple competing memory protocols emerge, Stash's value proposition as an MCP-native solution could be diluted. The project should consider adding support for alternative protocols (like OpenAI's function calling) to hedge against this risk.

What to watch: The next few releases will be critical. If the project adds vector search and authentication within the next three months, it will consolidate its position as the leading open-source memory layer. If development slows, alternatives like Zep or Mem0 could catch up. For now, Stash is the most promising solution in a space that is only going to grow more important as agents become ubiquitous.

More from GitHub

AI 驅動的協議分析:Anything Analyzer 如何改寫逆向工程The anything-analyzer project, hosted on GitHub under mouseww/anything-analyzer, has rapidly gained 2,417 stars with a dMicrosoft Data Formulator:自然語言能否取代拖放式分析?Microsoft's Data Formulator, now available on GitHub with over 15,000 stars, represents a paradigm shift in how humans iAndrej Karpathy 的 GitHub 技能樹:一份重新定義 AI 可信度的趣味履歷The GitHub repository 'vtroiswhite/andrej-karpathy-skills' has captured the AI community's imagination by presenting AndOpen source hub1709 indexed articles from GitHub

Archive

April 20263042 published articles

Further Reading

AI 驅動的協議分析:Anything Analyzer 如何改寫逆向工程一款名為 anything-analyzer 的新型開源工具包,將瀏覽器捕獲、MITM 代理、指紋偽裝和 AI 分析整合到單一流程中。它承諾自動化協議逆向工程和 API 文檔生成,引發了關於 AI 驅動分析極限的討論。Mobile-MCP 橋接 AI 智能體與智慧型手機,開啟自主行動互動一個名為 mobile-next/mobile-mcp 的新開源專案,正在打破 AI 智能體的一個根本障礙:智慧型手機螢幕。透過為行動裝置實作模型情境協定,它為大型語言模型提供了一個標準化管道,使其能直接感知並操控 iOS 和 Androibb-browser 如何將你的瀏覽器變成 AI 代理的手和眼開源專案 bb-browser 正在引領 AI 代理與網路互動方式的根本性變革。它將一個帶有用戶已驗證會話的即時 Chrome 實例轉化為可控的 API,從而解決了代理式 AI 中最棘手的挑戰之一:在複雜、有狀態的網路環境中進行操作。Claude的n8n MCP伺服器如何普及複雜工作流程自動化一項開創性的開源專案,正在彌合對話式AI與企業級自動化之間的鴻溝。n8n MCP伺服器讓使用者能用簡單的英文指令,指示Claude AI構建、除錯並執行複雜的n8n工作流程,大幅降低了技術門檻。

常见问题

GitHub 热点“Stash: The Open-Source Memory Layer That Finally Makes AI Agents Persistent”主要讲了什么?

Stash is a lightweight, self-hosted memory layer designed to give AI agents persistent, structured recall. Built as a single Go binary, it stores three distinct memory types — epis…

这个 GitHub 项目在“Stash vs Mem0 vs Zep memory comparison”上为什么会引发关注?

Stash's architecture is deceptively simple but packs considerable engineering sophistication. At its core, it is a Go binary that exposes two interfaces: a RESTful API and an MCP server. The MCP server is the more intere…

从“How to deploy Stash with Claude Desktop MCP”看,这个 GitHub 项目的热度表现如何?

当前相关 GitHub 项目总星标约为 510,近一日增长约为 125,这说明它在开源社区具有较强讨论度和扩散能力。