Criteria Expression Builder
The Criteria Expression Builder is a pre-built specialized agent that takes extraction rows (each carrying a question, answer, and source citation) plus reference documents and a location lookup table, and produces structured expression JSON for each row. For every row it synthesizes a named criterion — a human-readable name, description, validity dates, and an expressionJson field whose state and country references are resolved to concrete location IDs.
It belongs to the Custom Agents group: a set of pre-built, externally dispatched agents you select by ID instead of configuring an LLM loop yourself. Like every agent in this group, it runs as a Custom agent (custom_agent) — the agent service forwards the node's inputs to the custom-action service, which executes the agent and returns its output. See Custom Agent for how the custom_agent dispatch mechanism works.
Availability. This agent is environment-gated and is currently enabled in local and development only. If you don't see Criteria Expression Builder in the custom-agent list for your environment, it isn't enabled there.
When to use it
Use the Criteria Expression Builder when you have extracted policy or rule statements that reference jurisdictions (US states, countries) and you need to convert them into a structured, machine-resolvable expression — for example, turning "applies to employees in California and New York" into an expression whose location references are concrete IDs drawn from your lookup table. It pairs naturally downstream of an Extraction agent and, optionally, the Multilingual Translation Agent, whose translated-row grouping it preserves.
Configuration
Add the agent to a workflow as a Custom agent and pin it by ID in agent_config.type_config:
{ "custom_agent_id": "adp_criteria_expression_builder" }
You then wire the node's inputs through the node's input_mapping. The agent reads the following input keys.
| Input key | Required | Purpose |
|---|---|---|
extraction_columns | Yes | The rows to process. Each row is an object with question, answer, and source_citation fields. Accepted either as a JSON-serialized array string or as an already-parsed array. |
criteria_lookup_data | Yes | JSON lookup data the agent uses to resolve state and country names to location IDs. The run fails with a validation error when it is missing. |
documents | Yes in practice | The reference documents the agent searches when synthesizing each criterion. Each entry is an object (or a plain string, which is wrapped as {"content": "…"}). When omitted, every row is returned with empty criteria fields rather than synthesized output. |
expression_templates | No | JSON expression templates keyed by criteria type and operation. They shape the generated expressionJson. |
selected_models | No | JSON-serialized array (or list) of EmaFusion™ model IDs to use for synthesis. Omit to use the default. |
The agent only resolves the state and country location fields.
Translation grouping is preserved. When rows carry a duplicate_answer_id (as produced by the Multilingual Translation Agent), the agent synthesizes the criterion once for the primary row in each group and applies the result to every translated row in that group, rather than calling the LLM per translation.
Output
The agent returns an object with a single rows key. Every input row is preserved in order and augmented with the synthesized criteria fields:
| Added field | Meaning |
|---|---|
criteria_name | Auto-generated human-readable name for the criterion. |
criteria_description | Description of what the criterion covers. |
criteria_expression | The expression in source form. |
criteria_valid_from | Start of the criterion's validity window. |
criteria_valid_to | End of the criterion's validity window. |
criteria_expression_json | The structured expression JSON with state and country references resolved to location IDs. |
criteria_trace | A trace of the synthesis for debugging. |
When synthesis produces nothing for a row (or when no documents were supplied), these fields are present but empty, so the row count and ordering always match the input.
Example
A node configured as:
{ "custom_agent_id": "adp_criteria_expression_builder" }
with these inputs:
{
"extraction_columns": "[{\"question\": \"Which states require paid sick leave?\", \"answer\": \"California and New York require paid sick leave.\", \"source_citation\": \"policy.pdf p.4\"}]",
"criteria_lookup_data": "{ \"states\": [ {\"name\": \"California\", \"id\": \"US-CA\"}, {\"name\": \"New York\", \"id\": \"US-NY\"} ] }",
"documents": "[{\"content\": \"Paid sick leave is mandated in California and New York…\"}]"
}
returns:
{
"rows": [
{
"question": "Which states require paid sick leave?",
"answer": "California and New York require paid sick leave.",
"source_citation": "policy.pdf p.4",
"criteria_name": "Paid Sick Leave — CA, NY",
"criteria_description": "States requiring paid sick leave.",
"criteria_expression": "state in (California, New York)",
"criteria_valid_from": "",
"criteria_valid_to": "",
"criteria_expression_json": "{ \"state\": [\"US-CA\", \"US-NY\"] }",
"criteria_trace": "…"
}
]
}
Because the output is a flat rows array, a downstream node reads it via {{<node_id>.output.rows}}, and a publish node can write the augmented rows back to a knowledge base.
What's next
- Custom Agent — how the
custom_agentdispatch this agent runs on works. - Multilingual Translation Agent — produces the translated rows whose grouping this agent preserves.
- Agent Reference overview — the agent-type model, catalog, and shared execution engine.