CanaryGuard: Sub-millisecond deterministic edge firewall for LangChain agents

Hi LangChain community,

Most agent guardrails (Llama Guard, NeMo) add 500ms–1500ms of latency per turn because they invoke secondary LLMs. For high-frequency agent tool calls or autonomous spending loops, that latency and compute cost adds up fast.

I built CanaryGuard as a deterministic <1ms Layer 1 edge filter designed to sit directly in front of agent tool execution.

How it Works

  1. Chat-Template Delimiter Smuggling: Intercepts [INST], <|im_start|>, and <<SYS>> tokens before context parsing.
  2. Unicode & Evasion Normalization: Runs NFKC normalization and strips concealed zero-width characters (\u200B-\u200F), bidi overrides, and hidden DOM/CSS tags (display:none).
  3. Strict vs Sanitizer Modes:
    • Strict Mode: Hard-blocks instruction overrides and wallet drain commands before tools can execute.
    • Sanitizer Mode: Scrubs the malicious command lines while preserving the surrounding clean data for RAG pipelines.

Benchmark Numbers

  • Ordinary Chat FPR: 0.0%
  • Code / Prompt Templates FPR: 6.7%
  • Detection Recall on Delimiters / Unicode: 100.0%
  • Average Latency: ~1.07ms

Live interactive simulator to test payloads and before/after presets:

Would love feedback from LangChain developers building production agent guardrails!