Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
A cache for AI agents to learn and replay complex behaviors.
| Date | Stars |
|---|---|
| 2026-07-31 | 765 |
| 2026-08-06 | 765 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# Muscle Memory
`muscle-mem` is a behavior 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***.
It's unexplored territory, so all feedback is welcome!
- Read [Muscle Mem - Removing LLM calls from Agents](https://erikdunteman.com/blog/muscle-mem/) for more context
- Join [Muscle Mem discord](https://discord.gg/s84dXDff3K) for feedback
### Dev Log
- May 7, 2025 - [First working demo](https://www.loom.com/share/5936cd9779504aa5a7dce5d72370c35d)
- May 8, 2025 - Open sourced
- June 1, 2025 - Parameterization and Tags merged
<br>
<br>
# 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:
1. determine if the environment has been seen before (cache-hit), or if it's new (cache-miss) using `Checks`
2. perform the task, either
- using the retrieved trajectory on cache-hit,
- or passing the task to your agent on cache-miss.
3. 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.
<br>
<br>
# The API
## Installation
`pip install muscle-mem`
Muscle Mem's API is v0 and will break on minor releases, so we strongly recommend pinning to a specific version for production use.
## Engine
The engine wraps your agent and serves as the primary executor of tasks.
It manages its own cache of previous trajectories, and determines when to invoke your agent.
```python
from muscle_mem import Engine
engine = Engine()
engine.set_agent(your_agent).finalize()
# your agent is independently callable
your_agent("do some task")
# the engine gives you the same interface, but with muscle memory
engine("do some task")
engine("do some task") # cache hit
```
It is expected that your agent is callable, either as a function or with a `__call__` method. Any args and kwargs passed to `engine()` will be directly passed to your agent. Our examples use a string, but it could be a list of ChatCompletion messages or whatever your agent callable expects.
By default, trajectories are stored in a single cache. You may tag trajectories with a description of the task to create unique buckets.
```python
engine("do some task", tags=["some task"]) # cache miss
engine("do some task", tags=["some task"]) # cache hit
engine("do some task", tags=["different task"]) # cache miss
engine("do some task", tags=["different task"]) # cache hit
```
## Tool Instrumentation
Decorators are used to instrument action-taking tools, so that the engine can record actions as your agent takes them.
### Functions
Use the `@engine.function` decorator to instrument a simple function tool:
```python
from muscle_mem import Engine
engine = Engine()
@engine.function()
def hello(name: str):
print(f"hello {name}!")
hello("world") # invocation of hello is stored, with arg name="world"
```
### Methods
Use the `@engine.method` decorator to instrument a method attached to an object.
This allows for dependency injection of stateful API clients via the `self` argument, such as `self.db.get_user(id)` or `self.model.generate(prompt)`.
```python
from muscle_mem import Engine
engine = Engine()
class SomeClient:
@engine.method()
def hello(self, name: str):
print(f"hello {name}!")
Excerpt of 9,307 characters
Read on GitHubErik Dunteman · Butter · United States
56
9
1
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:493d7dd56becc6db, desc:ai agents