Skip to main content

Record and replay LLM agent tool calls for deterministic testing

Project description

toolsnap

Tests Codecov License: MIT

Zero dependency python decorator. 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.0.tar.gz (8.9 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.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: toolsnap-0.1.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.13.9 Windows/11

File hashes

Hashes for toolsnap-0.1.0.tar.gz
Algorithm Hash digest
SHA256 51bdf0af6f6c15427413b4608858cd72129c01cd34e719acbf746b2f48c07b09
MD5 1656c29ca09f1b365c9c9300dff57cb8
BLAKE2b-256 66ba5df55aaeddc27b43f7c725bf961d3be2b04db79efe44cf5b6cad6a15c67f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: toolsnap-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.13.9 Windows/11

File hashes

Hashes for toolsnap-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fffa436ee5a3ff4fa07d7302ecc113d81bef0102344508a876ce6ec300b70915
MD5 347812a5266929f323818523d8941dbc
BLAKE2b-256 65d3cf9b37b5d6b4d9891e9aaf8b1e6a291f94bb37a5c613a92ba73bc882e8ab

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