Strips Spectre control tokens from model output before it becomes a user-visible reply.
Prompts teach the model Spectre's routing and planning markup — <al>,
<intent>, <reply> wrappers, INTENT:/AL: control lines — and models
also emit reasoning wrappers (<think>, HTML comments). None of that may
reach the user, and without a core scrubber every host rewrites the same
cleanup. This sanitizer is the runtime default wherever LLM text becomes
reply_text; pass sanitize_reply: false to opt out, or configure an
action planner with a clean_reply/3 callback to take full ownership.
Host-specific cleanup (localized model preambles, channel formatting) stays in the host — this module removes only tokens Spectre itself introduces plus universal reasoning wrappers.
Summary
Functions
Removes Spectre control tokens and reasoning wrappers, then trims.
Functions
Removes Spectre control tokens and reasoning wrappers, then trims.
iex> Spectre.Reply.Sanitizer.sanitize("<think>hmm</think>Hello <al>a1</al>there")
"Hello there"Honors sanitize_reply: false in opts by returning the text trimmed but
otherwise untouched.