Ends With

Checks whether the agent output ends with a specified suffix string. Supports case-insensitive matching and optional whitespace trimming.

Config

FieldTypeRequiredDefaultDescription
valuestringYesThe suffix string to check for
case_sensitivebooleanNofalseEnable case-sensitive matching
trimbooleanNotrueTrim whitespace from both output and suffix before checking

Use Cases

  • Closing statement validation — Ensure agent responses end with a required sign-off such as "Is there anything else I can help with?" or a disclaimer.
  • Format enforcement — Verify that structured outputs end with expected closing markers like } for JSON or </html> for HTML.
  • Punctuation checks — Confirm that responses end with proper punctuation (e.g. a period, question mark, or exclamation mark).
  • Call-to-action validation — Assert that marketing or sales agent responses always end with a specific call-to-action phrase.

Examples

Require a closing question

// Pass if output ends with a follow-up question
{
  "value": "?"
}
// Output: "Your order has been placed. Is there anything else I can help with?" → pass
// Output: "Your order has been placed." → fail

Closing disclaimer

// Ensure disclaimer appears at the end
{
  "value": "This is not financial advice."
}
// Output: "Based on the data, stock X looks promising. This is not financial advice." → pass
// Output: "Based on the data, stock X looks promising." → fail

JSON closing brace

// Check that output ends with valid JSON closing
{
  "value": "}"
}
// Output: '{"status": "ok"}' → pass
// Output: '{"status": "ok"' → fail

Scoring

Returns 1.0 (pass) or 0.0 (fail). No intermediate scores. Returns 0.0 if no value is provided in the config.

Performance

Ends With performs a simple suffix check with no external API calls. Execution time is under 1ms regardless of output length, making it ideal for high-volume evaluation pipelines.

Have questions? Join our community!

Connect with other developers and the 2Signal team.

Join Discord