Defence techniques
Fight injection with several layers:
- Put instructions in the system prompt, never concatenated with data.
- Quote and label user text as
<data>. - Review every tool call before it runs.
- Limit what the agent can access.
No single fix works. Layer them.
The goal is defense in depth.
Data exposure limits
Stop agents leaking sensitive data:
if field in SECRET_FIELDS:
deny_access()
else:
allow()
Never let an agent read a secret just because it asked.
Also scrub outputs before showing them, so model memory doesn't leak credentials or personal data.