muscle-mem  by pig-dot-dev

SDK for caching AI agent behaviors, replaying trajectories for repetitive tasks

Created 4 months ago
746 stars

Top 46.5% on SourcePulse

GitHubView on GitHub
Project Summary

Muscle Memory (muscle-mem) is a Python SDK designed to cache AI agent tool-calling patterns, enabling deterministic replay of learned behaviors for repetitive tasks. It targets developers building AI agents who aim to reduce LLM latency, cost, and variability by replacing LLM calls with cached script executions for known tasks.

How It Works

Muscle-mem operates by wrapping an existing agent. When a task is presented, it first checks its cache for a previously recorded trajectory. On a cache hit, it replays the recorded tool calls. On a cache miss, it delegates the task to the user's agent, records the new trajectory, and stores it for future use. The core innovation lies in its "Checks" mechanism, which allows developers to define custom capture and compare callbacks for specific tools, ensuring cache validation and safe reuse of recorded actions.

Quick Start & Requirements

  • Install via pip: pip install muscle-mem
  • Requires Python.
  • See official examples for detailed usage.

Highlighted Details

  • Reduces LLM calls for repetitive tasks, improving speed and lowering token costs.
  • Supports caching of both standalone functions and methods within classes.
  • Cache validation is configurable via Check objects with custom capture and compare logic.
  • Tool instrumentation uses decorators (@engine.function, @engine.method).

Maintenance & Community

  • Project initiated in May 2025.
  • Active development with an invitation for feedback.
  • Discord community available for discussion.

Licensing & Compatibility

  • The repository does not explicitly state a license in the README.

Limitations & Caveats

  • The project is in its early stages ("unexplored territory") with a recent demo.
  • Cache validation logic requires careful implementation by the developer for each tool.
  • Runtime objects (self) used in methods are not serialized and must be explicitly provided via set_context for replay.
Health Check
Last Commit

3 months ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
14 stars in the last 30 days

Explore Similar Projects

Starred by Alex Yu Alex Yu(Research Scientist at OpenAI; Former Cofounder of Luma AI).

smallville by nmatter1

0%
701
Generative agents for video games
Created 2 years ago
Updated 1 year ago
Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Simon Willison Simon Willison(Coauthor of Django), and
2 more.

tau-bench by sierra-research

1.4%
840
Benchmark for tool-agent-user interaction research
Created 1 year ago
Updated 3 weeks ago
Feedback? Help us improve.