#2327·Guardrails

feature: consistent input-length handling across all rails

Author: m-misiuraCreated Aug 24, 2026Updated Sep 22, 2026
Labelsenhancementstatus: needs triage

Did you check the docs?

  • I have read all the NeMo-Guardrails docs

Is your feature request related to a problem? Please describe.

Every rail that evaluates user input has a finite limit. There are differences across rails when input exceeds this limit ranging from crash, silent truncation, error, delegation to a remote server. It would be prudent to standardise this behaviour. This is non-trivial as rails may be local or remote.

Describe the solution you'd like

Create a shared helper inside utils (e.g. evaluate_with_chunking) that owns chunking, dispatch, and aggregation. Each rail provides only a callback for single-chunk evaluation

The proposed flow would be:

  1. determine max_length (e.g. auto-detect for local models, config for remote/LLM) and define evaluate_fn(chunk)
  2. helper: chunk (token-based if tokenizer available, character-based otherwise) -> dispatch -> if any chunk triggers, block. If max_length is None, calls evaluate_fn once on full text to preserve the current behaviour
  3. rail returns the ChunkedResult

Describe alternatives you've considered

Pre-check and reject: fail-closed across all rails

Additional context

No response