docs/guides/agent/agent_workflow/data_manipulation_components.md
The Code component executes Python or JavaScript code for complex data processing, format conversion, calculation, file generation and custom logic.
Prerequisite: The Code component depends on a secure sandbox environment. The deployment environment needs to install and enable gVisor, RAGFlow sandbox and related environment variables. Restart the service after dependency changes.
Configuration:
Text Processing splits or merges text. Used to split long upstream text by separators or combine multiple variables into one template.
Processing Modes:
Configure script content with variables inserted via /. Output results can be referenced by subsequent nodes.
Data Operation processes structured objects returned by upstream tools, code or database nodes to clean data for downstream usage.
Configuration Steps:
+ to add multiple input variables. Query variables are mandatory.Output: Processed data stored in variable result.
Supported Operations:
| Operation | Function | Scenario |
|---|---|---|
| Select keys | Keep only specified fields | Extract required fields for downstream nodes |
| Literal eval | Convert string-formatted list/dict/bool/number into actual data types | Parse serialized structured strings |
| Combine | Merge multiple objects into one | Aggregate outputs from multiple upstream nodes |
| Filter values | Filter data matching conditions | Filter array/object collections |
| Append or update | Add new fields or overwrite existing field values | Supplement or modify object attributes |
| Remove keys | Delete specified fields | Remove unnecessary sensitive or unused fields |
| Rename keys | Rename object field keys | Unify field naming standards |
Variable Assignor writes or updates variables during workflow execution. It can save upstream results to target variables and support overwrite, clear, append and arithmetic operations for numbers, arrays and objects.
Configuration Steps:
Parameter Description:
| Parameter | Type | Required | Description |
|---|---|---|---|
| Target Variable | Variable | Yes | Select the variable to be written or updated. Supports component output variables, system variables, environment variables, session variables, and other variable types. |
| Operation | Enum | Yes | Select the operation to be performed on the target variable. The system will automatically display available operations based on the variable type. |
| Value | Variable / Constant | Conditional | The value used for the operation. You can select another variable or enter a fixed value (depending on the supported operation type). Some operations do not require a value. |
Supported Operations:
| Operation | Requires Value | Description |
|---|---|---|
| Overwritten by | Yes | Overwrite target variable with another variable's value |
| Set | Yes | Assign fixed constant value to target variable |
| Clear | No | Empty the target variable |
List Operation processes array data, supporting element extraction, head/tail fetching, filtering, sorting and deduplication. Suitable for array outputs from Begin, HTTP Request, Code and SQL.
Configuration Steps:
Parameter Description:
| Parameter | Required | Description |
|---|---|---|
| Query variables | Yes | Select the array variable to be processed. |
| Operations | Yes | Select the list processing operation. |
| Strict mode | No | When enabled, the system performs strict validation during processing and returns an error if an exception occurs. When disabled, the system processes according to the configured rules. |
| Operation Parameters | Conditional | Configure the corresponding parameters based on the selected operation, such as N, filter conditions, or sorting rules. |
Supported Operations:
| Operation | Description | Use Case |
|---|---|---|
| Nth | Retrieves an element at a specified position from the list. | Get the Nth item from the list. |
| Head | Retrieves one or more elements from the beginning of the list. | Get the first N items from the list. |
| Tail | Retrieves one or more elements from the end of the list. | Get the last N items from the list. |
| Filter | Filters elements in the list based on conditions. | Keep data that meets the specified conditions. |
| Sort | Sorts the elements in the list. | Sort by specified fields or order. |
| Drop duplicates | Removes duplicate elements from the list. | Deduplicate the list data. |
Operation Configuration Description:
| Operation | Description | Configuration |
|---|---|---|
| Nth | Retrieves an element at a specified position from the list. | Configure N to specify the element index (starting from 0). |
| Head | Retrieves elements from the beginning of the list. | Configure the return count N to return the first N elements. |
| Tail | Retrieves elements from the end of the list. | Configure the return count N to return the last N elements. |
| Filter | Filters list elements based on conditions. | Configure filter conditions and retain only elements that meet the requirements. |
| Sort | Sorts elements in the list. | Configure the sorting field and order (ascending or descending). |
| Drop duplicates | Removes duplicate elements from the list. | No additional configuration required. Returns the deduplicated list. |
Strict Mode:
Variable Aggregator combines multiple independent variables into one output group for unified reference by downstream nodes. Widely used in multi-branch conditional workflows to collect data from different branches.
Configuration Steps:
Note
A variable group can contain multiple variables. Multiple variable groups can also be created based on different business requirements for separate aggregation.
Parameter Description:
| Parameter | Required | Description |
|---|---|---|
| Group | Yes | Variable group used to store variables to be aggregated. A default group Group0 is created automatically, and additional variable groups can be added. |
| Select value | Yes | Select the variables to be aggregated. Supports system variables, Begin node inputs, session variables, or output variables from upstream nodes. |
| Add | No | Continue adding variables to the current variable group. |
| + | No | Create a new variable group. |
| Delete | No | Delete the current variable group. |
Output Result:
| Output | Description |
|---|---|
| Group0 (or other variable group name) | Outputs the variables after aggregation in the current variable group. The output can be directly referenced by subsequent nodes. |
Usage Instructions:
| Operation | Description |
|---|---|
| Add Variable | Select variables in Select value, then click Add to continue adding multiple variables. |
| Create Variable Group | Click the + icon to create a new variable group. |
| Delete Variable Group | Click the delete button for the variable group to remove the current group. |
| Reference Output | Subsequent nodes can directly reference the variable group (for example, Group0) as an input. |