on_tool_end hooks that scan every tool return value before it’s fed back into the model.
Python
1
Install
2
Attach hooks to your agent
agent.py
TypeScript
1
Install
2
Attach hooks
agent.ts
What gets scanned
Every string return value from a tool, via theon_tool_end / onToolEnd hook. The tool’s name is passed through as source so you can see which tools produce the most injections in your dashboard.
User inputs (from Runner.run(agent, input=...)) are not scanned by this hook. To also scan user input, call guard.scan(user_input, role="user") before Runner.run, or use the raw decorator approach from the OpenAI raw SDK integration.