Principle:Langgenius Dify Input Variable Definition
| Knowledge Sources | Dify |
|---|---|
| Domains | Workflow, DAG, Frontend |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
Description
Input Variable Definition is the principle governing how data enters and flows between nodes in a Dify workflow. Every workflow begins with a Start node that declares its expected inputs, and every downstream node references upstream data through a structured type system. This principle encompasses three interconnected concepts:
- InputVarType: An enumeration of the UI form-field types that a workflow's Start node can accept from end users. These types define the user-facing input surface and include text fields, dropdowns, numbers, URLs, file uploads, JSON objects, and checkboxes.
- ValueSelector: A path-based reference mechanism represented as a string array (
[nodeId, key]) that allows any node to reference a specific output variable from any upstream node. This is the backbone of inter-node data wiring. - VarType: An enumeration of the runtime data types that variables can carry within the workflow engine, including primitives (
string,number,boolean), complex types (object,file), and typed arrays (array[string],array[number], etc.).
The separation of input types (what users see) from variable types (what the engine processes) allows the platform to maintain a clean boundary between presentation and execution.
Usage
When defining inputs for a workflow:
- Use InputVarType to configure the Start node's form fields, determining what UI elements are shown to end users.
- Use ValueSelector (a
string[]of format[nodeId, variableKey]) to wire node outputs as inputs to downstream nodes. - Use VarType to declare and validate the runtime data types of variables as they flow through the DAG.
- The Variable type combines these concepts: it carries a variable name, a value_selector for wiring, and an optional value_type for type checking.
Theoretical Basis
This principle is grounded in:
- Strongly Typed Data Flow: Similar to typed dataflow languages (e.g., LabVIEW, Unreal Blueprints), each connection between nodes carries a declared type. The
VarTypeenum ensures that connections are type-compatible at design time, preventing runtime errors from type mismatches. - Path-Based Variable Resolution: The
ValueSelectorpattern ([nodeId, key]) mirrors JSON Pointer or XPath semantics, providing a deterministic way to resolve variable references across a graph without ambient scoping. This avoids the ambiguity of name-based resolution in complex DAGs with potential naming collisions. - Presentation-Logic Separation:
InputVarTypegoverns the UI layer (form rendering), whileVarTypegoverns the engine layer (runtime processing). This separation follows the Model-View pattern, allowing the same runtime type (string) to be presented as different input widgets (text-input,paragraph,url,select).