Skip to content

feat(litellm): Add async callbacks#5969

Merged
alexander-alderman-webb merged 51 commits intomasterfrom
webb/litellm/async-hooks
Apr 13, 2026
Merged

feat(litellm): Add async callbacks#5969
alexander-alderman-webb merged 51 commits intomasterfrom
webb/litellm/async-hooks

Conversation

@alexander-alderman-webb
Copy link
Copy Markdown
Contributor

@alexander-alderman-webb alexander-alderman-webb commented Apr 10, 2026

Description

Add asynchronous variants of callbacks to litellm.input_callback and litellm.success_callback

Issues

Reminders

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 10, 2026

Codecov Results 📊

100 passed | ⏭️ 1 skipped | Total: 101 | Pass Rate: 99.01% | Execution Time: 33.64s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +49
Passed Tests 📈 +51
Failed Tests
Skipped Tests 📉 -2

All tests are passing successfully.

❌ Patch coverage is 0.00%. Project has 14749 uncovered lines.
✅ Project coverage is 30.69%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
litellm.py 0.00% ⚠️ 147 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    26.75%    30.69%    +3.94%
==========================================
  Files          191       191         —
  Lines        21282     21279        -3
  Branches      7006      7010        +4
==========================================
+ Hits          5692      6530      +838
- Misses       15590     14749      -841
- Partials       490       537       +47

Generated by Codecov Action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 10, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (ai) Redact base64 data URLs in image_url content blocks by ericapisani in #5953
  • (integrations) Instrument pyreqwest tracing by servusdei2018 in #5682
  • (litellm) Add async callbacks by alexander-alderman-webb in #5969

Bug Fixes 🐛

Anthropic

  • Capture exceptions for stream() calls by alexander-alderman-webb in #5950
  • Stop setting transaction status when child span fails by alexander-alderman-webb in #5717
  • Only finish relevant spans in .create() patches by alexander-alderman-webb in #5716

Pydantic Ai

  • Adapt import for new library versions by alexander-alderman-webb in #5984
  • Use first-class hooks when available by alexander-alderman-webb in #5947

Other

  • (huggingface_hub) Stop setting transaction status when a child span fails by Zenithatic in #5952
  • (litellm) Avoid double span exits when streaming by alexander-alderman-webb in #5933
  • (wsgi) Respect HTTP_X_FORWARDED_PROTO in request.url construction by sl0thentr0py in #5963

Internal Changes 🔧

Litellm

  • Replace mocks with httpx types in rate-limit test by alexander-alderman-webb in #5975
  • Replace mocks with httpx types in embedding tests by alexander-alderman-webb in #5970
  • Replace mocks with httpx types in nonstreaming completion() tests by alexander-alderman-webb in #5937
  • Remove dead attributes by alexander-alderman-webb in #5985

Other

  • (ai) Remove gen_ai.tool.type span attribute by ericapisani in #5964
  • (anthropic) Separate sync and async .create() patches by alexander-alderman-webb in #5715
  • (openai) Split token counting by API for easier deprecation by ericapisani in #5930
  • (openai-agents) Remove error attributes by alexander-alderman-webb in #5986
  • (opentelemetry) Ignore mypy error by alexander-alderman-webb in #5927
  • 🤖 Update test matrix with new releases (04/13) by github-actions in #5983
  • Fix license metadata in setup.py by sl0thentr0py in #5934
  • Update validate-pr workflow by stephanie-anderson in #5931

Other

  • Handle None span context in the span processor and pin tokenizers version for anthropic tests on Python 3.8 by alexander-alderman-webb in #5967

🤖 This preview updates automatically when you update the PR.

@alexander-alderman-webb alexander-alderman-webb changed the base branch from webb/litellm/remove-mocks to webb/litellm/error-mock April 10, 2026 12:01
Base automatically changed from webb/litellm/error-mock to webb/litellm/embedding-tests April 10, 2026 13:05
@alexander-alderman-webb alexander-alderman-webb changed the base branch from webb/litellm/embedding-tests to webb/litellm/rate-limit-mock April 10, 2026 13:11
@alexander-alderman-webb alexander-alderman-webb requested a review from a team as a code owner April 10, 2026 14:01
@alexander-alderman-webb alexander-alderman-webb marked this pull request as draft April 10, 2026 14:47
@alexander-alderman-webb alexander-alderman-webb marked this pull request as ready for review April 13, 2026 08:48
Base automatically changed from webb/litellm/rate-limit-mock to master April 13, 2026 16:10
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Test mocks embeddings path instead of completions
    • Updated test_async_exception_handling to patch client.completions._client._client so the mock target matches the litellm.acompletion code path.

Create PR

Or push these changes by commenting:

@cursor push 270c50b1f3
Preview (270c50b1f3)
diff --git a/tests/integrations/litellm/test_litellm.py b/tests/integrations/litellm/test_litellm.py
--- a/tests/integrations/litellm/test_litellm.py
+++ b/tests/integrations/litellm/test_litellm.py
@@ -867,7 +867,7 @@
     model_response = get_rate_limit_model_response()
 
     with mock.patch.object(
-        client.embeddings._client._client,
+        client.completions._client._client,
         "send",
         return_value=model_response,
     ):

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6626a1b. Configure here.

@alexander-alderman-webb alexander-alderman-webb merged commit c0c0e9c into master Apr 13, 2026
158 checks passed
@alexander-alderman-webb alexander-alderman-webb deleted the webb/litellm/async-hooks branch April 13, 2026 16:36
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