Adding code blocks
Code blocks help you to add custom logic as Python code within your agentic workflow. A code block node is used where other nodes do not meet your needs for data processing, complex logic, or message formatting. You can create code from scratch or paste it from another source, and define output variables based on your code to use later in the agentic workflow. Code block gives you more control and flexibility to customize your agentic workflow and handle complex scenarios.
To add a code block to an agentic workflow:
- From the menu
, go to Build.
- Select All tools and click Create tool.
- Select Agentic workflow.
- Update the Name if necessary.
- Click Start build
- Use one of the following actions to add a code block:
- Click add tools
, then click and drag Code block onto a connector line. - Hover over a connector line and click add
, then select Code block.
- Click add tools
Adding or editing code in a code block
To add or edit code in a code block:
- Click the code block to open it.
- Select the Open code editor.
- Enter the new code or edit the existing code in the Code editor tab. For more information on creating code block, see Code block examples.
- Click close.
Adding output in a code block
To add or delete output in a code block:
- Click the code block to open it.
- Select the Define outputs.
- From the Outputs tab, select Add output.
- Choose the output type from the drop-down list.
- Enter the Name and optional Description.
- Select the List of {output type} checkbox to generate a list output.
- Click Save.
To learn more about defining output as an object, see Object data type.
Editing or deleting output in a code block
To edit or delete output in a code block:
- Click the code block to open it.
- Select the Define outputs.
- From the Outputs tab, click options
against the output. - To edit, select Edit Details from the drop-down list.
- Update the Name and Description.
- Click Save.
- To delete, select Delete from options drop-down list.
-
An agentic workflow defines a set of linked activities and controls that are designed to achieve a specific business purpose or goal. Learn more about agentic workflows.