Skip to content

fix(agno): clean up async streams on iteration errors - #1431

Open
KXHXK wants to merge 1 commit into
AgentOps-AI:mainfrom
KXHXK:fix/agno-async-stream-cleanup
Open

fix(agno): clean up async streams on iteration errors#1431
KXHXK wants to merge 1 commit into
AgentOps-AI:mainfrom
KXHXK:fix/agno-async-stream-cleanup

Conversation

@KXHXK

@KXHXK KXHXK commented Jul 25, 2026

Copy link
Copy Markdown

Description

  • handle exceptions raised after an Agno async stream has started yielding
  • mark the span as ERROR, record the original exception, end the span, and remove its stored context exactly once
  • re-raise the original stream exception to preserve caller behavior
  • add an offline regression test for the post-yield failure path

Without this cleanup, failed async Agent/Team streams leave an unended span and a stale entry in StreamingContextManager.

Closes #1430

Testing

  • uv run ruff check agentops/instrumentation/agentic/agno/instrumentor.py tests/unit/instrumentation/test_agno_instrumentor.py
  • uv run ruff format --check agentops/instrumentation/agentic/agno/instrumentor.py tests/unit/instrumentation/test_agno_instrumentor.py
  • uvx pre-commit run --files agentops/instrumentation/agentic/agno/instrumentor.py tests/unit/instrumentation/test_agno_instrumentor.py
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --no-sync pytest -p pytest_asyncio.plugin -p pytest_mock tests/unit/instrumentation -q (139 passed)

@KXHXK
KXHXK marked this pull request as ready for review July 26, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agno async stream wrapper leaks span/context on post-yield errors (span never ended, no ERROR status)

1 participant