Skip to main content

agent-memory-kit

Four small, dependency-free memory and safety patterns for LLM agents — no vector database, no framework lock-in. Companion library to the AgentCraft articles "Why Your AI Agent Forgets Things Mid-Task" and "How to Stop an Autonomous Agent From Doing Something Destructive".

pip install -e .

Pattern 1 — Scratchpad state

Facts that must never age out of a truncated context window, re-injected into every prompt.

from agent_memory_kit import ScratchpadState

state = ScratchpadState()
state.set_pref("timezone", "America/Edmonton")
state.record_decision("using SQLite, not Postgres — no ops overhead needed")

system_prompt = f"You are a coding assistant.\n\n{state.render()}"

Pattern 2 — Fuzzy recall

For facts too numerous to keep resident. Starts crude (difflib over a flat JSONL file, zero infra) on purpose — swap in real embeddings later by passing a custom scorer, without changing call sites.

from agent_memory_kit import FuzzyRecall

memory = FuzzyRecall(path="memory.jsonl")
memory.remember("the deploy target changed to Cloudflare Pages")
memory.recall("what is the deploy target?", top_k=3)

Pattern 3 — Pre-compaction checkpointing

If your framework auto-summarizes old turns, don't let it decide unsupervised what survives — extract load-bearing facts into Pattern 1's state first.

from agent_memory_kit import ScratchpadState, CompactionCheckpoint

state = ScratchpadState()

def extract(history):
    # a cheap, targeted LLM call — not shown here
    return {"decisions": ["switched to SQLite"]}

checkpoint = CompactionCheckpoint(state, extractor=extract)
checkpoint.before_compaction(conversation_history=history)
# now safe to let the framework summarize/drop the raw turns

Pattern 4 — Permission boundaries

Classifies actions by reversibility and enforces it in code the model can't talk its way around — not a prompt instruction it can forget.

from agent_memory_kit import ActionTier, PermissionBoundary

boundary = PermissionBoundary()
boundary.register("read_file", ActionTier.AUTONOMOUS, read_file_impl)
boundary.register("send_email", ActionTier.CONFIRM, send_email_impl)
boundary.register("transfer_funds", ActionTier.BLOCKED, transfer_funds_impl)

boundary.execute("send_email", {"to": "a@b.com", "body": "hi"}, get_human_approval=ask_user)
# unknown/unregistered actions default to CONFIRM, never AUTONOMOUS

Which one do you need?

  • A handful of durable facts in a single-session assistant → Pattern 1 alone.
  • A large, persistent corpus (a whole codebase, months of history) → Pattern 2, starting crude.
  • A framework that auto-summarizes and you keep losing specifics → Pattern 3, layered on top of whichever of the first two you're already using.

Most production agents end up running most or all four at once — the first three for memory reliability, Pattern 4 for safety once the agent can act autonomously.

Status

Being published to PyPI now. Not yet on a public GitHub repo — that's still a checkpoint pending sign-off (see agentcraft-site/PLAN.md).

License

MIT

Metadata

Release files for agent-memory-kit 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agent-memory-kit 0.2.0
File Size Uploaded Provenance
agent_memory_kit-0.2.0.tar.gz 8.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for agent-memory-kit 0.2.0
File Interpreter ABI Platform
agent_memory_kit-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.6 kB

Release files / agent_memory_kit-0.2.0.tar.gz

Download URL agent_memory_kit-0.2.0.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
761575e30eb4424acd551309c03111cd750e634deff85254ecaccdc60bf63432
BLAKE2b-256 checksum
How to use checksums
b755dedb84ad793902697c4292d69fef868d32e7d6d7e07371bac55382e1c9fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / agent_memory_kit-0.2.0-py3-none-any.whl

Download URL agent_memory_kit-0.2.0-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a22c66f9109f420783bd38399b902e60cd4d9245ca67ffcc19e77f038d3a04e2
BLAKE2b-256 checksum
How to use checksums
5cacf41ee733834209672096f81ff7836f5b0c58df4b0a0056b6bf44768fe797
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Security for agent-memory-kit 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page