Starts With
Checks whether the agent output begins with a specified prefix string. Supports case-insensitive matching and optional whitespace trimming.
Config
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
value | string | Yes | — | The prefix string to check for |
case_sensitive | boolean | No | false | Enable case-sensitive matching |
trim | boolean | No | true | Trim whitespace from both output and prefix before checking |
Use Cases
- Format enforcement — Ensure agent responses start with a required prefix such as "Answer:", "Summary:", or a JSON opening brace.
- Greeting validation — Verify that customer-facing agents always begin with an appropriate greeting like "Hello" or "Thank you for contacting us".
- Structured output checks — Confirm that outputs begin with expected markers like
{for JSON or<for XML/HTML. - Protocol compliance — Assert that API-facing agents produce responses starting with a specific status prefix or identifier.
Examples
Require a prefix
// Pass if output starts with "Answer:"
{
"value": "Answer:"
}
// Output: "Answer: The capital of France is Paris." → pass
// Output: "The capital of France is Paris." → failCase-sensitive prefix
// Require exact casing
{
"value": "ERROR:",
"case_sensitive": true
}
// Output: "ERROR: Connection failed" → pass
// Output: "error: Connection failed" → failJSON output detection
// Check that output begins with a JSON object
{
"value": "{"
}
// Output: '{"result": "success"}' → pass
// Output: "The result is success" → failScoring
Returns 1.0 (pass) or 0.0 (fail). No intermediate scores. Returns 0.0 if no value is provided in the config.
Performance
Starts With performs a simple prefix check with no external API calls. Execution time is under 1ms regardless of output length, making it ideal for high-volume evaluation pipelines.