Skip to main content
The Anthropic SDK doesn’t have lifecycle hooks, so Benchspan wraps your Claude call with a decorator (Python) or wrapCall helper (TypeScript). Every user and tool message is scanned before the request goes out.

Python

1

Install

2

Decorate the call

claude.py
Use @guard.wrap_async for an async def function.

TypeScript

1

Install

2

Wrap the call

claude.ts

Tool use

Claude’s tool-use loop means tool outputs flow back into the messages array as tool_result blocks. Pass those through as role: "tool" messages so Benchspan scans them:
For scanning tool-result blocks specifically, the simplest pattern is an explicit scan right after the tool runs: