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.1.tar.gz (8.7 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.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: toolsnap-0.1.1.tar.gz
  • Upload date:
  • Size: 8.7 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.1.tar.gz
Algorithm Hash digest
SHA256 a4b6b4473750a943749405e787a607571e59037488d357d5930ba2f74b48b4d9
MD5 265f4f7bda267fe31957451854f3124a
BLAKE2b-256 8801337fd812901e0b5cca52cfdfa0894da6c33e22a7938051d4520153882aec

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: toolsnap-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5aed8e979d89e1bd508c844a94eef04c1c6c58148beb6cbe64791fcc8462f608
MD5 f88e229a5a200a53bd9a799ce044712a
BLAKE2b-256 2e99dcf6f3a564359e42c2e3c7ab3da823da30c1e6e41ba57008455975cae154

See more details on using hashes here.

Provenance

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