On this page
Sommatic Docs
Open portal

Triage Classifier

Performs hierarchical intake triage with policy-driven decision rules.

View as Markdown
Open in
AI Available ai.classify.triage Version 1.0.0 Execution: async

Classifies an intake item into one category and subcategory of a taxonomy resource with the model, then normalises the answer: probabilities, confidence, routing hints, taxonomy gates and a needs_review flag. Retries transient model failures.

This operator classifies text into a category + subcategory taxonomy, produces confidence and a full probability distribution across categories, generates routing hints, and returns both notes and a longer justification suitable for audits and human review.

Typical use cases

  • Government / legal intake triage (PQRS, tutela, hábeas corpus, etc.)
  • Enterprise incident routing with policy rules
  • Multi-level taxonomy classification with traceable rationale

How it works

  1. Merges the upstream payload with the node config (config wins). Loads categories from knowledge_resource_id (content.structured_data.categories); without it, falls back to an inline taxonomy.categories.
  2. Builds the input: text when it is a non-empty string; otherwise lines Channel:, Sender:, Subject: and Body: from channel, sender, subject and body (or body.data.email.body).
  3. Sends a system prompt with every category, its definition and its flattened subcategory tree, plus general_considerations, decision_rules and routing_hints_catalog, asking for strict JSON, at temperature: 0.
  4. Calls the model with bounded retries on HTTP 5xx, 429 and errors without a status (exponential backoff with jitter).
  5. Parses the answer as JSON (code fences removed, first { to last } as fallback). Matches category case-insensitively to the taxonomy (an unknown name is kept as is) and keeps subcategory only if it belongs to that category.
  6. Applies taxonomy gates: a category or subcategory may declare gate.requires_any_regex / gate.forbids_any_regex (case-insensitive). A failed gate nulls the subcategory (unless on_fail.null_subcategory: false), may set on_fail.set_category / set_subcategory, records it in gate_failed and forces needs_review: true.
  7. Fills missing probabilities with 0, rescales them to sum 1, sets confidence to the chosen category's probability, keeps only catalog routing hints, and routes to success.

In a workflow

The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.

{
  "node_id": "node-triage-intake",
  "label": "Triage intake",
  "operator_slug": "ai.classify.triage",
  "operator_version": "1.0.0",
  "config": {
    "knowledge_resource_id": "<knowledge_resource_id>",
    "subject": "{{ $json.subject }}",
    "body": "{{ $json.body }}",
    "sender": "{{ $json.from }}",
    "channel": "email",
    "general_considerations": [
      "Prefer the most specific category."
    ],
    "decision_rules": [
      "Refund requests are Billing, even when they mention a product."
    ],
    "routing_hints_catalog": [
      "finance-queue",
      "support-queue"
    ],
    "confidence_threshold": 0.7,
    "language": "en",
    "llm_provider_id": "wf-llm-provider-xxxx",
    "invocation_mode": "sync",
    "llm_retry_max_attempts": 3
  }
}

Configuration

knowledge_resource_id string Required

Knowledge resource (type: taxonomy) containing the categories and subcategories for triage.

general_considerations array<string> Optional

High-level rules that should always be considered during triage.

Default: []

decision_rules array<string> Optional

Explicit decision/routing rules (specificity, precedence, exceptions).

Default: []

routing_hints_catalog array<string> Optional

Allowed routing hints that the model may suggest (optional).

Default: []

confidence_threshold number Optional

If confidence is below this threshold, the output will be flagged as needs_review.

Default: 0.7

language string Optional

Language used for notes/justification and interpretation. Example: "es", "en".

Default: es

llm_provider_id string Optional

The `id` of a `LlmProviderModel` record (e.g. `wf-llm-provider-*`). The orchestrator delegates to the backend: `POST /cognitive-infrastructure/cognitive-assets/llm-provider/invoke` for sync mode, or `POST /chat/conversation/execute/stream-ephemeral` (SSE) for stream mode. The backend resolves endpoint + api-key + deployment from the record and routes to the correct adapter (Azure OpenAI, Azure Foundry, OpenAI, AWS Bedrock, Google Vertex, Link Loom Cloud, Generic). Managed in the webapp at `/cognitive-assets/llm-provider/*`.

invocation_mode string Optional

Transport for the LLM call. `sync` opens a short HTTP request and blocks until the full response arrives (ideal for fast inferences: classification, short generation). `stream` consumes tokens via SSE as they arrive (required for long generations or outputs that would exceed the HTTP timeout). Default `sync`.

Default: sync

Allowed values: syncstream

timeout_ms integer Optional

Maximum time to wait for the invocation to complete (or, in stream mode, the idle timeout between chunks). Default 30000 for sync, 600000 for stream.

llm_retry_max_attempts integer Optional

Total attempts for the LLM call on transient failures (HTTP 5xx, 429, network/timeout). 1 disables retry. Falls back to execution.maxTries, then 3. Hard-capped at 5.

Default: 3

llm_retry_backoff_ms integer Optional

Base delay for exponential backoff between LLM retries (wait = base * 2^(attempt-1) + jitter, capped by llm_retry_max_wait_ms). Falls back to execution.waitBetweenTries, then 1500.

Default: 1500

llm_retry_max_wait_ms integer Optional

Ceiling for a single backoff wait between LLM retries. Hard-capped at 30000.

Default: 20000

Supports the shared execution settings: retries (retryOnFail, maxTries, waitBetweenTries) and timeout.

Behaviour in the code

What the implementation does with these keys beyond what the schema says.

llm_retry_max_attempts
Total attempts, hard-capped at 5. When unset: 1 if execution.retryOnFail is false, else execution.maxTries, else 3.
llm_retry_backoff_ms
Base wait, doubled on each retry plus up to 250 ms of jitter. When unset it uses execution.waitBetweenTries, else 1500.
llm_retry_max_wait_ms
Ceiling for one wait, default 20000, hard-capped at 30000.
execution
Unlike other nodes, retryOnFail, maxTries and waitBetweenTries are used here as the fallback retry policy for the model call.
taxonomy
Not declared. Legacy inline taxonomy { categories: [...] }, used only when knowledge_resource_id is empty.
text, subject, body, sender, channel
Not in the config schema, but read from the config first and then from the upstream payload.
confidence_threshold
Used only when the model omits needs_review: then needs_review is confidence < confidence_threshold. A model-provided needs_review wins, except that a failed gate always forces true.
timeout_ms
Stream mode only: idle timeout between chunks, default 600000. In sync mode it is not applied to the request.

Output ports

success default

The model answered valid JSON with a category. needs_review tells you whether a human should check it.

Data
{
  "category": "Billing",
  "subcategory": "Refund",
  "confidence": 0.82,
  "probabilities": {
    "Billing": 0.82,
    "Technical": 0.12,
    "Sales": 0.06
  },
  "routing_hints": [
    "finance-queue"
  ],
  "notes": "Explicit refund request with an order number.",
  "justification": "The sender asks to reverse a charge on a paid order. Billing is more specific than Sales because no new purchase is discussed.",
  "needs_review": false,
  "gate_failed": [],
  "raw": null,
  "port": "success"
}
error

Input or taxonomy is missing, the model call failed after its retries, or the answer was not usable JSON.

Data
{
  "error": "Model did not return valid JSON output"
}

In expressions

What a later node can read from this node's output with $("Triage Classifier").item.json.<path> (write your node's label instead of Triage Classifier). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through success, from the output shown in Ports.

ExpressionEditorWorker
$("Triage Classifier").item.json.categorystring= "Billing"Selected primary category.
$("Triage Classifier").item.json.subcategorystring | null= "Refund"Selected subcategory when applicable, else null.
$("Triage Classifier").item.json.confidencenumber= 0.82Confidence score (0-1) for the selected category.
$("Triage Classifier").item.json.probabilitiesobject= {…}Probability distribution across categories. Values should sum approximately to 1.
$("Triage Classifier").item.json.routing_hintsarray= […] (1)Suggested routing targets / hints to guide downstream workflows.
$("Triage Classifier").item.json.notesstring= "Explicit refund request with an order number."Concise 1-2 line explanation referencing key signals and rules.
$("Triage Classifier").item.json.justificationstring= "The sender asks to reverse a charge on a pai…"Longer justification explaining reasoning and rule precedence.
$("Triage Classifier").item.json.needs_reviewboolean= falseTrue when confidence is below confidence_threshold, output validation is weak, or a taxonomy hierarchy gate failed.
$("Triage Classifier").item.json.gate_failedarray= […] (0)Hierarchy gates that the input did NOT satisfy. A category or subcategory in the taxonomy may declare a gate ({ requires_any_regex, forbids_any_regex, on_fail }); when the input text does not satisfy it, the chosen subcategory is nulled and needs_review is forced. Empty array when no gate failed.
$("Triage Classifier").item.json.rawobject= nullRaw provider response for audit/debug (optional).
$("Triage Classifier").item.json.probabilities.BillingnumberNot suggested by the editor= 0.82—
$("Triage Classifier").item.json.probabilities.TechnicalnumberNot suggested by the editor= 0.12—
$("Triage Classifier").item.json.probabilities.SalesnumberNot suggested by the editor= 0.06—
$("Triage Classifier").item.json.portstringNot suggested by the editor= "success"—

— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).

Errors

Message Port Cause and fix
Missing input content (text/subject/body) error None of text, channel, sender, subject or body has content.
No categories found for triage classification. Ensure the linked knowledge resource contains at least one category. error The taxonomy resource has no structured_data.categories.
Model did not return valid JSON output error The answer could not be parsed as a JSON object. Missing 'category' in output means the JSON had no category.
Knowledge resource not found: <knowledge_resource_id> error The id does not match any knowledge resource. A deleted resource fails with Knowledge resource "<name>" has been deleted. Update the node config to reference an active resource.
[TriageClassifier] Missing 'llm_provider_id' in node config (LlmProviderModel.id, e.g. 'wf-llm-provider-*'). The legacy 'model_id' alias is no longer supported — update the node config to use 'llm_provider_id'. error llm_provider_id is empty or not a string. Pick an LLM provider record with chat capability.
LLM Invocation Error: <backend message> error The backend rejected the call: unknown or inactive provider record, provider error, quota or content filter. Check the provider record and the backend logs.
LLM Invocation Error: empty response from backend (<transport error>) error Sync mode: the HTTP call to the backend failed (network error, non-2xx status or timeout). Long prompts often hit the request timeout; switch to invocation_mode: "stream".
RemoteApiService.stream: idle timeout after <timeout_ms>ms error Stream mode: no chunk arrived within timeout_ms. A failed stream request shows RemoteApiService.stream: HTTP <status> — <body> instead.

Input contract

text string Optional

Primary text content to classify.

subject string Optional

Optional subject line (email/form).

body string Optional

Optional body content.

sender string Optional

Optional sender (email/domain/identifier).

channel string Optional

Optional channel identifier (email, form, api, etc.).

metadata object Optional

Optional arbitrary metadata (headers, tags, etc.).

Output contract

category string Required

Selected primary category.

subcategory string | null Required

Selected subcategory when applicable, else null.

confidence number Required

Confidence score (0-1) for the selected category.

probabilities object Required

Probability distribution across categories. Values should sum approximately to 1.

routing_hints array<string> Optional

Suggested routing targets / hints to guide downstream workflows.

notes string Optional

Concise 1-2 line explanation referencing key signals and rules.

justification string Optional

Longer justification explaining reasoning and rule precedence.

needs_review boolean Optional

True when confidence is below confidence_threshold, output validation is weak, or a taxonomy hierarchy gate failed.

gate_failed array<object> Optional

Hierarchy gates that the input did NOT satisfy. A category or subcategory in the taxonomy may declare a `gate` ({ requires_any_regex, forbids_any_regex, on_fail }); when the input text does not satisfy it, the chosen subcategory is nulled and needs_review is forced. Empty array when no gate failed.

raw object Optional

Raw provider response for audit/debug (optional).

Contracts (JSON Schema)

The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.

