481 strip frequency penalty#482
Open
Omarhus01 wants to merge 2 commits into
Open
Conversation
Author
|
For context on why I picked this fix: I was running through the AdalFlow quickstart while reading the LLM-AutoDiff paper, and the breakage in the Object Count training loop blocks exactly the demonstration the paper builds on — selective gradient computation on a teacher generator, which is o3-mini in this notebook. Happy to extend this to other params ( |
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
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.
What does this PR do?
Fixes #481
Problem
When AdalFlow is used with OpenAI reasoning models (o1, o3, o3-mini, o4, gpt-5 family), every API call fails with:
Responses.create() got an unexpected keyword argument 'frequency_penalty'This breaks the official quickstart Colab notebook and any user code that passes
frequency_penalty(a common default) when using a reasoning model. OpenAI's Responses API rejectsfrequency_penaltyfor reasoning models, but AdalFlow forwards all kwargs unconditionally.Fix
Adds a
_strip_unsupported_reasoning_kwargshelper onOpenAIClientthat:o1,o3,o4,gpt-5)._UNSUPPORTED_REASONING_KWARGS).The helper is invoked at the top of the LLM/LLM_REASONING branch in both
callandacall, so both sync and async paths are covered.Scope
Conservative on purpose: only
frequency_penaltyis stripped right now, since that is the parameter confirmed broken in #481. The constant_UNSUPPORTED_REASONING_KWARGSis a tuple so additional params (presence_penalty,top_p,logit_bias, etc.) can be added in follow-up PRs as they are independently confirmed.Tests
Added four unit tests in
adalflow/tests/test_openai_client.py:frequency_penaltyis stripped for each reasoning prefix (o1,o3-mini,o4-turbo,gpt-5).frequency_penaltyis preserved for non-reasoning models (e.g.gpt-4o).temperature,max_tokens) are left intact.Before submitting