Skip to content

fix(sdk): lock litellm.modify_params around completion calls#3249

Open
nehaaprasaad wants to merge 1 commit into
OpenHands:mainfrom
nehaaprasaad:fix/litellm-mod-prm-con-glb
Open

fix(sdk): lock litellm.modify_params around completion calls#3249
nehaaprasaad wants to merge 1 commit into
OpenHands:mainfrom
nehaaprasaad:fix/litellm-mod-prm-con-glb

Conversation

@nehaaprasaad
Copy link
Copy Markdown

Why

Concurrent LLM completions read/write LiteLLM’s global modify_params without synchronization; one thread’s restore could overwrite another’s active value mid-call.

Summary

  • Added _litellm_modify_params_lock in openhands-sdk/openhands/sdk/llm/llm.py.
  • Wrapped save / assign / yield / restore in _litellm_modify_params_ctx with that lock so chat and responses paths stay consistent under threads.

Issue Number

Closes #3137

How to Test

From repo root: make build then uv run pytest tests/sdk/llm/ -q and uv run pre-commit run --files openhands-sdk/openhands/sdk/llm/llm.py.

Video/Screenshots

N/A (no UI).

Type

  • Bug fix

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.

bug: litellm.modify_params global state race condition under concurrency

1 participant