Files
DeepTutor/tests
truffle eb3cd9a3fa fix(llm): map max_completion_tokens to max_output_tokens for Responses API
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.
2026-05-03 02:18:34 +00:00
..
2026-05-02 20:16:07 +08:00
2026-05-01 13:51:45 +08:00
2026-05-01 13:51:45 +08:00
2026-04-23 19:29:16 +08:00
2026-05-01 01:39:08 +08:00
2026-05-02 20:16:07 +08:00
2026-05-01 01:39:08 +08:00
2026-05-01 01:39:08 +08:00
2026-04-23 19:29:16 +08:00
2026-05-02 20:16:07 +08:00
2026-04-28 12:00:11 +08:00
2026-05-01 13:51:45 +08:00
2026-04-23 19:29:16 +08:00