How Workflows Run
This page explains what happens behind a run: where a draft run executes, how a Loop's results are collected, how a loop's items are spread over threads and workers, how data is cached between nodes, and how nodes record metrics you can read and compare afterwards.
Models wake when a run starts
When any run of a workflow starts, draft or deployed, every scale-to-zero model the workflow selects (the AI Gateway and Model Registry models its nodes name) is woken at once, all together, instead of each node waking its model when it reaches it. The run does not wait for them: each node still waits for its own model if it is not ready yet. A model only a branch the run does not take uses wakes too, and scales back to zero after its idle window like any other.
Your worker pool for draft runs
A draft run is a run of a workflow that is not deployed: a Run from the builder, or an execute call through the REST API, STAN or the SDK while the workflow is still a draft. Draft runs execute on your own worker pool. A deployed workflow never uses a pool; its runs execute on the workflow's own deployment (see Deploying Workflows).
How the pool behaves
- One pool per user. Your pool runs only your draft runs, as you. Other users in your organization have their own pools.
- It starts when you open the builder. Opening a batch workflow in the builder starts your pool with 2 pre-warmed workers, so a Run starts at once instead of waiting for a new worker.
- Each run uses a worker once. A run takes a free worker, and the worker is removed when the run ends. While you are still in the builder, the pool is topped back up so the next Run also finds a worker waiting.
- The open workflow gets a worker its run fits. A pre-warmed worker has up to 1 vCPU and 1 GB of memory and reaches only the platform's own services. When the workflow you have open needs more (an LLM node, or a size set on a node's Resources tab), the pool prepares one worker of exactly the size its run needs while you build, and prepares another after each run, so Run starts at once.
- A run that reaches services gets a worker made for it. A run that connects to data sources, add-ons, models or other services gets a worker started for it with exactly that access. The run waits for that worker to start, which can take up to a minute when new compute has to be added.
- It stops when you leave. The builder keeps your pool alive while you stay in the workflow section (it checks in every minute). About 5 minutes after you leave the workflow section or close the browser tab, the pool stops. A run already in progress finishes; it does not restart the pool.
A draft run started when your pool is stopped (for example through the REST API) still runs: a worker is started for that run.
What the builder shows
The pool's state is shown as a badge at the top right of the builder, next to Back to Workflow List:
| Badge | Meaning |
|---|---|
| Connecting... | The builder is joining your pool |
| Starting pool... | Your pool's workers are starting |
| Preparing a worker... | A worker sized for the open workflow's run is starting |
| N workers ready | N free workers can take the open workflow's next run at once |
| Runs start their own worker | The open workflow's runs each get a worker made for them (they reach services, or the workflow is deployed); hover the badge for the reason |
| Stopping pool... / Pool stopped | Your pool is shutting down, or has stopped |
| Workers unavailable | The workers could not be started; hover the badge for the reason |
| Pool unavailable | The builder could not reach the pool service; hover the badge for the reason |
Streaming workflows show Starting streaming worker... / Streaming worker ready instead: a streaming test session runs on its own test worker (see Streaming Workflows).
Limits
- A workflow runs one execution at a time unless its concurrency limit is raised (up to 10). A second run while one is still running its steps is refused (429
concurrency-limit, naming the runs in flight); a run frees its place as soon as its last step completes, while it still writes its end, so the next run can start on its result. To be told when a run ends, add an alert rule with the condition "Execution completed" (or "Execution failed") and a webhook channel: it posts the run's id, status and duration when the run ends. An agent's runs fire its alert rules the same way. - Pool workers are billed to you, as the user whose pool they belong to. FinOps shows them under your user.
How to check it worked
Open the builder and wait for N workers ready, then click Run: the canvas shows each node's state as the run moves through the graph, and the run appears in Workflow Monitor with its trace.
Closing a loop with a Loop Accumulator
A Loop runs the nodes on its body once per item. The Loop Accumulator node (node id merge, shown in the palette as Loop Accumulator (Sink)) closes the loop: it collects the output of every iteration into one array, and the rest of the workflow continues from it.
How to wire a Loop and its accumulator, and the Map variant, is described in Creating Workflows: Loop bodies. In short:
- Draw the body from the Loop's output handle.
- Connect the body's last node to a Loop Accumulator. The loop returns at the first Loop Accumulator its body reaches, on its own: never connect the Loop itself to the accumulator. No other node ends a loop: an Aggregate or Data Aggregator goes after the accumulator.
- Continue the workflow from the accumulator's output. The next node reads the collected array at
data.data(and the item count atdata.count), for example an input mappingitems=data.data.
The accumulator collects every item however the loop runs: one item at a time, several at once, or across workers (see below). Always read the results from the accumulator.
What happens without one
- Deploy refuses the workflow: loop "..." has no Loop Accumulator, with the suggestion to add one after the body. It also refuses a loop whose paths end in different Loop Accumulators, naming them.
- A draft run fails before any node runs: 'loop' requires an aggregator node to collect results.
- If an accumulator is present but nothing from the body is wired into it, deploy refuses the workflow because the accumulator would collect nothing.
How to check it worked
Run the workflow and click the Loop Accumulator (or the node after it) on the canvas: its output holds one entry per item, in item order, and count equals the number of items. In the run's trace, the body nodes have one span per item.
Threads and workers
A loop's items can run one at a time (Single), several at once in the workflow's worker (Threaded), or spread over several workers (Across Workers). You choose on the node's Scaling tab; the settings and their ranges are listed in Creating Workflows: Scaling a Loop, Map or Parallel Branch. A Map and a Parallel Branch have the same three modes.
| Threaded | Across Workers | |
|---|---|---|
| Where items run | Inside the workflow's worker, several at the same time | Over the workflow's own worker plus workers started for the node |
| Best for | I/O-bound work: API calls, model calls, database queries | CPU- or memory-heavy work, long work per item, thousands of items |
How a loop runs Across Workers:
- The loop's items are put on a shared work queue.
- The number of workers is the item count divided by Target Items per Worker, rounded up, at most Max Workers and never more workers than items. The workflow's own worker is one of them, so the run starts that many minus one workers.
- The workflow's own worker starts on the items at once; started workers join as soon as they are running and take items from the queue. A small loop can finish on the workflow's own worker before the others are up.
- An item that fails on a transient error is run again, up to Retry Attempts. A worker that stops (its machine is reclaimed, it runs out of memory) gives its items back to the queue and they run on another worker; an item it was in the middle of runs again from its start.
- When every item is done, the Loop Accumulator collects all of their results in item order, as for a loop that runs one item at a time. An item that failed under Continue on Error is in its place as a failed entry, and the run ends Partly succeeded.
Across Workers works in draft runs and in deployed runs alike. A run's secret inputs reach only the workflow's own worker, never the workers started for the node: an item there that needs one fails, naming it. A loop across workers inside another one is allowed up to 5 levels deep; deeper nesting fails the run. While and goal loops always run one iteration at a time, because each iteration depends on the previous one.
Threads share a worker's CPU
Every worker, the workflow's own included, runs Threads per Worker items at once as threads of one process, on the CPU the worker has. An item that mostly computes (parsing a PDF, transforming a large file) gets no faster with more threads: the threads take turns on the same CPU, so each item takes longer from start to end while the worker finishes the same number of items per second. Threads help when items mostly wait (on a model, an API, a database). To finish CPU-heavy items sooner, give the loop body's nodes more CPU on their Resources tab, or raise Max Workers.
How to check it worked
Open the run's trace in Workflow Monitor. A scaled Loop has a span of type DISTRIBUTED named Distributed: (loop name), recording the total item count and the Max Workers, Target Items per Worker and Threads per Worker it ran with. It is recorded at every tracing level except off, and it starts and ends when the loop did. Every body node span sits under it in the trace, grouped by Worker N (the worker that ran it) and Item N, with the item's results merged in item order (a failed item's entry where its item was); a Worker or Item row starts with its first span and ends with its last. A page of the trace that holds only a loop's later items still shows them under the loop's span.
A Map's trace has the same shape: under the Map's span is one Item N span per item (type ITERATION, with the item's index), and each item's body node spans sit under its Item span, whether the items ran one at a time or as threads.
A body node span records the item index, the worker that processed it and how many items that worker ran at once. Its Inputs tab shows what the item received (its mapped inputs and the loop's current item), and its settings are on the Config tab. A body node reads its loop's position the same way whether the loop is scaled or not: _metadata.loops holds each enclosing loop's currentIteration and totalIterations.
In the builder, click the Loop and open Node Info. The Items tab lists each item with its CPU time (the CPU the node itself used on the item) and its Wall time (start to end, with how many items its worker ran at once), and a row per worker with its items, average CPU time, average wall time and Items/sec. When wall time is many times the CPU time on a worker running several items at once, the items are waiting for the worker's CPU.
Caching between nodes
Nodes hand data to each other through a cache with three tiers. Every item written to the cache goes to object storage, and smaller items are also kept closer to the node for fast reads:
| Tier | Where | What it holds | Lifetime |
|---|---|---|---|
| L1: Memory | The worker's memory | Items up to 100 KB. The tier uses up to 10% of the worker's free memory (between 50 MB and 500 MB) | 5 minutes |
| L2: Disk | The worker's local disk | Items up to 10 MB (an L1 item is written here too). Up to 500 MB in total | 1 hour |
| L3: Object storage | The platform's storage bucket | Every item, of any size. Shared by every worker of the run | Until the run's cache is cleaned up (below) |
A node reading an item checks memory first, then disk, then object storage. An item read from disk again and again is moved up to memory. When a worker runs low on memory, new items are kept in memory only if they are small, and the oldest are dropped first; nothing is lost, because every item is also in object storage.
Because L3 is shared, every worker of a run sees the same data: the started workers of a loop across workers read what the workflow's own worker wrote, and a resumed run reads what the first attempt wrote.
Cleanup: a run's cache is deleted 24 hours after the run ends, except for the most recent finished run of each workflow, which keeps its cache so it can still be resumed. A run's final result is never removed by this cleanup.
There is nothing to configure: the tier is chosen for each item by its size. The memory tier grows with the worker's free memory, so a run whose nodes have more memory (their Resources tab, or the deploy dialog for a deployed workflow) keeps more in memory.
Node metrics
Nodes record metrics as they run: numbers such as a judge's score, the rows a query affected, or how long a model call took. A metric is saved only when a node logs it: a built-in node or your own node calls log_metric(name, value, unit), and a Code node calls metric(name, value, unit). The platform records no metrics of its own: no output field, timing or token count of a node becomes a metric unless the node logs it. Metrics are stored with the run, and you can read them on the run's trace and compare them across runs.
Token usage is not a metric. The AI Gateway records every model call a run makes, and the run's trace shows them on its AI Gateway Usage card: the requests, input tokens, output tokens and total tokens, in all and per model. The same figures come from GET /api/v1/workflows/-/executions/:id/ai-usage and client.executions.ai_usage(execution_id) in the Python SDK.
Which nodes log metrics
| Node | Metrics it logs |
|---|---|
| LLM as Judge | evaluation_score, evaluation_passed, and <criterion>_score for each criterion |
| Faithfulness Checker | faithfulness_score, is_faithful, claims_extracted, unsupported_claims |
| RAG Metrics | Each metric it computes (contextPrecision, contextRecall, answerRelevancy, faithfulness, contextUtilization, as configured) and rag_overall_score |
| Relevance Grader | relevance_score, relevance_ratio, relevant_doc_count, total_doc_count |
| Answer Quality | quality_score and <dimension>_score for each dimension |
| Pairwise Comparator | preference_score, comparison_confidence, and <criterion>_a_score and <criterion>_b_score for each criterion |
| LLM | response_time_ms |
| Model Registry | response_time_ms, batch_size |
| Database sources that write (Google BigQuery, CockroachDB, CrateDB, Microsoft SQL Server, Oracle Database, QuestDB, SingleStore, Snowflake, TimescaleDB) | rows_affected |
| Filter | matched_count, unmatched_count |
| Sort | items_sorted |
| Limit | items_limited |
| Remove Duplicates | duplicates_removed |
| Aggregate | items_aggregated |
| Edit Fields | fields_set |
| Value Map | mapped_values, unmapped_values |
| Number Format, String Transform | transforms_applied |
| JSON Parser | json_parsed |
| Data Standardizer | fields_standardized, fields_unresolved |
| PDF Redactor | pdf_redaction_boxes, pdf_pages, pdf_pages_redacted, and pdf_redaction_failed when a redaction fails |
| PII Redaction Validator | pii_candidates, pii_kept, pii_dropped |
| Web Search | results_returned (the number of results the search returned; on the tool call's span when an agent calls it as a tool) |
| Split Out | items_split |
| Stop and Error | workflow_stopped |
| Code | Whatever its code records with metric(name, value, unit) (see below) |
A node inside a loop records its metrics once per item.
Log your own metrics from a Code node
A Code node can record any number you want to see per run. Call metric(name, value, unit) in its Python:
redacted = 0
for item in items:
for field in ("ssn", "phone"):
if item.get(field):
item[field] = "[REDACTED]"
redacted += 1
metric("values redacted", redacted, "count")
result = items
nameis the metric's name, a non-empty string.valueis a number (an integer or a decimal;True/Falseare not accepted).unitis optional text such ascount,score,percentorms.
Each call becomes a span-level metric with the Code node as its source. In Run Once for Each Item mode every item's calls are recorded. A wrong argument stops the node with an error that points at the line. Metrics are recorded when the code finishes; code that fails records none.
Metric levels
Each metric has the level the node logged it at (log_metric(name, value, unit, level)); a metric logged without one is a span metric. Its Source is always the node that logged it.
| Level | What it is |
|---|---|
| Span | A number about one node run (the default) |
| Trace | A number the node gives about the run as a whole |
| Execution | A summary number the node gives for a batch run |
Read and compare metrics
- Open Workflows > Monitor, click the workflow, and open a run's trace.
- The Execution Metrics card lists every metric of the run with its Metric Name, Value, Unit, Level and Source. Filter by level (All Levels, Span, Trace, Execution), search by metric or source, and sort by name, value, level or source.
- To compare runs, select two or more runs in the workflow's execution history and click Compare. The comparison lines up each metric across the selected runs (a run's value is the mean of what its nodes logged under that name), and lists the inputs and node settings that differ between them.
A run whose nodes recorded no metrics shows No metrics recorded for this execution.
How to check it worked
Run a workflow that contains one of the nodes above, for example a Limit node: its trace's Execution Metrics card shows items_limited at span level with the node as its source, and nothing else.
For a Code node, add metric("values redacted", 4, "count") to its code and run the workflow: the trace's Execution Metrics card shows values redacted at span level with the Code node as its source. A Code node without metric(...) calls adds no metric.
For an LLM node, run the workflow: its span metric is response_time_ms, and the trace's AI Gateway Usage card shows the call with its input and output tokens.