Tripwire

Stops an LLM response mid-stream the moment a rule matches.

  • TypeScript
  • Node.js
  • Express

The problem

A language model sends its answer one piece at a time, so the user is already reading it while it is still being written. Checking after the whole response is generated is too late; the user has already read it.

How it works

Tripwire tests every streamed chunk and aborts the stream on a match.

  • The streaming layer, in TypeScript on Node.js, reads each chunk as it arrives and runs a set of rules over it.
  • The rules are patterns and structural checks, not a second model, which keeps them cheap enough to run on every chunk.
  • When a rule matches, the stream is cut and the rest of the response never reaches the screen.

It ships as an OpenAI-compatible proxy. Point a client at its POST /v1/chat/completions endpoint instead of the provider's, and responses stream through the guard. An app switches to it by changing one URL.

What it does not do

  • Rules are patterns, not a model, so there is no semantic check in the loop.
  • It catches text that breaks a rule, not a confident wrong answer.
  • A careless pattern can match safe text, so rules need tests of their own.

Links