Expected format absent
This page shows what the Expected format absent rule checks, what it needs, and how to set its pattern so you catch completions that come back in the wrong shape.
Definition
Expected format absent checks each model call's completion against a pattern you write. The rule fails when the completion doesn't match. Use it for any shape the caller depends on, such as a required heading, a table, or a fixed prefix.
Property | Value |
Key |
|
Unit |
|
Check kind | deterministic |
Category | Output integrity |
Default severity |
|
The rule only checks model calls that returned text. A blank completion isn't checked, so it never fails this rule. To catch blank completions, use Empty output.
When a completion fails, the result shows an excerpt of the completion and a summary that names your pattern, for example "completion does not match the expected shape ^## ".
Why it matters
Code that parses a model's answer often expects a fixed shape. When the shape is missing, the call still reports success, but the next step in your application can break or show the user a broken answer. This rule finds those calls, even when nothing else went wrong.
It's a deterministic check, so it makes no model calls of its own.
What it requires
- Traces that contain model calls with completion text. To send traces, see Instrument your code.
- Permission to change rules in the project. See Project permissions.
- A value for the following parameter. It has no default, so you have to enter one before you can save.
Parameter | Required | Default | What it does |
Expected format | Yes | None | A regular expression the completion must match. The rule fails when the completion doesn't match. |
The pattern uses RE2 regular expression syntax. The field label shows "RE2 regex" to remind you. The browser doesn't check the pattern before you save, so test it carefully against real completions.
Configuration examples
To set up the rule:
- On the Rules page, select + New rule.
- On the New rule page, enter
formatin Search templates, and then select Configure › on the Expected format absent card.
- On the Configure rule page, for Project, choose the project this rule watches.
- Check Name. It starts as the template name followed by the project slug. Rule names must be unique, so change it if you plan to create more than one rule from this template.
- For Severity, select a level. The default is MEDIUM.
- For Expected format, enter your pattern. To use one of the examples shown under the field, select it, and it's inserted for you.
- Select Save & enable.
If you leave the pattern empty, the form shows "Expected format is required."
The following table shows the example patterns under the field.
Pattern | The completion must |
| Start with a level-two Markdown heading. |
| Start with |
| Contain a Markdown table row, that is, text between two pipe characters. |
Tip
Scope each rule to a project whose completions really should have this shape. A rule that runs on free-form chat flags almost every answer.
Related
- Missing citation uses a pattern the same way, but checks for a citation marker.
- Banned term in output fails when the completion does match a pattern.
- Output length out of bounds checks the completion's length instead of its shape.
- Empty output catches blank completions, which this rule skips.

Have a suggestion?