muscle-mem  by pig-dot-dev

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

created 2 months ago
728 stars

Top 48.5% on sourcepulse

GitHubView on GitHub
1 Expert Loves This Project
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

1 month ago

Responsiveness

Inactive

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

Explore Similar Projects

Starred by Omar Sanseviero Omar Sanseviero(DevRel at Google DeepMind) and Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems).

LlamaGym by KhoomeiK

0.3%
1k
SDK for fine-tuning LLM agents with online reinforcement learning
created 1 year ago
updated 1 year ago
Starred by Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), Simon Willison Simon Willison(Author of Django), and
1 more.

tau-bench by sierra-research

2.6%
709
Benchmark for tool-agent-user interaction research
created 1 year ago
updated 3 weeks ago
Feedback? Help us improve.