Skip to main content

shadowlap SDK for Python

Wrap your agent's tools once with their effect, so shadowlap records every call and a replay serves it from the recording instead of running it again.

pip install shadowlap
from shadowlap import tool

@tool(effect="read")
def lookup_order(order_id: str) -> dict:
    return orders.get(order_id)

@tool(effect="write")
def issue_refund(order_id: str, amount: float) -> dict:
    return payments.refund(order_id, amount)

Record and replay with the shadowlap command, which this package installs: it runs the shadowlap CLI from npm at the package's own version (an npm install of that version on your PATH, or npx), so it needs Node.js 22.17 or later, not 23, and says how to get it when there is none.

shadowlap run -- python agent.py    # record a run, with your usual key
shadowlap replay <run>              # a clean replay: 0 upstream requests, no real key

Model calls need no code changes: shadowlap run routes the Anthropic, OpenAI and Gemini SDKs through its sidecar, and captures Azure OpenAI, Gemini Enterprise Agent Platform (Vertex AI) and Bedrock clients inside the process. Outside shadowlap every wrapper is a passthrough, so decorated tools ship unchanged.

  • effect is required: pure (depends only on its arguments), read (reads outside state) or write (changes it). After a fork, read tools run live and a write raises ShadowlapWriteBlocked, unless the replay stubs writes, returning what on_fork gives, or allows them. Coroutine functions, async generators (a streaming tool keeps streaming) and objects with an async __call__ work too, under asyncio, trio and anyio.
  • now(), random() and uuid() record the clock and randomness, so a replay sees the values the run saw.
  • scope() names branches of the agent that run at once, user_input() records what a person types, and trust="untrusted" marks a read for injection tests.
  • A tool that a replay's --fail-at fails raises without running: ShadowlapInjectedTimeout, a TimeoutError, or ShadowlapInjectedHTTPError with the status.
  • Parameters a framework injects, such as a Pydantic AI RunContext or a LangChain config, are left out of the recording. shadowlap.adapters has adapters for the OpenAI Agents SDK, LangChain and LangGraph, CrewAI and Google ADK, and fences the Claude Agent SDK's built-in tools through its hooks. Pydantic AI, LlamaIndex, Microsoft Agent Framework, Strands, smolagents and Agno need none: wrap the function they take with @tool.

Recorded tests

Mark a pytest test, and it records its model and tool calls on its first run, then replays them offline:

import pytest

@pytest.mark.shadowlap
def test_escalates_a_refund_above_the_limit(shadowlap_recording):
    refund_agent("A-1042")
    assert shadowlap_recording.called("escalate") == 1
    assert shadowlap_recording.called("issue_refund") == 0

The shadowlap_recording fixture tells what the agent did: called(name, **args), tool_calls(name=None), calls() and answer(). Recordings go to __recordings__/ beside the test; commit them. SHADOWLAP_RECORD=all records again, and none, the default when CI is set, only replays. Other test runners use with shadowlap.testing.recording(path):. The plugin runs the shadowlap command on your PATH, which this package provides, or the one SHADOWLAP_CLI names.

Python 3.9 or later, no dependencies. The package is typed (py.typed) and passes mypy --strict.

SDKs · Frameworks · Test suites

Metadata

Release files for shadowlap 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shadowlap 0.1.0
File Size Uploaded Provenance Actions
shadowlap-0.1.0.tar.gz 114.1 kB With provenance Details for shadowlap-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for shadowlap 0.1.0
File Interpreter ABI Platform Actions
shadowlap-0.1.0-py3-none-any.whl Python 3 none any Details for shadowlap-0.1.0-py3-none-any.whl

Total release size: 196.9 kB

Release files / shadowlap-0.1.0.tar.gz

Download URL shadowlap-0.1.0.tar.gz
Size 114.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1069e606344a3c03238a59a16e3de393b4e8bd329a060d283330a017bb1583e1
BLAKE2b-256 checksum
How to use checksums
0027bb5987b101d0be089b59ae4cc3b1ff921043f8f383e5d2255910f3386295
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / shadowlap-0.1.0-py3-none-any.whl

Download URL shadowlap-0.1.0-py3-none-any.whl
Size 82.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
94009564414e8c2ce8f562ac502e4c67ecade6659b5ed3783a1d0118c77fc051
BLAKE2b-256 checksum
How to use checksums
93431f2da6c6c09b6af276b7a7f28af5a853ec7c4492b4c324180bc1622a5b15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for shadowlap 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for shadowlap-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page