muscle memory
Project description
Muscle Memory
muscle-mem is a skill cache for AI agents.
It is a Python SDK that records your agent's tool-calling patterns as it solves tasks, and will deterministically replay those learned trajectories whenever the task is encountered again, falling back to agent mode if edge cases are detected.
The goal of muscle-mem is to get LLMs out of the hotpath for repetitive tasks, increasing speed, reducing variability, and eliminating token costs for the many cases that could have just been a script.
This system is inspired by:
- Building computer-use agents at Pig.dev, and realizing users don't want AI, they just want better RPA
- The Voyager paper
- JIT compilers
- Human muscle memory
Dev Log
- May 7, 2025 - First working demo
- May 8, 2025 - Open sourced
How It Works
muscle-mem is not another agent framework.
You implement your agent however you want, and then plug it into muscle-mem's engine.
When given a task, the engine will:
- determine if the environment has been seen before (cache-hit), or if it's new (cache-miss) using
Checks - perform the task, either
- using the retrieved trajectory on cache-hit,
- or passing the task to your agent on cache-miss.
- collect tool call events to add to cache as a new trajectory
It's all about Cache Validation
To add safe tool reuse to your agent, the critical question is cache validation. Ask yourself:
For each tool we give to our agent, what features in the environment can be used to indicate whether or not it's safe to perform that action?
If you can answer this, your agent can have Muscle Memory.
Docs
muscle-mem is a Python SDK to instrument tool calls with custom cache validation functions.
It sits on top of
Prior trajectories are stored in an in-process database
It runs an in-memory database to store prior observations, using
Installation
pip install muscle-mem
Instrumenting your tools
Use the tool decorator to capture all invocations of your action-taking functions.
from muscle_mem import Engine
engine = Engine()
@engine.tool()
def greet(name: str):
print(f"Hello {name}!")
Adding Checks
Checks can be run before, or after, a tool call, to capture data from the engironment at runtime, and compare the current environment against past environments at query time.
Project details
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 muscle_mem-0.0.1.tar.gz.
File metadata
- Download URL: muscle_mem-0.0.1.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a23cf0338e998f87292b7cbb1c5c8fa19fda44654d8f673a19b6aeb027f622fe
|
|
| MD5 |
309a2a9f533a89fbb222aa0228df0fb7
|
|
| BLAKE2b-256 |
41a34849a839622c1b2ba5c653093d4a477a4d0d49581ce4460930df046bcab2
|
File details
Details for the file muscle_mem-0.0.1-py3-none-any.whl.
File metadata
- Download URL: muscle_mem-0.0.1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de25640cf14dde6c9c12e5ec89ce65dfa605a353c92bf9b7384efb2713605a9b
|
|
| MD5 |
239f72de6a7cc52c9fb5a2f3d40e26fe
|
|
| BLAKE2b-256 |
111f35cfdfea0e27578a276f319a9b1b842e9e1724214e1a8d848734baf19c2f
|