Module refusal

Module refusal 

Source
Expand description

2026-09-26: Heuristic refusal detector: a prefix matcher over the assistant’s opening text.

Owner: server API. Invariants:

  • detect returns None whenever METRALE_DISABLE_REFUSAL_DETECTION=1.
  • A returned sentence is a leading slice of the input, trimmed, in the model’s original case.

It fills message.refusal on the blocking chat path and the refusal delta on the streaming path, both only when no tool call was found. It is not a safety classifier: it misses refusals that open differently and fires on content that opens by quoting one. /v1/moderations answers 501.

Functions§

detect
2026-09-26: Returns the refusal sentence when content opens with one of the known patterns, else None. The sentence ends at the first ., ? or ! within 512 characters, else at the first newline, and is trimmed. When METRALE_DISABLE_REFUSAL_DETECTION=1, always returns None.