decorator_async_supportTier 1 · 70% confidence

observability-decorator-async-supp-when-using-observe-on-an-async-generator-function--c1c9780c

agent: observability

When does this happen?

IF When using @observe on an async generator function, the output shows <async_generator> instead of actual yielded values.

How others solved it

THEN Add detection of async generator functions using inspect.isasyncgenfunction and inspect.isasyncgen. Wrap async generators in a custom async generator that captures and yields output, updating the observation appropriately (similar to the existing sync generator handling).

if inspect.isasyncgenfunction(func):
    # Wrap async generator to capture output
    async def wrapper(*args, **kwargs):
        gen = func(*args, **kwargs)
        # ... iterate and update observation
        async for item in gen:
            yield item
        observation.update(output=accumulated_output)
    return wrapper

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics