Skip to content

Conditions

Adding condition groups to a rule

Open Protect → Policies → Detection rules (/rule-engine) and select a rule of kind Match to open its detail page. A rule’s matching logic lives in its Condition Groups section there. Conditions are organized into groups: each group has its own AND/OR operator for the conditions inside it, and the rule’s top-level Group Operator (set when you created the rule, editable from Edit Details) decides how the groups themselves are combined.

  • On a rule with no conditions yet, you’ll see “No condition groups yet.” and an Add First Group button.
  • On a rule that already has groups, click Add Group to add another one.
  • Inside a group, click Add Condition to add a condition. Each group shows its own AND/OR choice, labeled “within group”, for combining the conditions inside it.
  • When you’re done, click Save Conditions to persist your changes.

Each condition has three parts:

  • Field - a dropdown. You choose from a fixed list of fields (there’s no way to type an arbitrary custom field name).
  • Operator - a dropdown whose options depend on the field’s data type (string or number - see below). The dropdown shows symbols for comparisons (=, ≠, >, ≥, <, ≤); the tables below also give each operator’s stored name.
  • Value - a text input. Every string field offers suggestions labeled “Top 100 values from traces. Press Enter to add a custom value.” Number fields take a typed number.

All fields come from your trace/telemetry data. Hover the info icon beside a field in the dropdown to see its description.

FieldAttribute it matchesTypeWhat it holds
Service NameServiceNamestringThe service name reported by the SDK
Span NameSpanNamestringThe operation or span name
Span KindSpanKindstringCLIENT, SERVER, INTERNAL and so on
Duration (ms)DurationnumberSpan duration in milliseconds
Status CodeStatusCodestringSpan status: OK, ERROR or UNSET
Deployment Envdeployment.environmentstringDeployment environment, such as production or staging
Service Name (OTel)service.namestringThe OpenTelemetry resource attribute service.name
Gen AI Systemgen_ai.systemstringAI provider identifier, such as openai or anthropic
Modelgen_ai.request.modelstringModel name, such as gpt-4o
Input Tokensgen_ai.usage.input_tokensnumberPrompt (input) tokens used
Output Tokensgen_ai.usage.output_tokensnumberCompletion (output) tokens generated
Total Cost ($)gen_ai.usage.total_costnumberTotal cost of the request in USD
Temperaturegen_ai.request.temperaturenumberSampling temperature used for the request (0–2)
Tool namegen_ai.tool.namestringThe tool name on tool or function-call spans
Tool call namegen_ai.tool.call.namestringThe name of an individual tool invocation
Agent clientcoding_agent.clientstringThe coding agent that sent the span, such as cursor, claude_code or codex
Permission modecoding_agent.policy.permission_modestringThe coding agent’s permission mode, such as default, plan, acceptEdits or bypassPermissions
Content capture modecoding_agent.content_capture_modestringHow much content the collector kept: minimal, metadata_only or full
User classificationcoding_agent.user.classificationstringHow the session was classified: work, personal or disputed
Session outcomecoding_agent.session.outcomestringHow the coding session ended, such as completed, abandoned or cancelled
Agent toolcoding_agent.tool.namestringThe tool name on coding-agent tool spans

A condition is checked against the value the rule is given under the field’s attribute name. When you call the Evaluate API yourself, use the attribute name (for example gen_ai.request.model) as the key in fields.

OperatorDescription
equalsExact match
not_equalsDoes not match
containsSubstring match
not_containsSubstring not present
starts_withPrefix match
ends_withSuffix match
regexRegular expression match
inValue is one of a comma-separated list
not_inValue is not one of a comma-separated list
OperatorDescription
equalsExact numeric match
not_equalsDoes not match numerically
gtGreater than
gteGreater than or equal to
ltLess than
lteLess than or equal to
betweenInclusive range, entered as min,max

Say you want a rule to match requests to a specific, more expensive model where the cost is also high - a candidate for a cost alert:

  1. Click Add First Group (or Add Group if the rule already has one).
  2. Leave the group’s “within group” operator on AND.
  3. Click Add Condition, choose Field = Model, Operator = equals, Value = the model name (e.g. gpt-4).
  4. Click Add Condition again, choose Field = Total Cost ($), Operator = gt, Value = 1000.
  5. Click Save Conditions.

This group now matches any request where Model equals your chosen model AND Total Cost is greater than 1000. If you add a second group, the rule’s top-level Group Operator decides whether both groups must match (AND) or either one is enough (OR).