Labels

Auto-apply rules

Automatically label sessions in Fabric Agents based on user messages or the working folder, with optional label values.

A label can carry auto-rules for user messages or the session’s working folder. A pattern rule runs against each user message. When a pattern matches, the label is applied to the session — optionally with a value extracted from the match.

Auto-rules let you keep your inbox organised without manual tagging. Mention a Linear issue key in a message, and a "Linear" label with the issue ID appears on the session automatically. Type [P0] in a message about a hot incident, and a "Priority: P0" label lands.

Message pattern rules

{
  "pattern": "\\b([A-Z]{2,5}-\\d+)\\b",
  "valueTemplate": "$1",
  "description": "Issue keys like CRA-123 or FAB-4567"
}

Fields:

FieldPurpose
patternJavaScript regex. Capture groups get substituted into valueTemplate.
flagsOptional regex flags. Defaults to gi (global, case-insensitive). g is always enforced regardless of what you put here.
valueTemplateTemplate for the extracted value. $1 / $2 / … expand to the matching capture groups. Omit to use the first capture group (or the whole match, if none).
descriptionHuman-readable purpose. Surfaced in the label config UI; doesn't affect matching.

When rules run

Message pattern and semantic rules are triggered when you send a user message (fresh or queued). Folder rules run in the background when a session is created or its working folder changes. Neither kind of trigger includes:

  • Assistant responses.
  • Tool results.
  • Message edits or retries.
  • Label changes made by other means.

What the message regex sees

A pattern rule runs against the last user message text, with code blocks stripped first:

  • Fenced code blocks ( ``` ... ``` ) are removed.
  • Inline code spans (`...`) are removed.

That way The fix for CRA-123 was to rename \isCRA-999`only matchesCRA-123, not CRA-999`. Code is for the agent; tags are for prose.

Typed values

On a plain label (no valueType), a rule applies only the label itself: captures and valueTemplate are ignored, and the label is added once however often, and in whatever case, the pattern matches. Give the label a valueType to store extracted values.

Labels can declare a valueType (string, number, or date). When an auto-rule matches, the captured value is normalised for that type before being attached:

  • string — used as-is.
  • number — parsed as a number. Expansions like 45k → 45000, 1.2m → 1200000 are recognised.
  • date — parsed as an ISO date.

This lets you filter the inbox by numeric priority or chronological range, not just string equality.

Message pattern conflict resolution

Several rules on the same valued label that all match the same message produce one label instance per unique captured value. Duplicates are collapsed by meaning: string values compare case-insensitively (ENG-1 and eng-1 are the same value), links, numbers and dates exactly. A label matched both with and without a value is applied once, with the value, and a value that isn't valid for the label's type (a word on a number label) applies the bare label. Sessions that picked up duplicate spellings or stray values on plain labels in older versions are cleaned up when they load. A hard cap of 10 matches per message prevents runaway tagging from pasted logs.

If two different labels both match, both get applied. Labels don't compete.

Semantic rules

A semantic rule is a yes/no question instead of a regex. The decision model answers it for every user message, and the label is applied when the "yes" probability reaches the threshold. A regex can't express "this message is about billing"; a semantic rule can.

{
  "id": "billing",
  "name": "Billing",
  "autoRules": [
    { "semantic": "Is the user asking about billing, invoices or charges?", "threshold": 0.9 }
  ]
}
PropertyTypeDescription
semanticstringRequired. The yes/no question, in English. Keep it specific.
thresholdnumber"Yes" probability needed to apply the label, 0 < threshold <= 1. Default 0.9.
valuestringFixed value for valued labels (area::mobile-app). Omitted → the plain label is applied.
descriptionstringHuman-readable note.
  • Inert without the decision model — when it is off (or the Semantic label rules switch is), semantic rules are validated and stored but never evaluated.
  • Off the critical path — message pattern rules run before the turn starts; semantic rules run in the background and their labels appear a moment later. Messages shorter than 20 characters are skipped, and so are rules whose label the session already has. A label you removed while the judgment was in flight is not re-added.
  • One kind per rule — a rule has exactly one of pattern, semantic, or folder.
  • Automations fire — a semantic match fires LabelAdd automations like any other label change, which is why the default threshold is high.
  • Privacy — the message (code blocks stripped, cut to 8k characters) is sent to the configured decision provider; every call is logged to ~/.fabric-agent/logs/decisions.jsonl without the text.

From the CLI:

fabric-cli label auto-rule-add billing --semantic "Is the user asking about billing?" --threshold 0.9

Folder rules

Add this entry to the built-in Project label’s autoRules array (valueType: "string"):

{ "folder": "/Projects/([^/]+)$", "valueTemplate": "$1" }

Folder rules run in the background when a session is created or its working folder changes, not when a message is sent or an existing session is loaded. They match the main checkout’s path for a Git repository, even from a subfolder or linked worktree. For example, ~/Projects/fabric-agents and ~/Projects/fabric-agents-wt/slot-1 both get project::fabric-agents. In a bare-repo layout they match the bare repository’s path. Outside Git, they match the folder’s own absolute path. Paths use / separators. If the session has no working folder (none) or Git cannot resolve the current folder, that folder produces no new labels.

flags (default gi), valueTemplate, and description are optional. As with message regexes, omit the template to use the first capture group, or the whole match if there are no groups. The first matching folder rule for each label wins, but only if the session has no entry for that label ID. On a folder change, an entry exactly matching the old folder’s result is eligible for replacement (or removal if the new folder doesn’t match); entries with other values are left alone. If Git cannot resolve the old folder, the last known match from this app run can still be removed. If no earlier result is known, existing entries are kept.

What auto-rules can't do

  • Remove labels based on a message. Message rules add labels but never remove them. Folder rules can replace or remove an earlier folder match when you change folders. For removal based on a message match, use an automation that reacts to a label the match adds.
  • Match on assistant output. Message rules read user messages, and folder rules read paths. Neither reads assistant output.
  • Chain. A rule can't trigger another rule.

Examples

Linear / Jira issue keys

{
  "pattern": "\\b([A-Z]{2,5}-\\d+)\\b",
  "valueTemplate": "$1",
  "description": "Issue keys like CRA-123"
}

Linear issue URLs

{
  "pattern": "linear\\.app/[\\w-]+/issue/([A-Z]+-\\d+)",
  "valueTemplate": "$1",
  "description": "Linear issue URLs"
}

Priority markers

{
  "pattern": "\\[P([0-3])\\]",
  "valueTemplate": "P$1",
  "description": "Priority tags like [P0] or [P2]"
}

ISO dates for a due-date label

{
  "pattern": "\\b(\\d{4}-\\d{2}-\\d{2})\\b",
  "valueTemplate": "$1",
  "description": "ISO dates (YYYY-MM-DD)"
}

If the label's valueType is "date", the captured string is parsed into a date and the inbox can sort chronologically.

Amounts (numeric)

{
  "pattern": "\\$(\\d+(?:[.,]\\d+)?)\\s*([kKmM]?)",
  "valueTemplate": "$1$2",
  "description": "Dollar amounts"
}

With valueType: "number", $45k → 45000 and you can filter "sessions mentioning >$10k".

Hierarchy

Labels can nest — Priority → P0 / P1 / P2, Team → Engineering / Design. Auto-rules on nested labels work exactly the same as on top-level labels; the label config walks the whole tree when it evaluates.

Filtering the inbox by a parent label includes all descendants.

Editing rules

Rules are stored in {workspace}/labels/config.json alongside the labels themselves. Edit through the label editor UI, or edit the JSON directly — the app re-reads the config on each session's message send, so there's no restart needed for tweaks.

  • Labels — creating labels, hierarchy, typed values.
  • Automations — event-driven actions that complement auto-rules (including label removal).
  • Statuses — a parallel organisation axis; often used together with labels.

On this page