{
  "slug": "ai.classify.triage",
  "name": "Triage Classifier",
  "category": "ai",
  "version": "1.0.0",
  "description": "Performs hierarchical intake triage with policy-driven decision rules.\n\nThis operator classifies text into a **category + subcategory** taxonomy, produces **confidence** and a full **probability distribution** across categories, generates **routing hints**, and returns both **notes** and a longer **justification** suitable for audits and human review.\n\n**Typical use cases**\n- Government / legal intake triage (PQRS, tutela, hábeas corpus, etc.)\n- Enterprise incident routing with policy rules\n- Multi-level taxonomy classification with traceable rationale",
  "capabilities": [
    "ai",
    "classification",
    "nlp",
    "taxonomy",
    "triage",
    "routing",
    "explainability"
  ],
  "knowledge_binding": {
    "enabled": true,
    "resource_types": [
      "taxonomy"
    ],
    "field": "knowledge_resource_id",
    "label": "Classification Taxonomy"
  },
  "config_schema": {
    "type": "object",
    "required": [
      "knowledge_resource_id"
    ],
    "properties": {
      "knowledge_resource_id": {
        "type": "string",
        "title": "Classification Taxonomy",
        "description": "Knowledge resource (type: taxonomy) containing the categories and subcategories for triage.",
        "x-ui-widget": "knowledge-resource-picker",
        "x-knowledge-resource-types": [
          "taxonomy"
        ]
      },
      "general_considerations": {
        "type": "array",
        "title": "General Considerations",
        "description": "High-level rules that should always be considered during triage.",
        "items": {
          "type": "string"
        },
        "default": []
      },
      "decision_rules": {
        "type": "array",
        "title": "Decision Rules",
        "description": "Explicit decision/routing rules (specificity, precedence, exceptions).",
        "items": {
          "type": "string"
        },
        "default": []
      },
      "routing_hints_catalog": {
        "type": "array",
        "title": "Routing Hints Catalog",
        "description": "Allowed routing hints that the model may suggest (optional).",
        "items": {
          "type": "string"
        },
        "default": []
      },
      "confidence_threshold": {
        "type": "number",
        "title": "Confidence Threshold",
        "description": "If confidence is below this threshold, the output will be flagged as needs_review.",
        "default": 0.7,
        "minimum": 0,
        "maximum": 1
      },
      "language": {
        "type": "string",
        "title": "Language",
        "description": "Language used for notes/justification and interpretation. Example: \"es\", \"en\".",
        "default": "es"
      },
      "llm_provider_id": {
        "type": "string",
        "title": "LLM Provider",
        "description": "The `id` of a `LlmProviderModel` record (e.g. `wf-llm-provider-*`). The orchestrator delegates to the backend: `POST /cognitive-infrastructure/cognitive-assets/llm-provider/invoke` for sync mode, or `POST /chat/conversation/execute/stream-ephemeral` (SSE) for stream mode. The backend resolves endpoint + api-key + deployment from the record and routes to the correct adapter (Azure OpenAI, Azure Foundry, OpenAI, AWS Bedrock, Google Vertex, Link Loom Cloud, Generic). Managed in the webapp at `/cognitive-assets/llm-provider/*`.",
        "x-ui-widget": "llm-provider-picker",
        "x-llm-provider-capabilities": [
          "chat"
        ]
      },
      "invocation_mode": {
        "type": "string",
        "title": "Invocation Mode",
        "description": "Transport for the LLM call. `sync` opens a short HTTP request and blocks until the full response arrives (ideal for fast inferences: classification, short generation). `stream` consumes tokens via SSE as they arrive (required for long generations or outputs that would exceed the HTTP timeout). Default `sync`.",
        "enum": [
          "sync",
          "stream"
        ],
        "default": "sync"
      },
      "timeout_ms": {
        "type": "integer",
        "title": "Timeout (ms)",
        "description": "Maximum time to wait for the invocation to complete (or, in stream mode, the idle timeout between chunks). Default 30000 for sync, 600000 for stream.",
        "minimum": 1000
      },
      "llm_retry_max_attempts": {
        "type": "integer",
        "title": "LLM Retry — Max Attempts",
        "description": "Total attempts for the LLM call on transient failures (HTTP 5xx, 429, network/timeout). 1 disables retry. Falls back to execution.maxTries, then 3. Hard-capped at 5.",
        "minimum": 1,
        "maximum": 5,
        "default": 3
      },
      "llm_retry_backoff_ms": {
        "type": "integer",
        "title": "LLM Retry — Base Backoff (ms)",
        "description": "Base delay for exponential backoff between LLM retries (wait = base * 2^(attempt-1) + jitter, capped by llm_retry_max_wait_ms). Falls back to execution.waitBetweenTries, then 1500.",
        "minimum": 0,
        "default": 1500
      },
      "llm_retry_max_wait_ms": {
        "type": "integer",
        "title": "LLM Retry — Max Wait (ms)",
        "description": "Ceiling for a single backoff wait between LLM retries. Hard-capped at 30000.",
        "minimum": 0,
        "default": 20000
      },
      "execution": {
        "type": "object",
        "title": "Execution Settings",
        "properties": {
          "alwaysOutputData": {
            "type": "boolean",
            "title": "Always Output Data",
            "description": "Always output data, even on error (if configured).",
            "default": false
          },
          "retryOnFail": {
            "type": "boolean",
            "title": "Retry On Fail",
            "description": "Retry the execution if it fails.",
            "default": false
          },
          "maxTries": {
            "type": "integer",
            "title": "Max Retries",
            "description": "Number of retries.",
            "default": 3,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "waitBetweenTries": {
            "type": "integer",
            "title": "Wait Between Retries (ms)",
            "default": 1000,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "continueOnFail": {
            "type": "boolean",
            "title": "Continue On Fail",
            "description": "Do not crash workflow on error.",
            "default": false
          },
          "timeout_ms": {
            "type": "integer",
            "title": "Timeout (ms)",
            "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
            "default": 300000
          }
        }
      }
    }
  },
  "input_contract_schema": {
    "type": "object",
    "description": "Incoming content and optional metadata used for intake triage.",
    "properties": {
      "text": {
        "type": "string",
        "description": "Primary text content to classify."
      },
      "subject": {
        "type": "string",
        "description": "Optional subject line (email/form)."
      },
      "body": {
        "type": "string",
        "description": "Optional body content."
      },
      "sender": {
        "type": "string",
        "description": "Optional sender (email/domain/identifier)."
      },
      "channel": {
        "type": "string",
        "description": "Optional channel identifier (email, form, api, etc.)."
      },
      "metadata": {
        "type": "object",
        "description": "Optional arbitrary metadata (headers, tags, etc.).",
        "additionalProperties": true
      }
    }
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "category": {
        "type": "string",
        "description": "Selected primary category."
      },
      "subcategory": {
        "type": [
          "string",
          "null"
        ],
        "description": "Selected subcategory when applicable, else null."
      },
      "confidence": {
        "type": "number",
        "description": "Confidence score (0-1) for the selected category."
      },
      "probabilities": {
        "type": "object",
        "description": "Probability distribution across categories. Values should sum approximately to 1.",
        "additionalProperties": {
          "type": "number"
        }
      },
      "routing_hints": {
        "type": "array",
        "description": "Suggested routing targets / hints to guide downstream workflows.",
        "items": {
          "type": "string"
        }
      },
      "notes": {
        "type": "string",
        "description": "Concise 1-2 line explanation referencing key signals and rules."
      },
      "justification": {
        "type": "string",
        "description": "Longer justification explaining reasoning and rule precedence."
      },
      "needs_review": {
        "type": "boolean",
        "description": "True when confidence is below confidence_threshold, output validation is weak, or a taxonomy hierarchy gate failed."
      },
      "gate_failed": {
        "type": "array",
        "description": "Hierarchy gates that the input did NOT satisfy. A category or subcategory in the taxonomy may declare a `gate` ({ requires_any_regex, forbids_any_regex, on_fail }); when the input text does not satisfy it, the chosen subcategory is nulled and needs_review is forced. Empty array when no gate failed.",
        "items": {
          "type": "object",
          "properties": {
            "level": {
              "type": "string",
              "description": "'category' | 'subcategory'"
            },
            "name": {
              "type": "string"
            },
            "reason": {
              "type": "string"
            }
          }
        }
      },
      "raw": {
        "type": "object",
        "description": "Raw provider response for audit/debug (optional).",
        "additionalProperties": true
      }
    },
    "required": [
      "category",
      "subcategory",
      "confidence",
      "probabilities"
    ]
  },
  "ports": [
    {
      "port_id": "success",
      "label": "Classified",
      "is_default": true
    },
    {
      "port_id": "error",
      "label": "Error"
    }
  ],
  "execution_mode": "async",
  "tags": [
    "ai",
    "classifier",
    "triage",
    "taxonomy",
    "routing"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_sommatic_ai",
    "profile": {
      "name": "Sommatic AI",
      "verified": true,
      "url": "https://me.veripass.com/sommatic",
      "logo_url": null
    }
  }
}

Execution

Execution
async
Stateful
No
Retries (retryOnFail)
Yes
Capabilities
aiclassificationnlptaxonomytriageroutingexplainability
Tags
aiclassifiertriagetaxonomyrouting

Notes and limits

  • Missing llm_provider_id and other errors without an HTTP status are also retried, so a configuration error costs every attempt and its waits before failing.
  • gate_failed entries are { level, name, reason }; reason is a fixed Spanish string such as requires_any_regex: ninguno coincidió or forbids_any_regex coincidió: <pattern>. Invalid regex patterns are ignored.
  • language (default es) only sets the language line of the prompt.
  • The worker returns its fields at the top level instead of inside data, so the engine stores the whole return value as the node output: port and raw appear in $json next to the result fields.
  • The model call goes through the Sommatic AI backend, which resolves the provider record named by llm_provider_id (endpoint, credentials, deployment); the orchestrator never holds provider keys. invocation_mode: "sync" (default) waits for the full answer; "stream" reads it as server-sent events and joins the chunks.
  • timeout_ms only takes effect in stream mode, as the idle time allowed between chunks (default 600000). In sync mode the value is logged but not applied to the HTTP request, so the platform's default request timeout governs.
  • In stream mode the backend endpoint does not apply sampling settings, so the fixed temperature: 0 only takes effect in sync mode.
  • The knowledge resource is read from the backend on every run (10 s timeout). A resource whose status is not active is used anyway, with a warning in the log.

Reviewed against the orchestrator code · 31e874b · 2026-11-26

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs