Skip to content

[Bug]: AgentOps breaks async streaming in Agno frameworkΒ #1262

@james-3rdbrain

Description

@james-3rdbrain

Contact Details

james@3rdbrain.co

πŸ“¦ Package Version

0.4.21

🎞️ Framework Version

Agno 2.1.0, Python 3.12

πŸ”Ž Describe the Bug

Got the following error, trying to initialize AgentOps as part of my Agno team setup.

Using FastAPI, and making use of stream=True and async runs for all my agents/team.

'async for' requires an object with aiter method, got coroutine


Expected vs actual behavior:

  • Expected: Streaming works as normal
  • Actual: Returns coroutine instead of async generator

Workaround:

  • Removing agentops.init() fixes the issue

Additional context:

  • Works fine without AgentOps
  • Breaks immediately after adding agentops.init()
  • Likely related to instrumentation/monkey-patching of async methods

import agentops
from agno.team import Team
from agno.models.openai import OpenAIChat

agentops.init(api_key="your-key")

team = Team(model=OpenAIChat(id="gpt-4"), ...)

This breaks after agentops.init()

async for event in team.arun(query, stream=True, stream_intermediate_steps=True):
yield event

🀝 Contribution

  • Yes, I'd be happy to submit a pull request with these changes.
  • I need some guidance on how to contribute.
  • I'd prefer the AgentOps team to handle this update.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions