@weave.op so that Weave captures their inputs, yielded outputs, and the full hierarchy of nested calls. Use this when you have streaming or lazily evaluated code paths whose outputs you want to inspect in the Weave UI alongside your other traces.
- Python
- TypeScript
deeply_nested_generator, nested_generator, and inner Ops in the trace tree hierarchy.

Consume generators
The following section explains why you must consume generators for Weave to record their outputs, and which consumption patterns work. Weave captures generator outputs only after you fully consume the generator. Consume the generator by iterating over it (for example, withlist(), a for loop, or next() until exhaustion). The same applies to async generators when you use async for or equivalent consumption.
For more information about decorating functions and methods with @weave.op, see Create calls.
Accumulate yielded values into a single trace
If you want Weave to record a combined result (such as a joined string or a list) instead of the raw sequence of yielded values, use an accumulator. You can use theaccumulator parameter of weave.op to customize how yielded values are combined from generator functions, for example, to join streamed text tokens into a single string. The accumulator is a two-argument function that Weave calls once per yielded value, building up a result incrementally.
The
accumulator parameter isn’t available for TypeScript.