Skip to content

Add local open-source ATR detection guardrail sample (HookProvider) - #273

Open
eeee2345 wants to merge 1 commit into
strands-agents:mainfrom
eeee2345:add-atr-guardrail-sample
Open

eeee2345 wants to merge 1 commit into
strands-agents:mainfrom
eeee2345:add-atr-guardrail-sample

Conversation

@eeee2345

@eeee2345 eeee2345 commented Jun 14, 2026 •

Copy link
Copy Markdown

This adds a guardrail sample under python/03-integrate/guardrails/, alongside the existing alice-wonderfence, llama-firewall, and nvidia-nemo samples.

What it adds: an ATRGuardrailHook that runs Agent Threat Rules (ATR, https://github.com/Agent-Threat-Rule/agent-threat-rules, MIT) against incoming turns and tool arguments. ATR is an open detection ruleset for AI-agent threats; the pyatr engine matches with pattern rules in-process, so the check needs no API key, no network call, and sends no agent data off the host.

Enforcement points (stable hooks API):

  • BeforeInvocationEvent -> event.cancel when a rule at or above min_severity matches the user turn.
  • BeforeToolCallEvent -> event.cancel_tool when a rule matches the tool arguments.

How it complements the existing samples: WonderFence calls a hosted service; LlamaFirewall and NeMo use model-based scanners. ATR is local and deterministic, which fits data-residency-sensitive deployments and can run as a fast offline first layer.

Status -- opening as a draft on purpose: the detection core and the hook decision logic are tested locally against the real pyatr engine (injection input and injected tool arguments are blocked; benign input and benign tool args are allowed; no false positives on the benign cases). I have not yet run main.py end-to-end against Amazon Bedrock from my own environment, so I am marking this a draft until that live run is confirmed. Happy to do it, or for a maintainer with Bedrock access to verify. Flagging honestly rather than claiming an e2e I have not run.

Edit (2026-10-15): I later moved this out of draft without having done that run. The end-to-end Bedrock run is still unconfirmed.

Files: guardrail.py, main.py, README.md (use-cases template), requirements.txt. Self-contained, no infrastructure to clean up.

Happy to adjust naming, placement, or the enforcement-point choice.

Adds python/03-integrate/guardrails/agent-threat-rules: a HookProvider that
screens agent inputs (BeforeInvocationEvent) and tool calls
(BeforeToolCallEvent) with Agent Threat Rules (ATR, MIT), an open detection
ruleset. Fully local and deterministic (no API key, no network call),
complementing the hosted (WonderFence) and model-based (LlamaFirewall, NeMo)
guardrail samples.

Signed-off-by: Adam Lin <adam@agentthreatrule.org>
@eeee2345
eeee2345 marked this pull request as ready for review June 18, 2026 07:20
@eeee2345

eeee2345 commented Jul 11, 2026 •

Copy link
Copy Markdown
Author

Checking in after a couple of weeks of quiet — no rush, just want to make sure this landed in the right place and isn't blocked on anything I can fix. It's a local, offline HookProvider (no external calls).

Edit (2026-10-15): an earlier version of this comment said it had been tested end-to-end against Bedrock; that was wrong. As the PR description says, the detection core and hook logic are tested locally, and the end-to-end Bedrock run is still unconfirmed.

If AWS prefers a different shape for security-sample contributions, or this isn't the right repo for it, happy to redirect. Otherwise just flagging it's ready whenever someone has bandwidth to take a look.

@eeee2345

Copy link
Copy Markdown
Author

Flagging this one — realising my earlier note did not tag anyone, and I do not want to guess at an individual on an AWS-owned repo. Whoever handles security-sample contributions: it adds a local open-source ATR detection guardrail sample, mergeable against main. If AWS prefers a different shape for security samples, or this is not the right repo, happy to redirect. A clear no is more useful to me than an open PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant