Report Abuse

Basic Information

muscle-mem is a Python SDK that provides a behavior cache for AI agents by recording and deterministically replaying sequences of tool calls when tasks repeat. It wraps an existing agent with an Engine that intercepts tool invocations, stores trajectories into a cache, and replays them on cache hits while falling back to the original agent on cache misses or invalid cases. The project is intended for developers who implement agents in any style and want to avoid unnecessary LLM calls for repetitive work, improving speed, consistency, and reducing token costs. The README emphasizes cache validation via Check objects, instrumentation of tools using decorators, optional context injection for stateful objects, a top-level parameter system for dynamic arguments, and that the API is v0 and installable via pip.

Links

App Details

Features
The repo exposes an Engine that wraps a callable agent and manages a trajectory cache with optional tagging for buckets. Tool instrumentation is provided via decorators: @engine.function for functions and @engine.method for object methods, enabling recording of tool calls. Cache validation is implemented with Check objects that encapsulate capture and compare callbacks for environment feature extraction and matching. A params system marks top-level dynamic arguments so replayed trajectories can accept per-run values. set_context allows dependency injection of runtime objects for replaying method calls. Trajectories are replayed deterministically on cache hits and the system falls back to the agent on misses or failed checks. The package is installable with pip and includes examples demonstrating usage.
Use Cases
muscle-mem helps developers remove repetitive LLM inference from agent execution paths by turning repeatable agent behaviors into cached, script-like trajectories. This reduces latency, lowers token usage and cost, and produces more deterministic outcomes for recurring tasks. The Check mechanism encourages explicit, testable cache validation so tools are only reused when it is safe to do so. Instrumentation decorators make it straightforward to record and replay both stateless functions and stateful methods, and the params system supports per-run variability without losing replay benefits. Because it wraps existing agents rather than replacing them, developers can incrementally add behavior caching to production agents and still fall back to full agent execution when edge cases arise.

Please fill the required fields*