Decision 0002 · Accepted · 2026-11-22

Two-stage LLM pipeline: cheap guard, then answer

Context

The bot must answer only questions about one person. The answer call carries the whole knowledge text (thousands of input tokens), so spending it on off-topic or abusive prompts is wasteful and a larger attack surface.

Options considered

  1. One call with a restrictive system prompt: simple, but every abusive prompt pays the full cost and the model alone decides refusals.
  2. Keyword/regex filtering: brittle and easy to bypass.
  3. A small, cheap classifier call (ALLOW/BLOCK) before the answer call.

Decision

Option 3. The guard sees the recent turns and the latest message (not the knowledge text) and is capped at a handful of output tokens. Any guard error counts as BLOCK (fail closed).

Consequences

← 0001 Bind to loopback only, behind a reverse proxy0003 Interfaces at the edges (LLM, store) for testability →