Summary
Agent Builder flows today mostly run in a straight line. Adding control-flow and code nodes would let us build production agents inside AIDP, without pushing the logic out to external services.
Conditional Nodes (IF / SWITCH)
- IF: branch on a true/false check. For example, if the LLM's confidence is below 0.8, send the item to human review; otherwise continue.
- SWITCH: route to one of several paths based on a value, such as an intent label (invoice query, supplier onboarding, payment status) or a document type.
- Should accept output from earlier nodes, variables, and simple expressions (==, >, contains, is null, AND/OR), with a default/else path.
Loop Nodes (FOR / FOR EACH)
- Run a group of nodes once for each item in a list, such as invoice lines, supplier records, rows from a query, or files in a bucket.
- Options: maximum iterations, break/continue conditions, collect each pass's output into a list, and optional parallel runs with a limit on how many run at once.
- Report errors per item, so one bad record doesn't fail the whole run.
Code Node (Python)
- Run short Python snippets inline for data transforms, validation rules, JSON reshaping, calculations, and regex parsing.
- Sandboxed, with common libraries available (json, re, datetime, pandas), typed inputs and outputs mapped to the flow's variables, timeouts, and logs visible in the trace.
Business value
- Deterministic control: rules-based steps (like approval thresholds or compliance checks) run as code, not as LLM guesses. That matters for audit and SOX-style governance.
- Fewer external dependencies: no separate functions or APIs needed for simple logic.
- Feature parity: brings Agent Builder in line with other agent and workflow tools that already support branching, loops and code steps.
- Easier debugging: each branch and loop pass shows up in the run trace.
Example use case
An invoice-exception agent:
- Reads the invoices on hold.
- Loops over each one.
- Uses a SWITCH on the hold reason (price, quantity, missing PO).
- Runs a Python node to calculate the variance.
- Uses an IF on the variance tolerance to either auto-release the invoice or create a review task.