asmemory
Action-State Memory Engine that records typed events (state values and actions) and provides trend, anomaly, causal, and summary analyses via MCP tools. Enables agent self-tracking and operational monitoring with time-series math.
README
asmemory — Action-State Memory Engine
Give your agent a time memory: record what happened and what changed, then analyze trends, anomalies, and causality — not just what was said.
Language: English | 简体中文
⭐ If this helps you, a star is the best way to say thanks — it keeps the project visible to others.
What it does
asmemory stores two kinds of typed events, not raw text:
- State — a value of some entity/metric at a point in time (
gpu.temperature = 78°C) - Action — something that happened (
agent ran training,operator adjusted a valve)
On top of this memory it provides four analyses:
| Analysis | Question it answers |
|---|---|
| Trend | Is my metric going up or down? (slope + direction) |
| Anomaly | Which readings are outliers? (z-score) |
| Causal | Did action X move metric Y? (before/after delta) |
| Summary | What's in my memory? (counts + entities) |
Why asmemory
Most memory plugins store conversations or documents, so they answer "what did you say". asmemory stores actions and states, so it answers "what happened, and why":
"Did GPU temperature rise after training started?" → causal "Is my sleep trending down this week?" → trend "Which readings are outliers?" → anomaly
It is the memory layer for the physical and operational world — agents observing themselves, industrial processes, and personal metrics.
Example: agent self-tracking
Record your agent's own actions and resource states, then ask why the GPU got hot:
from asmemory import StateEvent, ActionEvent, MemoryStore, analysis
store = MemoryStore("memory.db")
store.add_state(StateEvent("gpu", "temperature", 78.5, "celsius"))
store.add_action(ActionEvent("agent", "run_training", "qwen3.6", ts=1723500000))
# Did training actually heat the GPU?
causal = analysis.causal_effect(store, "run_training", "gpu", "temperature")
print(causal["before_mean"], "->", causal["after_mean"], f"(Δ={causal['delta']})")
Real output (24h simulated agent, 72 states + 20 actions):
【因果】run_training → gpu.temperature: 45.3 → 78.7 (Δ=33.4, up) ← significant
【因果对照】git_commit → gpu.temperature: 53.7 → 56.4 (Δ=2.7, up) ← no effect
【异常】ram.usage: 1 outlier (z=-2.4)
The engine cleanly separates real causality (training) from coincidence (git commits) — no LLM guessing involved, just time-series math.
Example: industrial monitoring → DataLens
Air-separation plant: oxygen purity (monitored metric) vs. valve opening (control action). asmemory remembers the causality, then exports to DataLens for over-control optimization:
from asmemory.export import export_datalens
export_datalens(store, entity="oxygen", metric="purity",
action_verb="valve_adjust",
pollutant="氧纯度", regulator="导叶开度",
regulatory_limit=99.5)
# → data_datalens.csv + data_datalens.config.json
Real output (240 min, 240 states + 240 actions):
【因果】valve_adjust → oxygen.purity: Δ=0.0009 (up)
✅ CSV → data_datalens.csv (时间,指标值,控制量,整点标记)
✅ config → data_datalens.config.json (pollutant/regulator/limit)
Open data_datalens.csv in DataLens to visualize the "still over-controlling in the safe zone" savings space.
Tools
Seven MCP tools, exposed to the model as mcp__asmemory__<tool>:
| Tool | What it does |
|---|---|
memory_store_state |
Record a state event (entity / metric / value / unit / tags) |
memory_store_action |
Record an action event (actor / verb / object / amount) |
memory_trend |
Trend direction + slope of a metric |
memory_anomaly |
z-score outlier detection |
memory_causal |
Mean change of a metric before/after an action |
memory_summary |
Library statistics |
memory_export_datalens |
Export CSV + config for DataLens visualization |
Installation
The server runs from the asmemory-mcp command (or an absolute path via ASMEMORY_MCP_PATH). Install the command first, then register the MCP bridge with DSH.
-
Install the
asmemory-mcpcommand:pip install .(Or skip the install and set
ASMEMORY_MCP_PATH=/path/to/bin/asmemory-mcpinstead.) -
Launch DSH with the plugin patch:
dsh web --patch "$PWD/cordis.yml"(Once published, you can also run
dsh plugin add dsh-plugin-asmemory.) -
Done. The server is a single stdio process using only the Python 3.10+ standard library.
Persistence defaults to ~/.asmemory/memory.db (override with ASMEMORY_DB_PATH).
<a id="verified"></a>
Verified
The full loop is tested end-to-end on a real DSH instance (headless profile + a local Qwen3.6 model): the agent called memory_store_state, memory_store_action, and memory_summary, and the events landed in SQLite — exactly the data it was asked to record.
Quick start
python3 examples/demo_agent_self_tracking.py # agent self-tracking demo
python3 examples/demo_datalens_export.py # industrial → DataLens export demo
Use cases
- Agent self-tracking — record the agent's own actions and resource states
- Industrial monitoring — process variables and operator actions (air separation, emission control)
- Personal data — sleep, weight, spending, exercise trends
License
MIT — use it, fork it, ship it. And if it earns you a star-shaped reward in return, all the better. ⭐
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。