Skip to main content
The Google Agent Development Kit (ADK) exposes a before_model_callback / beforeModelCallback hook that fires before every LLM call. Benchspan ships a factory that scans each content part before the Gemini call goes out.

Python

1

Install

2

Register the callback

agent.py

TypeScript

1

Install

2

Register the callback

agent.ts

What gets scanned

Every text part in llmRequest.contents. The role of each content determines how it’s classified: System instructions and pure model completions are skipped; they’re inside your trust boundary.

Handling blocks

In block mode, the callback raises InjectionDetectedError which propagates out of the ADK invocation. Wrap your agent call in a try / except (Python) or try / catch (TypeScript):