Skip to content

Fix top_p null still sent in API requests after #385#415

Open
toslali-ibm wants to merge 1 commit intoalgorithmicsuperintelligence:mainfrom
toslali-ibm:toppfix
Open

Fix top_p null still sent in API requests after #385#415
toslali-ibm wants to merge 1 commit intoalgorithmicsuperintelligence:mainfrom
toslali-ibm:toppfix

Conversation

@toslali-ibm
Copy link

Summary

PR #385 (closing #378) made top_p optional and defaulted it to None in LLMConfig, but the API call layer in openevolve/llm/openai.py still unconditionally includes top_p in the request params:

params = {
    ...
    "top_p": kwargs.get("top_p", self.top_p),  # sends None when top_p is unset
    ...
}

This puts "top_p": None into the params dict. Providers like AWS Bedrock, LiteLLM, and other OpenAI-compatible wrappers may serialize it as "top_p": null in the JSON body, triggering a 400 error.

Fix: Only include top_p in params when it is explicitly set (not None).

Changes

  • openevolve/llm/openai.py: Conditionally include top_p in request params only when not None

Test plan

Fixes #414

…lligence#385

PR algorithmicsuperintelligence#385 made top_p optional and defaulted it to None in LLMConfig,
but openai.py still unconditionally includes top_p in the request
params dict. This sends "top_p": null to providers like AWS Bedrock
that don't strip null values, causing 400 errors.

Only include top_p in params when it is explicitly set.

Fixes algorithmicsuperintelligence#414

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@toslali-ibm
Copy link
Author

toslali-ibm commented Feb 24, 2026

@codelion This is a follow-up to your #385 fix — it addressed the config layer but openai.py still unconditionally includes top_p in the request params, which sends null to providers that don't strip it (e.g. Bedrock). Small 3-line fix.

Let me know your comments.
Thanks!

@CLAassistant
Copy link

CLAassistant commented Feb 24, 2026

CLA assistant check
All committers have signed the CLA.

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.

top_p: null still sent in API requests after #385 fix, causing errors on Bedrock and other providers

2 participants