mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 05:20:33 +08:00
When the Responses API path is selected for newer OpenAI models (gpt-5.x, o1, o3, o4) and an extra kwarg of `max_completion_tokens` flows in (typically from `get_token_limit_kwargs(model, n)`), the OpenAI SDK raises `TypeError` from `responses.create()` before any HTTP request leaves the client. `_should_fallback_from_responses_error()` only catches HTTP errors that carry a `status_code`, so the call is never retried via Chat Completions; the user just sees a stack trace. The bug exists on both OpenAICompatProvider and AzureOpenAIProvider, in the chat and chat_stream paths (4 sites total). Add `adapt_chat_kwargs_to_responses()` that translates the alias to `max_output_tokens` and is used at all four merge sites. The helper: - preserves the existing `None`-drop semantics of the previous dict-comprehension merge, - only applies the alias when `max_output_tokens` is not explicitly set by the caller, - does not mutate the input. Closes #437.