-
Notifications
You must be signed in to change notification settings - Fork 56
tests(llm): add explicit retry behavior tests for empty choices
#1107
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…onseError) - Retries then succeeds - Exhausts retries and bubbles LLMNoResponseError - Verifies temperature bump from 0.0 -> 1.0 on retry Co-authored-by: openhands <openhands@all-hands.dev>
Contributor
Coverage Report •
|
||||||||||||||||||||
…pty choices Add comment near choices validation to make retry semantics explicit. Co-authored-by: openhands <openhands@all-hands.dev>
…LMNoResponseError Co-authored-by: openhands <openhands@all-hands.dev>
choices (LLMNoResponseError)choices
neubig
approved these changes
Nov 10, 2025
Contributor
neubig
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for checking this! I'm going to have to dig in deeper to the error, I'll try to share a version of what happened in a new issue description.
neubig
pushed a commit
that referenced
this pull request
Nov 10, 2025
…mping Some LLM providers (e.g., Gemini) occasionally return malformed responses with choices=None. When this happens, litellm may raise InternalServerError during internal validation before returning the response to our code. Previously, these InternalServerErrors were retried, but without temperature bumping. Since temperature=0.0 is deterministic, all retries would hit the same provider bug and fail. This change detects InternalServerErrors related to malformed choices and converts them to LLMNoResponseError. This enables the RetryMixin's adaptive behavior, which bumps temperature from 0.0 to 1.0 on retry. The temperature change makes the provider's response generation non-deterministic, which can help avoid the same bug on subsequent attempts. This complements PR #1107, which handles the case where litellm successfully returns a response with empty choices. Together, these changes ensure temperature bumping happens regardless of where the choices validation fails. Co-authored-by: openhands <openhands@all-hands.dev>
neubig
pushed a commit
that referenced
this pull request
Nov 10, 2025
…mping Some LLM providers occasionally return malformed responses with choices=None. When this happens, litellm may raise InternalServerError during internal validation (in convert_to_model_response_object) before returning the response to our code. Previously, these InternalServerErrors were retried, but without temperature bumping. Since temperature=0.0 is deterministic, all retries would hit the same provider bug and fail. This change detects InternalServerErrors related to litellm's response_object validation and converts them to LLMNoResponseError. This enables the RetryMixin's adaptive behavior, which bumps temperature from 0.0 to 1.0 on retry. The temperature change makes the provider's response generation non-deterministic, which can help avoid the same bug on subsequent attempts. The detection is specific to litellm's internal validation patterns: - response_object AND choices - choices AND is not None - convert_to_model_response_object This complements PR #1107, which handles the case where litellm successfully returns a response with empty choices. Together, these changes ensure temperature bumping happens regardless of where the choices validation fails. Co-authored-by: openhands <openhands@all-hands.dev>
neubig
pushed a commit
that referenced
this pull request
Nov 10, 2025
…mping Some LLM providers occasionally return malformed responses with choices=None. When this happens, litellm raises InternalServerError during internal validation in convert_to_model_response_object before returning the response to our code. Previously, these InternalServerErrors were retried, but without temperature bumping. Since temperature=0.0 is deterministic, all retries would hit the same provider bug and fail. This change detects InternalServerErrors from convert_to_model_response_object and converts them to LLMNoResponseError. This enables the RetryMixin's adaptive behavior, which bumps temperature from 0.0 to 1.0 on retry. The temperature change makes the provider's response generation non-deterministic, which can help avoid the same bug on subsequent attempts. The detection checks for 'convert_to_model_response_object' in the error message, which is the specific function where litellm validates the response_object['choices'] field. This complements PR #1107, which handles the case where litellm successfully returns a response with empty choices. Together, these changes ensure temperature bumping happens regardless of where the choices validation fails. Co-authored-by: openhands <openhands@all-hands.dev>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds targeted tests to validate how the SDK handles LiteLLM responses with empty
choices— a scenario observed with some providers (e.g., Gemini). These tests ensure that:choicesis None/emptyScope
Details
Added tests/sdk/llm/test_llm_no_response_retry.py with three cases:
choices, second is valid → returns LLMResponsechoices→ raises LLMNoResponseErrorWhy this matters
Empty
choicescan occur due to transient provider issues. We want to:Notes
Co-authored-by: openhands openhands@all-hands.dev
@enyst can click here to continue refining the PR
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.12-nodejs22golang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:a2f54f1-pythonRun
All tags pushed for this build
About Multi-Architecture Support
a2f54f1-python) is a multi-arch manifest supporting both amd64 and arm64a2f54f1-python-amd64) are also available if needed