Skip to content

Conversation

@majiayu000
Copy link
Contributor

Summary

  • Mark async wrapper's call attribute as async function for tenacity compatibility
  • Tenacity uses is_coroutine_callable which checks call attribute
  • This enables @Retry decorator to work with async llm.call decorated functions

Related Issue

Fixes #989

Test Plan

  • Added test_async_call_is_coroutine_callable to verify tenacity detection
  • Added test_tenacity_retry_with_async_call to verify retry works
  • All existing tests pass

Mark async wrapper's __call__ attribute as async function so tenacity's
is_coroutine_callable helper correctly detects it as an async callable.
This enables tenacity's @Retry decorator to work properly with async
llm.call decorated functions.

Fixes Mirascope#989

Signed-off-by: majiayu000 <[email protected]>
) -> Awaitable[

async def _async_call_impl(
current_context: Any, # noqa: ANN401
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we get a better type here than Any?

@codecov
Copy link

codecov bot commented Dec 30, 2025

Codecov Report

❌ Patch coverage is 96.77419% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.98%. Comparing base (0befca3) to head (4a1736b).

Files with missing lines Patch % Lines
tests/llm/test_call.py 95.45% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1775      +/-   ##
==========================================
- Coverage   99.99%   99.98%   -0.01%     
==========================================
  Files         513      513              
  Lines       21398    21443      +45     
==========================================
+ Hits        21397    21440      +43     
- Misses          1        3       +2     
Flag Coverage Δ
tests 99.98% <96.77%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Retry decorator with collect_errors does not work with async methods

2 participants