Skip to main content
Use a script node to process inline Python code inside your agentic workflow. Script nodes let you transform data, initialize state, aggregate results from other nodes, or perform any custom logic that does not require an external tool or agent. A script node corresponds to the Logic Block in the watsonx Orchestrate Flow Builder UI. To configure a script node, call the script() method in your agentic workflow. In this method, define the following parameters:
string
required
The internal identifier for the node.
string
required
The Python code for this node. Write the code as a multiline string. Inside the script, use the following variables to read and write data:
  • flow.input.<field> — reads a value from the agentic workflow input.
  • flow.private.<field> — reads or writes a value in the private agentic workflow state, which is not exposed to users.
  • flow.nodes['<node_name>'].output.<field> — reads the output of another node by its name.
  • self.output.<field> — writes a value to this node’s output.
string
A human-readable name shown in the UI.
type[BaseModel]
A Pydantic BaseModel that defines the structure of the node’s output. Required when other nodes or the agentic workflow output need to reference the script node’s results.
Example