Agent 错题本 — the error notebook for AI agent tool calls. Remember failures so your agent doesn't repeat them.
Project description
Agent Memory — 错题本
The error notebook for AI agent tool calls.
pip install agent-memory→ one SQLite file → your agent stops repeating mistakes.
Why
Every AI agent hits the same wall: it calls web_search, gets a timeout, retries with the same long query, times out again. With Agent Memory, it learns: "long queries cause timeouts → shorten them." Next time, it gets it right on the first try.
Benchmark (3 tasks × 5 learning rounds):
| Metric | Without Memory | With Memory | Improvement |
|---|---|---|---|
| Trial-and-error fixes (Web Research) | 20 | 5 | -75% |
| Trial-and-error fixes (File Processing) | 20 | 4 | -80% |
| Trial-and-error fixes (API Debugging) | 20 | 5 | -75% |
Memory doesn't just store data — it stores lessons. The agent re-discovers fewer fixes, wastes fewer tokens, and completes tasks faster.
Install
pip install agent-memory
# With optional semantic search:
pip install agent-memory[embed]
# With MCP server:
pip install agent-memory[mcp]
Quick Start
from agent_memory import AgentMemory
mem = AgentMemory("./agent_errors.db")
# Log a tool call outcome
mem.remember(
tool="web_search",
input="GRPO reinforcement learning survey with comparison...",
outcome="fail",
error="timeout",
error_detail="Request timed out after 30s",
fix="shorten query to under 80 chars",
)
# Search relevant past experiences
results = mem.recall("web_search timeout")
for r in results:
print(f"[{r['outcome']}] {r['tool']}: {r['fix']} (confidence: {r['confidence']:.0%})")
# Review memories for manual correction
mem.review(low_confidence_only=True)
# After using a memory, confirm if it helped
mem.confirm(memory_id=1, was_helpful=True)
MCP Server
Use as an MCP server that any agent framework can connect to:
agent-memory serve --db ./agent_errors.db
Add to your MCP client config:
{
"mcpServers": {
"agent-memory": {
"command": "agent-memory",
"args": ["serve", "--db", "./agent_errors.db"]
}
}
}
Available MCP tools: remember, recall, review, forget, confirm, stats.
How It Works
- Remember: Agent logs every tool call — success or failure, with error type and fix
- Store: SQLite with FTS5 trigram tokenizer (English + CJK), time-decay ranking, confidence scoring
- Recall: Agent queries past experiences before making decisions
- Learn: Confidence adjusts based on whether the memory actually helped
No LLM calls — all storage and retrieval is pure rules + SQL. Your agent's LLM only sees the relevant memories as context.
Write Strategy
| What | Strategy |
|---|---|
| Failures | Always remember (error type, detail, fix) |
| Successes | Deduplicated by tool+input hash (count bumps, not duplicate rows) |
| Output size | Truncated to 500 chars (head + tail) |
| Eviction | Oldest low-confidence memories purged at 10K limit |
Anti-Pollution
- Confidence scoring: +0.2 when memory helps, -0.2 when it misleads
- Time decay: Older memories rank lower (configurable half-life, default 30 days)
- Human review:
review()for manual inspection andforget()for removal
Roadmap
| Version | Scope |
|---|---|
| v0.1 | SQLite + FTS5 + remember/recall/review/forget + MCP server |
| v0.2 | Optional semantic search (fastembed) |
| v0.3+ | Graph-based retrieval (only if benchmark proves FTS5 insufficient) |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file errnote-0.1.0.tar.gz.
File metadata
- Download URL: errnote-0.1.0.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd59536448ecfa2c18845cf1b09d1b423532b376da2a1095e220274ad6fd58f1
|
|
| MD5 |
ffb90e097349a7e6234c7242571ee360
|
|
| BLAKE2b-256 |
07459027999d97bf765e42afe11686e8d1936a9a2ae81413f4a85aadb08b64a9
|
File details
Details for the file errnote-0.1.0-py3-none-any.whl.
File metadata
- Download URL: errnote-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3419e550df991f532e431ba2a6d0181123a2093c09b54c61564bc1f40c79ed84
|
|
| MD5 |
697f9b970a038aa0df7d816a31e1dc04
|
|
| BLAKE2b-256 |
0cc020d8f875be8074b1ad50b15814bd412c2ae72458ff089bde9ba0d65d0a1d
|