Skip to content

fix: make LiteLLM streaming truly asynchronous #1451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

avidelatm
Copy link
Contributor

Description

Fixes #1306 by using async for with await self.llm_client.acompletion() instead of synchronous for loop.

Changes

  • Updated test mocks to properly handle async streaming by creating an async generator
  • Ensured proper parameter handling to avoid duplicate stream parameter

Testing Plan

  • All unit tests now pass with the async streaming implementation
  • Verified with pytest tests/unittests/models/test_litellm.py that all streaming tests pass
  • Manually tested with a sample agent using LiteLLM to confirm streaming works properly

Test Evidence:

https://youtu.be/hSp3otI79DM

Let me know if you need anything else from me for this PR

@selcukgun selcukgun added the ready to pull for importing back to Google label Jun 18, 2025
@selcukgun
Copy link
Collaborator

Thank you for the PR!
LGTM

@thiagosalvatore
Copy link

@selcukgun do you think we can get this released? This is causing a ton of issues in our production usage of ADK

copybara-service bot pushed a commit that referenced this pull request Jun 23, 2025
Merge #1451

## Description
Fixes #1306 by using `async for` with `await self.llm_client.acompletion()` instead of synchronous `for` loop.

## Changes
- Updated test mocks to properly handle async streaming by creating an async generator
- Ensured proper parameter handling to avoid duplicate stream parameter

## Testing Plan
- All unit tests now pass with the async streaming implementation
- Verified with `pytest tests/unittests/models/test_litellm.py` that all streaming tests pass
- Manually tested with a sample agent using LiteLLM to confirm streaming works properly

# Test Evidence:
https://youtu.be/hSp3otI79DM

Let me know if you need anything else from me for this PR

COPYBARA_INTEGRATE_REVIEW=#1451 from avidelatm:fix/litellm-async-streaming d35b9dc
PiperOrigin-RevId: 774835130
@avidelatm
Copy link
Contributor Author

@selcukgun This got merged, do I close the PR now ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to pull for importing back to Google
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LiteLLM streaming not truly asynchronous - returns batch processed chunks
3 participants