Skip to main content
For the curious. Your AI agent configures batch processing when needed. This explains what happens when you ask to process many items (files, API results, etc.) and what to expect during execution.
Batch processing runs a single node multiple times — once for each item in an array. Think for-loop, but declarative: your agent adds a batch config to any node, and pflow handles the looping, concurrency, and error collection.

When batch processing happens

Your agent uses batch processing when tasks involve:
  • Processing each file in a directory listing
  • Analyzing each item from an API response
  • Running the same LLM prompt on multiple inputs
  • Transforming each element in an array
Example scenario: When you ask to classify 100 GitHub issues, your agent configures a batch node to process each issue.

How it works

A batch configuration is added to a node:
This runs the classify node once for each issue. The as: "issue" creates a template variable ${issue} that changes with each iteration.

Configuration options

Sequential vs parallel

Sequential (default)

Items are processed one at a time, in order:
This mode is chosen when:
  • Order matters
  • Rate limits are strict
  • Resources are limited

Parallel

Multiple items are processed concurrently:
This mode is chosen when:
  • Items are independent
  • Speed is important
  • API/LLM can handle concurrent requests
Your agent typically starts with max_concurrent: 5 for LLM calls to avoid rate limits, increasing gradually based on API tier.

Error handling

Fail fast (default)

Execution stops immediately on first error:
This mode is chosen when:
  • Any failure means the whole task is invalid
  • Errors should be fixed and re-run from scratch

Continue on errors

All items are processed, with errors collected:
This mode is chosen when:
  • Partial results are useful
  • Some failures are expected
  • All errors should be seen before fixing
The node output includes error details in this mode:

Retries

Failed items can be automatically retried:
This configuration gives each failed item up to 3 total batch attempts, waiting 2 seconds between attempts. Common in scenarios involving:
  • Transient API errors
  • Rate limit recovery
  • Network timeouts
Node-level retry: is separate from batch retry and applies inside each node attempt:
For nodes that return an "error" action when exhausted (llm, shell, mcp, code, file nodes), batch does not run another item attempt. Attempts multiply only for nodes that re-raise after node retries are exhausted, such as http, agent, or custom nodes using the default fallback.

What you’ll see

During batch execution, pflow shows real-time progress:
Failed items are marked with and summarized at the end. When a failed item is large, pflow shows a compact description instead of printing the full item. For example, a record with a label and a long payload is shown with the label, payload size, and a stable reference:
The original failed input remains available in runtime data and trace files for debugging. Terminal output, MCP output, JSON error responses, and generated reports use the compact form so the actionable error stays visible.

Output structure

Batch nodes write a special output structure to the shared store:
results contains only successful items — each pairs item (the original input) with the inner node’s outputs. With error_handling: continue, failed items are excluded from results and appear only in errors. count is the total items attempted, success_count equals len(results), and error_count equals len(errors). Inside a batch node, ${__index__} gives the 0-based position of the current item. Index-based access to results (like ${node.results[0].field}) requires fail_fast mode (the default). With error_handling: continue, use iteration (items: ${node.results}) instead — the validator blocks index access because filtered results don’t preserve original positions. Subsequent nodes can access results:

Examples

Process files from directory listing

API pagination pattern

Fault-tolerant LLM processing

Per-item configuration

Each item can override any node parameter through template variables — not just the prompt. Here model and reasoning_effort change per item while the prompt template stays the same.

How your agent chooses settings

For LLM calls, your agent typically:
  • Starts with max_concurrent: 5
  • Monitors rate limits and costs
  • Uses retry_wait for rate limit recovery
For HTTP requests, your agent typically:
  • Checks API rate limits in documentation
  • Uses max_concurrent to respect limits
  • Adds retries for transient errors
For file operations, your agent typically:
  • Uses parallel processing for reads (safe)
  • Uses sequential mode for writes (avoids race conditions)
  • Uses sequential mode when files depend on each other

Limitations

  • No nested batch - You can’t batch a node that’s already in a batch
  • No branching within batch - Each item follows the same code path
  • Memory usage - All results are held in memory until batch completes