Quick Overview

The Code action lets you run custom Python or JavaScript code directly within your agent workflows. It’s ideal for tasks like data manipulation, data analysis, API calls, complex calculations, or conditional logic. Key benefits:
  • Multi-language support - Write in Python or JavaScript
  • Variable integration - Use outputs from previous steps as variables
  • Flexible output - Return results, printed text, or error messages
  • Rich libraries - Access to popular data science and utility libraries

Action Configuration

Code action configuration showing language selection, variables, and code editor

Language Selection

Choose between Python and JavaScript based on your needs:
  • Python - Best for data analysis, scientific computing, and complex calculations
  • JavaScript - Ideal for web APIs, JSON manipulation, and async operations

Variables

Variables configuration showing name and value fields with output references
Set up variables to pass data from previous steps into your code:
  • Name - The variable name you’ll use in your code
  • Value - Set to output references from previous steps
  • Type - Variable values are always passed as strings
All variable values are passed as strings. Convert to appropriate types (int, float, etc.) within your code as needed.

Code Editor

Code editor showing Python code with variable usage and function definition
Write your code using the variables defined in the previous step. The code editor supports:
  • Syntax highlighting
  • Auto-completion
  • Error detection
  • Multi-line code blocks

Reference Code Output

Output references showing result, text, and stderr options in subsequent steps
The results of your code action can be used in subsequent steps with three output references:
  • result - What your code returns (using return statement)
  • text - Any text printed during execution (stdout)
  • stderr - Standard error buffer for debugging
If you want to see what the example code output looks like within the test panel or task view, you can click into the code action and see the JSON for all the outputs, so you can use them appropriately.

Available Libraries

Python Libraries

Use Cases

Best Practices

Always handle errors gracefully in your code. Use try-catch blocks and return meaningful error messages.
Code execution has timeouts. Keep your code efficient and avoid infinite loops or very long-running operations.

Next Steps