Skip to main content

Record and replay LLM agent tool calls for deterministic testing

Project description

toolsnap

PyPI Version Tests Codecov License: MIT

Record your LLM agent's tool calls once. Replay them deterministically in every test run — no API keys, no network.

Why toolsnap?

LLM agents are non-deterministic at the model level, but their tool call trajectory i.e. which tools they call, in what order, with what arguments is the real testable surface. Existing approaches either hit live APIs on every test run (slow and expensive) or require writing brittle mocks upfront (tedious and disconnected from real behavior).

toolsnap takes a different approach: record first, assert after. Run your agent once against the real APIs, capture every tool call to a JSONL fixture, then replay that fixture in CI forever deterministically, offline, without credentials.


Installation

pip install toolsnap

Quick Start

Step 1: Decorate your tool with @snap

from toolsnap import snap
from strands import tool

@tool
@snap   # auto-saves to fixtures/search.jsonl
def search(query: str) -> list[str]:
    """Search the document store."""
    return real_search_api(query)

Step 2: Run your agent once to record real calls

python main.py
# fixtures/search.jsonl written

Step 3: Replay in tests with @replay

from toolsnap import replay
from strands import tool

@tool
@replay   # reads from fixtures/search.jsonl — no API call
def search(query: str) -> list[str]:
    """Search the document store."""
    ...
# No LLM API key. No database connection. The fixture drives everything.
pytest test.py   # fast, offline, deterministic

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

toolsnap-0.1.3.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

toolsnap-0.1.3-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file toolsnap-0.1.3.tar.gz.

File metadata

  • Download URL: toolsnap-0.1.3.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for toolsnap-0.1.3.tar.gz
Algorithm Hash digest
SHA256 559359ab0056eb1be748b87c61224effa195f9c688909e8a040158b855e7b96a
MD5 1a403a1cf6eb916c7ea2ef35b5132270
BLAKE2b-256 26d55a0f9196c5254dafd141177a297386381792de6cc3a6042c9128b2eb37e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for toolsnap-0.1.3.tar.gz:

Publisher: release.yml on waitasecant/toolsnap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file toolsnap-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: toolsnap-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for toolsnap-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4ce7356442e8efd4383917c69286288e72cb6369e481ceede950c380f3fa513e
MD5 ed0cfa83ef680b8b494f841c63ae894a
BLAKE2b-256 4a32cd497c26549899564c178cc203e48cf371bbcdca5fd430c4e3899aab6409

See more details on using hashes here.

Provenance

The following attestation bundles were made for toolsnap-0.1.3-py3-none-any.whl:

Publisher: release.yml on waitasecant/toolsnap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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