#1271·txtai

Multi-action Tasks exhaust iterator inputs and lose streamed workflow results

Author: LimbC-CCreated Sep 24, 2026Updated Sep 24, 2026

Problem

A StreamTask produces an iterator. If the following Task has multiple actions, Task.execute() passes the same iterator to each action. The first consumes it, so later actions see no input. A column-wise merge can silently discard all output.

python
from txtai import Workflow
from txtai.workflow import Task, StreamTask

workflow = Workflow([
    StreamTask(action=lambda value: iter([value])),
    Task(action=[
        lambda values: [v.upper() for v in values],
        lambda values: [v + "!" for v in values],
    ]),
])
print(list(workflow(["a", "b"])))
# Actual: []
# Expected: [("A", "a!"), ("B", "b!")]

The same exhaustion occurs when calling a multi-action Task directly with a generator/list iterator, including per-action column extraction. No model or external service is needed for reproduction. Tested on Windows, Python 3.12.14 with the real NumPy/Torch dependencies.

Proposed fix

Materialize iterator inputs once when a task has more than one action, before building any per-action inputs. Retain existing handling of lists/arrays and keep single-action iterator inputs lazy. Add regressions for streaming workflows, sequential/thread execution, merge modes, column extraction and single-action consumption.

This differs from #291 (materializing generator outputs of an action) and #1268 (RagTask mutating a reusable dictionary). Investigation and the proposed implementation are AI-assisted.