Flow Control Nodes

Applies to: ChengOS v0.2.0+ | Last verified: 2026-09-25 | Source: crates/cheng-nodes/src/nodes/builtin/utils

These nodes decide where data goes and what shape it arrives in. utils/condition_router is the deterministic branch — simple mode is one rule with a true/false pair of outputs, advanced mode is a multi-rule switch with one output per branch. Reach for it before an LLM branch whenever the rule can be written down. utils/to_items fans a single value out into items for downstream iteration, utils/type_cast fixes type mismatches at a connection, utils/smart_var holds a named value you want to reference from several places, and utils/delay paces calls against a rate-limited service.

Condition Router — utils/condition_router

Route by field conditions: supports operator comparison, dot nested path, Schema hint generation, enhanced fallback metadata

Inputs

FieldTypeRequiredDefaultDescription
contextobject (port)—nullInput AgentContext (optional). Connection port, not a form field. Control: code-editor
responsestring—""LLM response text (JSON format). Control: code-editor
custom_datastring—nullCustom JSON data. Control: code-editor
payload_sourceenum—responseSelect data extraction source. Control: select. Options: response (从 response 字段解析 JSON), context (从完整 context 序列化为 JSON), custom (从 custom_data 字段取值)
branch_fieldsarray<object>—[]Branch field list (click + to add; each entry auto-generates a corresponding output port)
strict_modeboolean—falseError on JSON parse failure (false routes error reason to fallback output)
generate_schemaboolean—falseEnable auto-generated JSON Schema hint output to schema_hint port (can connect to upstream LLM's system_prompt)
modeenum—advancedSimple (If: one rule, True/False) or Advanced (Switch: multi-rule, multi-output). Control: select. Options: simple (If 模式:单条件,True / False 输出), advanced (Switch 模式:多规则多输出(默认,兼容旧行为))
match_policyenum—allFirst: stop at first match. All: output all matched branches (default). Control: select. Options: first (仅输出第一个命中的分支), all (所有命中的分支都输出(默认))
fallback_modeenum—fallback_outputFallbackOutput: route to fallback_out (default). None: skip. Output0: route to first branch port. Control: select. Options: fallback_output (输出到 fallback_out 端口(默认)), none (不输出,下游自动跳过), output0 (输出到第一个分支端口)

Outputs

FieldTypeDescription
branch_outputsarray<any> (port)Branch output list, corresponding 1:1 with branch_fields (AgentContext on match, null on miss). Connection port, not a form field.
fallback_outobjectFallback output (acts as 'False' in Simple mode). Fires when no branch rule matches. Includes diagnostic metadata.
context_outobjectLegacy fallback output (use fallback_out instead). Mirrors fallback_out for backward compatibility.
schema_hintobject (port)Auto-generated structured output hint (can connect to upstream LLM node's system_prompt port). Connection port, not a form field.

Smart Variable Node — utils/smart_var

Auto-detect text variables, dynamically generate ports, support full output and picked variable extraction

Inputs

FieldTypeRequiredDefaultDescription
templatestring✅—Raw text (supports JSON/curl/YAML, etc.). Control: textarea
extract_modeenum—autoExtract mode: auto=auto-detect key names, manual={{var}} syntax only. Control: select. Options: auto, manual
output_varsarray<string>—[]List of variables to include in output. Control: multi-select. Options loaded from ports

Outputs

FieldTypeDescription
full_textstringFull text after variable substitution
selected_varsobjectPicked variable key-value pairs
all_variablesarray<string>All extracted variable names
preview_contentstringFormatted preview content
statisticsobjectVariable extraction statistics

To Items — utils/to_items

Normalize any input into a loop-ready items array for LoopContainer

Inputs

FieldTypeRequiredDefaultDescription
inputany——Data to convert into loop items
modeenum—autoHow to convert the input. Control: select. Options: auto (Automatically detect input type.), array (Input is an array — pass through, normalizing each element.), single (Wrap any single value into a one-element array.), split_text (Split a string into text items.), refs (File / document / chunk reference passthrough — no content expansion.), object_values (Convert object key-value pairs into items.), range (Generate a numeric range as items.)
chunkSizeinteger—500Characters per chunk when Split By = Chunk. Control: number
maxItemsinteger—0Maximum number of items to emit (0 = unlimited). Control: number
rangeEndinteger—0Range end (exclusive, Range mode). Control: number
rangeStartinteger—0Range start (inclusive, Range mode). Control: number
rangeStepinteger—1Step between consecutive range values. Control: number
splitByenum—paragraphText split strategy (SplitText mode). Control: select. Options: paragraph (Split on blank lines (two consecutive newlines).), line (Split on every newline.), sentence (Heuristic sentence splitting (punctuation-based).), chunk (Fixed character chunk size.)

Outputs

FieldTypeDescription
itemsanyLoop-ready items array
countintegerNumber of items in the array
mode_usedstringConversion mode that was applied

Type Cast — utils/type_cast

Convert between common port types, with first-class AgentContext support

Inputs

FieldTypeRequiredDefaultDescription
agent_contextobject (port)—nullConnect AgentContext-like object here. Connection port, not a form field.
textstring (port)—nullConnect string/text output here. Connection port, not a form field.
jsonobject (port)—nullConnect object output here. Connection port, not a form field.
arrayarray<any> (port)—nullConnect array output here. Connection port, not a form field.
integerinteger (port)—nullConnect integer output here. Connection port, not a form field.
numbernumber (port)—nullConnect number output here. Connection port, not a form field.
booleanboolean (port)—nullConnect boolean output here. Connection port, not a form field.

Outputs

FieldTypeDescription
agent_contextobject (port)Converted AgentContext. Connection port, not a form field.
textstring (port)Converted string. Connection port, not a form field.
jsonobject (port)Converted object. Connection port, not a form field.
arrayarray<any> (port)Converted array. Connection port, not a form field.
numbernumber (port)Converted number. Connection port, not a form field.
integerinteger (port)Converted integer. Connection port, not a form field.
booleanboolean (port)Converted boolean. Connection port, not a form field.
source_typestringSelected input source type

Delay Node — utils/delay

Add delay in workflow, for testing pause and stop functionality

Inputs

FieldTypeRequiredDefaultDescription
delay_typeenum—fixedfixed, random range, until timestamp, until time of day, fixed with jitter, or exponential backoff. Control: select. Options: fixed (固定时长延迟), random_range (随机区间延迟), until_timestamp (延迟到绝对时间戳), until_time_of_day (延迟到某个本地时间), fixed_with_jitter (固定延迟并附加抖动), exponential_backoff (指数退避)
delay_valueinteger—5Delay time value (used with unit). Control: number
delay_unitenum—secondsDelay time unit: milliseconds or seconds. Control: select. Options: milliseconds (毫秒), seconds (秒), minutes (分钟), hours (小时)
max_delay_valueinteger—nullUpper bound for random range delay. Control: number
target_timestampstring—nullRFC3339 timestamp or local datetime interpreted with timezone. Control: datetime-local
time_of_daystring—nullLocal target time in HH:MM or HH:MM:SS
timezonestring—UTCIANA timezone for local datetime interpretation; defaults to UTC
jitter_percentinteger—nullMaximum +/- jitter percentage for fixed_with_jitter mode. Control: number
attemptinteger—nullZero-based attempt number for exponential_backoff mode. Control: number
initial_delay_valueinteger—nullInitial delay value for exponential_backoff mode. Control: number
max_backoff_valueinteger—nullMaximum delay value for exponential_backoff mode. Control: number
multipliernumber—nullGrowth multiplier for exponential_backoff mode. Control: number
log_messagestring—nullLog message: output before and after delay
passthroughany—nullPassthrough data: forwarded as-is to output port

Outputs

FieldTypeDescription
completedbooleanWhether delay completed normally
actual_delay_msintegerActual delay duration (milliseconds)
passthroughanyPassthrough data from input
log_messagestringPassthrough log message from input
contextobjectAgentContext combining log_message and passthrough
infoobjectDetailed delay execution info

Next steps