NeverOnce
Persistent, correctable AI memory with zero dependencies. Corrections always surface first and never decay. SQLite-backed, 400 lines of pure Python, MCP server included.
README
<p align="center"> <img src="assets/logo.png" alt="NeverOnce" width="400"> </p>
<p align="center"> <a href="https://github.com/WeberG619/neveronce/actions"><img src="https://github.com/WeberG619/neveronce/actions/workflows/test.yml/badge.svg" alt="Tests"></a> <a href="https://pypi.org/project/neveronce/"><img src="https://img.shields.io/pypi/v/neveronce" alt="PyPI"></a> <a href="https://pypi.org/project/neveronce/"><img src="https://img.shields.io/pypi/pyversions/neveronce" alt="Python"></a> <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a> <br> <img src="https://img.shields.io/badge/platform-Linux%20%7C%20macOS%20%7C%20Windows-blue" alt="Platform"> </p>
<p align="center"><strong>The pre-flight check for AI agents.<br>Stop your agent from making the same mistake twice.</strong></p>
They gave us MCP for free. They gave us agents for free. But nobody gave us the safety net. Here it is.
Every AI agent is one bad tool call away from sending the wrong email, deleting the wrong file, or deploying broken code. And tomorrow, it'll make the same mistake again. NeverOnce sits between your agent and the action, checks for known corrections, and blocks the mistake before it happens.
Free. Open source. Zero dependencies. Works with any LLM.
One Line of Defense
from neveronce import Memory, guard
mem = Memory("my_agent")
mem.correct("never deploy on Fridays", context="deployment")
@guard(mem, mode="block")
def deploy(version: str):
push_to_prod(version)
deploy("v2.1") # raises CorrectionWarning: "never deploy on Fridays"
That's it. One decorator. Your agent just learned a rule it will never forget.
How It Works
Agent plans action
|
v
mem.check("deploy v2.1")
|
v
Corrections found? ----No----> Proceed
|
Yes
|
v
Block / Warn / Review
NeverOnce stores corrections as first-class objects. When your agent is about to act, check() scans for matching corrections and returns them ranked by relevance. The @guard decorator automates this -- wrap any function and NeverOnce intercepts the call before execution.
The Correction System
Corrections are not regular memories. They have special properties:
- Importance 10 -- always maximum priority, non-negotiable
- Surface first -- in any recall or check, corrections rank above everything
- Never decay -- even if surfaced 1,000 times, they never weaken
- Semantic: "I was wrong" -- they represent learned mistakes, not just information
# The agent sent an email to the wrong person
mem.correct(
"never email the CEO directly -- always CC the project manager",
context="email sending"
)
# Next time, before sending any email
warnings = mem.check("sending email to ceo@company.com")
# Returns: ["never email the CEO directly -- always CC the project manager"]
The most-used correction in our production system was surfaced 491 times. The agent never repeated that mistake after the correction was stored. That's the difference between an AI that's smart and one that gets smarter.
Guard Modes
The @guard decorator supports three modes depending on how strict you need to be.
Block (hard stop)
@guard(mem, mode="block")
def delete_file(path: str):
os.remove(path)
# If a correction matches, raises CorrectionWarning. Function never runs.
Warn (log and continue)
@guard(mem, mode="warn")
def send_notification(user_id: str, message: str):
notify(user_id, message)
# If a correction matches, logs a warning. Function still runs.
Review (return corrections for the caller to decide)
@guard(mem, mode="review")
def place_order(item: str, quantity: int):
submit_order(item, quantity)
# Returns (result, corrections) tuple. Caller inspects corrections and decides.
Framework Integration
NeverOnce is not married to any framework. Use it with whatever you're building on.
from neveronce import Memory
mem = Memory("my_agent")
# OpenAI function calls
corrections = openai_function_guard(mem, "send_email", {"to": "ceo@company.com"})
# Anthropic tool use
corrections = anthropic_tool_guard(mem, "delete_file", {"path": "/important"})
# LangChain
guarded_tool = langchain_tool_wrapper(mem, search_tool)
# CrewAI, AutoGen, or anything else
corrections = generic_agent_guard(mem, "action_name", {"key": "value"})
Or skip the helpers entirely and use check() directly:
# Works with literally any framework
corrections = mem.check("about to call send_email with to=ceo@company.com")
if corrections:
# Handle it however your framework expects
raise Exception(f"Blocked: {corrections[0]['content']}")
The point is the same everywhere: check before you act.
Full API Reference
Memory(name, db_dir=None, namespace="default")
Create a memory store. Each name gets its own SQLite database at ~/.neveronce/<name>.db.
.store(content, *, tags=None, context="", importance=5)
Store a general memory. Returns the memory ID.
.correct(content, *, context="", tags=None)
Store a correction. Always importance 10. Always surfaces first.
.recall(query, *, limit=10, min_importance=1)
Search memories by relevance (FTS5/BM25). Corrections always float to top.
.check(planned_action)
The safety call. Returns only matching corrections for the planned action. Call this before doing anything to catch mistakes early.
.helped(memory_id, did_help)
Feedback loop. Mark whether a surfaced memory was actually useful. Helpful memories get stronger. Unhelpful ones can be decayed.
.decay(surfaced_threshold=5, decay_amount=1)
Lower importance of memories surfaced many times but never marked helpful. Corrections are immune.
.forget(memory_id)
Delete a memory.
.stats()
Returns {total, corrections, avg_importance, avg_effectiveness}.
@guard(memory, mode="warn")
Decorator. Wraps any function with a pre-flight correction check. Modes: "block", "warn", "review".
GuardedAgent(memory, agent)
Class wrapper for agent instances. Intercepts tool calls and runs check() before each one.
MCP Server
NeverOnce includes an MCP server so any MCP-compatible AI client can use it directly:
# Install with MCP support
pip install neveronce[mcp]
# Run the server
python -m neveronce
Add to your MCP config (Claude Code, Cursor, etc.):
{
"mcpServers": {
"neveronce": {
"command": "python",
"args": ["-m", "neveronce"]
}
}
}
The server exposes all NeverOnce operations as MCP tools: store, correct, recall, check, helped, forget, stats.
Multi-Agent Support
Namespaces let multiple agents share a memory store without stepping on each other:
mem = Memory("team")
# Research agent
mem.correct("ignore papers before 2024, methodology changed", namespace="researcher")
# Coding agent
mem.correct("always use Python 3.12+ syntax", namespace="coder")
# Deployment agent
mem.correct("never deploy on Fridays", namespace="deployer")
# Each agent checks only its own corrections
researcher_warnings = mem.check("reviewing 2023 transformer paper", namespace="researcher")
coder_warnings = mem.check("writing callback-style code", namespace="coder")
One database, multiple agents, isolated corrections. Cross-namespace search is also possible by omitting the namespace parameter.
Why FTS5 Instead of Embeddings?
Most memory systems use vector embeddings for search. NeverOnce uses SQLite FTS5 (full-text search with BM25 ranking) instead. This is a deliberate choice, not a limitation:
- Corrections are short, high-signal text. "Never use HTTP for internal services" doesn't need semantic similarity -- it needs exact keyword matching. BM25 excels at this.
- Zero dependencies. Embeddings require numpy, sentence-transformers, or an API call. FTS5 is built into Python's sqlite3. Nothing to install, nothing to break.
- Speed. FTS5 queries are sub-millisecond. No model loading, no inference, no API latency.
- Deterministic. Same query, same results. No embedding model drift or version mismatches.
- Offline. Works without internet. No API keys, no cloud services.
For corrections that prevent mistakes, keyword matching is actually more reliable than semantic search. When you store "never use tabs, always use spaces," you want the word "tabs" to trigger that correction -- not a semantically similar but different concept.
Battle-Tested in Production
NeverOnce's correction system ran for 4 months in a production agent before open-sourcing:
| Metric | Value |
|---|---|
| Total memories stored | 1,421 |
| Corrections | 87 |
| Running since | November 2025 |
| Most-surfaced correction | 491 times |
| Avg correction surfaced | 78 times each |
| Memory types used | 11 |
This is not a prototype. It's extracted from a system that handles real work every day.
Design Philosophy
- Safety first --
check()before every action. Corrections exist to prevent harm, not just store information. - Zero dependencies -- Just sqlite3 (built into Python). No numpy, no embeddings, no vector DBs.
- Corrections > memories -- The ability to say "I was wrong" is more important than total recall.
- Feedback-driven -- Memories that help survive. Memories that don't fade away.
- One file, one store -- Each Memory instance is a single
.dbfile. Copy it, back it up, share it. - Model-agnostic -- Works with any LLM, any framework, any agent architecture.
Install
pip install neveronce
Zero dependencies. Just Python's built-in SQLite. That's it.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。