Skip to main content

# Sentences Count

The Sentences count guardrail validates that the message content falls within a specified sentence count range. This is useful to ensure that prompts or responses contain a minimum amount of structured content, or to prevent overly verbose outputs.

It can be applied before sending the prompt to the LLM and after to validate the LLM response.

### How it works​

The guardrail splits the message content by sentence-ending punctuation (`.`, `!`, `?`) and counts the resulting segments. If the count falls outside the configured `min` and `max` bounds, the message is blocked.

### Configuration​

    "guardrails": [
      {
        "enabled": true,
        "before": true,
        "after": true,
        "id": "sentences",
        "config": {
          "min": 1,
          "max": 50
        }
      }
    ]

### Field explanations​

- enabled: `true` — The guardrail is active
- before: `true` — The guardrail applies to user input before sending to the LLM
- after: `true` — The guardrail applies to the LLM response

#### Config section​

Parameter | Type | Required | Default | Description
--- | --- | --- | --- | ---
`min` | number | No | `0` | Minimum number of sentences allowed in the message
`max` | number | No | unlimited | Maximum number of sentences allowed in the message

### Guardrail example​

If the LLM generates a response with 60 sentences and the maximum is set to 50, the response will be blocked with:

    This message has been blocked by the 'sentences count' guardrail !