Skip to main content

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:

Dev Log



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.

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

muscle_mem-0.0.1.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

muscle_mem-0.0.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

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

Hashes for muscle_mem-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a23cf0338e998f87292b7cbb1c5c8fa19fda44654d8f673a19b6aeb027f622fe
MD5 309a2a9f533a89fbb222aa0228df0fb7
BLAKE2b-256 41a34849a839622c1b2ba5c653093d4a477a4d0d49581ce4460930df046bcab2

See more details on using hashes here.

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

Hashes for muscle_mem-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 de25640cf14dde6c9c12e5ec89ce65dfa605a353c92bf9b7384efb2713605a9b
MD5 239f72de6a7cc52c9fb5a2f3d40e26fe
BLAKE2b-256 111f35cfdfea0e27578a276f319a9b1b842e9e1724214e1a8d848734baf19c2f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page