Codumentor logo Codumentor

Script Filter Plugin

The Script Filter plugin removes runs of non-Latin characters (CJK, kana, hangul, …) that a model sometimes leaks into otherwise-Latin output. It strips them live during streaming (replacing each run with a placeholder) and, when the turn finishes, optionally translates the removed fragments back into the surrounding language and revises the message in place.

Configuration

plugins:
  - module: codumentor.plugins.script_filter
    class: ScriptFilterPlugin
    priority: 70
    args:
      enabled: true
      scope: both              # both | content | thinking
      placeholder: "□"
      translate: true
      target_language: auto    # 'auto' = match the surrounding text
      request_timeout_seconds: 20.0
      defer_translation: true

Parameters

How It Works

The plugin has no agent tools — it is pure content transformation via two hooks:

  1. onLLMStream (priority 20, early): replaces target-character runs in each streamed delta with the placeholder and caches the removed text, keyed by the turn's run_id.
  2. onBeforeSendResponse (priority 70): when the turn finishes, translates the cached fragments and edits them back into the final message (per segment for multi-segment turns).

When defer_translation is on, the finish-time translation runs as a script_filter_translation background job: it retries with backoff and rewrites both the displayed message (an SSE revision) and the LLM-history placeholder rows.

Notes