Chat Size

Enforce limits on message length and conversation size.

The Chat Size detector enforces limits on individual message length, total number of turns, and cumulative conversation length. Use it to prevent abuse and control costs.

Recommended for Input & Output

Use cases

  • Prevent users from overwhelming the LLM with huge prompts
  • Control token usage and costs
  • Limit conversation length to keep context manageable

Labels

MAX_MESSAGE_LENGTH_EXCEEDED

A single message exceeds the maximum length.

MAX_TURNS_EXCEEDED

Conversation has too many messages.

MAX_CUMULATED_LENGTH_EXCEEDED

Total length of all messages exceeds the limit.

Configuration

Max message length default: 400

Maximum characters per message. Leave empty to disable.

Max turns default: 20

Maximum number of messages in the conversation.

Max cumulated length default: none

Maximum total characters across all messages.

Roles default: user

Which message roles to count toward limits.