From f3cb623ff99e82d58d8e503e3cb289654595ae93 Mon Sep 17 00:00:00 2001 From: themavik Date: Thu, 19 Mar 2026 05:54:47 -0400 Subject: [PATCH] fix: await async wrapped call in streaming agent wrapper (#1280) Root cause: create_streaming_agent_async_wrapper used a synchronous wrapper that called async methods without await, returning a coroutine object instead of the actual async generator result. Made-with: Cursor --- agentops/instrumentation/agentic/agno/instrumentor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/agentops/instrumentation/agentic/agno/instrumentor.py b/agentops/instrumentation/agentic/agno/instrumentor.py index b8d41cbfe..05089f80b 100644 --- a/agentops/instrumentation/agentic/agno/instrumentor.py +++ b/agentops/instrumentation/agentic/agno/instrumentor.py @@ -427,7 +427,7 @@ def wrapper(wrapped, instance, args, kwargs): def create_streaming_agent_async_wrapper(tracer, streaming_context_manager): """Create a streaming-aware async wrapper for agent run methods.""" - def wrapper(wrapped, instance, args, kwargs): + async def wrapper(wrapped, instance, args, kwargs): import inspect # Get agent ID for context storage @@ -465,7 +465,7 @@ def wrapper(wrapped, instance, args, kwargs): # Execute the original function within agent context context_token = otel_context.attach(current_context) try: - result = wrapped(*args, **kwargs) + result = await wrapped(*args, **kwargs) finally: otel_context.detach(context_token) @@ -880,7 +880,7 @@ def wrapper(wrapped, instance, args, kwargs): def create_team_async_wrapper(tracer, streaming_context_manager): """Create an async wrapper for Team methods that establishes the team context.""" - def wrapper(wrapped, instance, args, kwargs): + async def wrapper(wrapped, instance, args, kwargs): import inspect # Get team ID for context storage @@ -910,7 +910,7 @@ def wrapper(wrapped, instance, args, kwargs): # Execute the original function within team context context_token = otel_context.attach(current_context) try: - result = wrapped(*args, **kwargs) + result = await wrapped(*args, **kwargs) finally: otel_context.detach(context_token)