Skip to content

feat: Improve compatibility with agno 2.5.0#41

Merged
Abhijeet Prasad (AbhiPrasad) merged 2 commits intomainfrom
abhi-argo-integration-improvements
Mar 5, 2026
Merged

feat: Improve compatibility with agno 2.5.0#41
Abhijeet Prasad (AbhiPrasad) merged 2 commits intomainfrom
abhi-argo-integration-improvements

Conversation

@AbhiPrasad
Copy link
Copy Markdown
Member

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) commented Mar 4, 2026

resolves https://linear.app/braintrustdata/issue/BRA-4192/agno-integration-improvements

AI Summary

This PR hardens and modernizes the Agno integration to support the API changes introduced around the Agno 2.4 -> 2.5 transition, while preserving compatibility with older versions.

Why this change was needed

Agno’s run execution model changed significantly:

  • older versions relied heavily on private methods like _run/_arun/_run_stream/_arun_stream
  • newer versions moved execution behind public dispatcher methods (run/arun) with mixed return contracts (direct value, iterator, async iterator, awaitable returning async iterator)

Our wrapper previously had gaps in these newer async/streaming paths:

  • spans could end too early for awaited async-stream dispatchers
  • streamed task metrics could be dropped in aggregation for object-like metrics payloads
  • duplicated wrapper logic in agent.py/team.py made this behavior harder to maintain safely

What changed

Integration behavior

  • Updated public run/arun wrapping logic for both Agent and Team to handle all dispatcher return shapes correctly.
  • Fixed async streaming lifecycle bug: spans now remain open until stream consumption completes (no premature span.end()).
  • Fixed streamed task metrics aggregation so token metrics are preserved even when metrics are object-like.

Refactor / maintainability

  • Extracted shared public dispatch wrapping logic into:
    • py/src/braintrust/wrappers/agno/run_helpers.py
  • Reduced duplication between Agent and Team wrappers.

Tests

Expanded py/src/braintrust/wrappers/test_agno.py with coverage for:

  • public dispatcher streaming (sync + async)
  • awaited async iterator dispatch path
  • non-stream async dispatch path
  • sync/async stream error paths
  • early-break stream consumption paths
  • parent span nesting
  • private-method precedence over public dispatch methods
  • strict span lifecycle regression checks

Also added short explanatory docstrings for complex tests.

Version matrix

  • Updated Agno nox matrix to:
    • LATEST, 2.4.0, 2.1.0
  • Added comment explaining this covers newest API plus the key 2.4→2.5 transition boundary.

User-facing changes

  • Positive behavior change for users on newer Agno versions:
    • more reliable tracing in async streaming paths
    • correct span timing/lifecycle for dispatcher-based arun(..., stream=True)
    • improved streamed token metrics capture in task spans
  • No breaking API changes to Braintrust wrapper usage (setup_agno(...) remains the same).

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) force-pushed the abhi-argo-integration-improvements branch from 8803089 to c3bf48e Compare March 4, 2026 21:53
@AbhiPrasad Abhijeet Prasad (AbhiPrasad) merged commit 8695a8e into main Mar 5, 2026
33 checks passed
@AbhiPrasad Abhijeet Prasad (AbhiPrasad) deleted the abhi-argo-integration-improvements branch March 5, 2026 19:57
@AbhiPrasad Abhijeet Prasad (AbhiPrasad) changed the title feat: Improve compatibility with argo 2.5.0 feat: Improve compatibility with agno 2.5.0 Mar 6, 2026
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.

2 participants