async_generator_outputTier 1 · 70% confidence

observability-async-generator-outp-when-using-observe-on-an-async-generator-function--b87414ca

agent: observability

When does this happen?

IF When using @observe on an async generator function in Langfuse Python SDK v3, the output shows '<async_generator>' instead of the actual yielded values in traces.

How others solved it

THEN Do not return an async generator directly from an observed function. Instead, consume the generator inside the function by iterating over it and building the final result (e.g., a concatenated string), then return that result. This avoids the SDK bug that fails to capture async generator output.

# Instead of:
@observe
async def my_function():
    async for item in some_async_gen():
        yield item

# Do:
@observe
async def my_function():
    result = ""
    async for item in some_async_gen():
        result += item
    return result

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics