Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

fix: exclude empty stop parameter from LLM completion params

Summary

Fixes issue #4149 where models like GPT-5.1 throw an error: "Unsupported parameter: 'stop' is not supported with this model."

The root cause was that _prepare_completion_params always included stop in the params dict, even when it was an empty list []. Some models (e.g., gpt-5.1) don't support the stop parameter at all, and passing even an empty list causes an API error.

Changes:

  • Modified _prepare_completion_params to only include stop when it has values AND is not in additional_drop_params
  • Added 4 unit tests to verify the fix and prevent regression

This also ensures the existing retry logic works correctly - when a model rejects stop, the error handler adds "stop" to additional_drop_params, and subsequent calls will now properly exclude it.

Review & Testing Checklist for Human

  • Test with a model that doesn't support stop (e.g., gpt-5.1, o1-mini) to verify the error no longer occurs
  • Test with a model that DOES support stop words (e.g., gpt-4o) with explicit stop sequences to verify they still work correctly
  • Verify the retry logic still works: if a model unexpectedly rejects stop, the retry should succeed

Notes

This fixes issue #4149 where models like gpt-5.1 don't support the
stop parameter at all. Previously, an empty list was always passed
to the API, causing an error.

Changes:
- Only include stop in params when it has values (non-empty)
- Respect additional_drop_params to ensure retry logic works correctly
- Add tests to verify the fix

Co-Authored-By: João <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

1 participant