Expand description
2nd-layer sanitize: LLM-backed semantic review via Anthropic Messages API.
§Configuration
ANTHROPIC_API_KEY— required. Absent ⇒ no-op (input returned unchanged with an emptyremovedvector).AGENTSEC_LLM_MODEL— optional override for the model id; defaults toclaude-haiku-4-5-20251001.
§Fail-open rationale
On any of (a) missing API key, (b) non-2xx HTTP response, the layer returns the input unchanged. The 1st (regex) layer already removed the obvious markers, so this layer is a defense in depth boost — not the floor of protection. Failing closed here would mean a transient API outage breaks all URL fetches, which is worse than missing a few semantic edge cases.
§Prompt and response
The prompt wraps the body in a <content> tag and asks for a strict
JSON verdict: {"removed": ["span1", "span2", ...]}. The response is
parsed tolerantly (prose / code-fence wrapping is stripped) so a
conversational model output does not break the layer; malformed JSON
degrades silently to no removals.
Functions§
- review
- Run the semantic review layer and return
(cleaned, removed).