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.2.tar.gz (8.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.2-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: toolsnap-0.1.2.tar.gz
  • Upload date:
  • Size: 8.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.2.tar.gz
Algorithm Hash digest
SHA256 61853bacc49d18052781b03bc504e8e8fa2a9604fab07481f70db155df0825c0
MD5 41982d6bb585194f8b0370b5b1cc7b0e
BLAKE2b-256 3db9ecebb9c0d55211b0d58b2d1dd241d5d69f4e67af74c8e4f73e5055abafb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for toolsnap-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: toolsnap-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.7 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fb30b23f857336a01fa715addee82efcf24aa165143346f829c70d0a04780ec0
MD5 68ac3413d8d8ad3822a5675d6b7d17cf
BLAKE2b-256 5bbae71db66174b07eeedf0102f1455b9d2102526a4e6b7f513acad0949e9a03

See more details on using hashes here.

Provenance

The following attestation bundles were made for toolsnap-0.1.2-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