mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-22 00:31:44 +00:00
fix(router): bind fallback_kwargs before try for each iteration
Greptile: except used fallback_kwargs assigned only inside try, risking UnboundLocalError or a stale dict from a prior loop iteration. Set fallback_kwargs = kwargs before each try; first line in try remains safe_deep_copy(kwargs). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
23c27fc305
commit
eba6cc16ee
1 changed files with 4 additions and 0 deletions
|
|
@ -123,6 +123,10 @@ async def run_async_fallback(
|
|||
for mg in fallback_model_group:
|
||||
if mg == original_model_group:
|
||||
continue
|
||||
# Bind before try so except always has a defined dict; reset each
|
||||
# iteration so we never log a stale copy from a prior attempt. Until
|
||||
# safe_deep_copy runs, this aliases the caller kwargs (same as legacy).
|
||||
fallback_kwargs = kwargs
|
||||
try:
|
||||
# Keep each fallback attempt isolated from mutations made while
|
||||
# preparing or sending a previous attempt.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue