yekeyu-666/ultron-memory

Project Overview项目介绍

ultron-memory is a lightweight, locally deployable Python component that adds feedback-driven behavior memory and skill self-evolution capabilities to AI agents. It stores user feedback as reusable rules, guardrails, facts, and preferences, and uses hybrid lexical-semantic retrieval to inject relevant memory into subsequent agent context. It never modifies underlying model parameters, and only adjusts the external behavior context of the agent. The host agent remains responsible for the main agent loop, tool calls, permissions, and all model invocation logic. To install, you first create a virtual environment for Python 3.10+, then run pip install -e . to set it up.

ultron-memory separates memory into four categories: rules, guardrails, facts, and preferences, each stored, retrieved, and injected separately. It supports extracting candidate memory entries from user feedback, then a maintainer decides whether to add, merge, or discard the candidate. It uses a hybrid retrieval approach that combines lexical search (SQLite FTS5 or BM25-lite) with optional semantic search via embeddings, then fuses results using Reciprocal Rank Fusion. All changes get immutable versioned records, and memory can be rolled back if negative feedback or repeated failures occur. It also supports replay-based evaluation of memory entries to check performance over time.

While ultron-memory includes a native TypeScript plugin integration for DeepSeek Harness, it can be integrated with any agent framework or host that supports Python callbacks. It is privacy-first by default: full conversation turns are only kept in the current process, and only bounded, desensitized previews are stored in SQLite by default. Credentials like API keys are never intentionally persisted. It requires no extra runtime dependencies beyond Python 3.10+ and SQLite, and is released under the permissive MIT license. To integrate with DSH, you need to manually install the local package and edit your profile configuration.

ultron-memory 是一个轻量可本地部署的 Python 组件,用于为智能 Agent 构建反馈驱动的行为记忆与 Skill 自进化能力。它将用户反馈沉淀为可复用的规则、护栏、事实和偏好,使用词法与语义混合检索注入后续 Agent 上下文,并为每次变更保留不可变版本与来源记录。它不修改模型参数,仅改变 Agent 的外部行为上下文,主 Agent 循环、工具调用、权限和模型调用仍由宿主负责。

它支持从用户反馈中抽取候选记忆,由维护者决定新增、合并或丢弃,将记忆分为规则、护栏、事实、偏好四类分别存储和检索。采用 SQLite FTS5/BM25-lite 词法检索加可选嵌入语义检索,通过 RRF 融合排序,支持版本回滚、评测,隐私优先设计,默认仅持久化脱敏数据,不主动存储凭据。适合需要长期沉淀用户反馈优化 Agent 行为的开发场景。

项目仅依赖 Python 标准库和 SQLite,支持 Python 3.10 及以上版本,可通过创建虚拟环境后 pip 安装运行单元测试验证。它提供了 DeepSeek Harness 的 TypeScript 插件集成,也可被其他任意 Agent 框架宿主调用,遵循 MIT 开源许可证。目前集成 DSH 需要手动安装本地包并修改 profile 配置文件。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 2 warnings2 项注意
  • Only 2 stars - very few users, little community feedback星标只有 2,几乎没人在用,遇到问题缺少社区反馈
  • No DSH plugin manifest detected - it may only carry the dsh-plugin topic, so the install method must be confirmed on the spot未检测到 DSH 插件清单:可能只是打了 dsh-plugin 话题,安装方式要现场确认
  • Not DSH-native: a multi-platform tool that may require Node / Electron or another runtime first非 DSH 原生,是多平台兼容工具:可能要先装 Node / Electron 等运行时
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add ultron-memory-deepseek-harness

把 yekeyu-666/ultron-memory 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

ultron-memory

ultron-memory 是一个轻量、可本地部署的 Python 组件,用于构建反馈驱动的行为记忆与 Skill 自进化能力。

它把用户反馈沉淀为可复用的规则、护栏、事实和偏好,使用词法/语义混合检索注入后续 Agent 上下文,并为每次变更保留不可变版本与来源记录。

注意:本项目改变的是 Agent 的外部行为上下文,不会训练模型参数,也不会让模型发生参数级“自学习”。宿主仍负责主 Agent Loop、工具、权限和模型调用。

特性

  • 反馈进化:从下一轮用户反馈中抽取至多一个候选,并由 Maintainer 决定 add、merge 或 discard。
  • 四类记忆:rule、guardrail、fact、preference 分开存储、检索和注入。
  • 混合检索:SQLite FTS5/BM25-lite 词法检索 + 可选 embedding 语义检索,通过 RRF(Reciprocal Rank Fusion)融合排序。
  • 版本与审计:每个语义变更生成 immutable version,记录 parent、provenance、决策和使用统计。
  • 可回滚:明确负反馈或多个独立硬失败可触发回滚;冲突来源保留,不物理删除历史。
  • 可评测:从 provenance 生成 replay 样本,支持程序规则和可选 LLM Judge,并对比演化前后版本。
  • 隐私优先:默认只持久化有界、脱敏的 pending evidence;凭据不会主动写入存储。
  • 无运行时依赖:使用 Python 标准库和 SQLite,支持 Python 3.10 及以上版本。

安装与快速验证

项目要求 Python 3.10 及以上版本(Python 3.9 不支持本项目使用的 dataclass slots)。推荐在项目目录创建独立虚拟环境;如果本机命令名不是 python3.11,请替换为任意可用的 Python 3.10+ 解释器:

python3.11 -m venv .venv
.venv/bin/python -m pip install -e .
.venv/bin/python -m unittest discover -s tests -v
.venv/bin/python examples/evolution_demo.py

如果本地 Python/SQLite 提供 FTS5,组件会使用 SQLite FTS5;否则自动退回内置的 BM25-lite 风格词法评分器。单实例约 1 万条记录以内不需要向量数据库。

最小集成

宿主只需要提供模型回调;embedding 回调是可选的。未配置 embedding 回调时,记忆会以 bm25 状态正常落库并通过 BM25/FTS 检索;只有已经配置的 embedding 回调调用失败时,新候选才会进入 awaiting_embedding,待服务恢复后重试。

from ultron_memory import EvolutionMemory

memory = EvolutionMemory(
    storage_dir="./.ultron-memory",
    namespace="my-project",
    side_query=side_query,  # async (system_prompt, JSON_payload) -> JSON 字符串
    embed=embed,            # async (text) -> list[float],可选
)

memory.record_turn({
    "conversation_id": "c1",
    "user": "修改 API",
    "assistant": "API 已修改。",
})
await memory.observe_feedback("c1", "每次修改 API 都要更新并运行测试")
retrieval = await memory.retrieve(
    "修改订单 API",
    top_k=3,
    conversation_id="c1",
)
memory.record_outcome("c1", "tests_passed", metadata={"command": "pytest"})
report = await memory.evaluate()
paths = memory.export_skills("./exported-skills")
memory.close()

在真实 Harness 中,应将 retrieval.prompt_context 注入主模型的 system context,并把实际采用的版本传给 record_outcome()。完整生命周期示例见 examples/minimal_harness.py 和 UltronMemoryAdapter。

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-readcache 下一个 Next dsh-command-code-review →