ai-sdk: the OpenAI chat provider emits max_tokens for models that require max_completion_tokens #1646

Closed
opened 2026-10-27 13:41:13 +00:00 by sam · 0 comments
Owner

Cross-repo root cause behind archie-core bead 7zu3. In ai-sdk (the pinned release archie-core consumes), provider/openai/chat_completions.go writes body[max_tokens] whenever the request sets a max-token bound, while reasoning-class models reject that parameter with HTTP 400 and require max_completion_tokens instead. The same module already resolves ModelInfo per model but the chat runtime discards its reasoning flag, so the provider has nothing to switch on. The Responses path in the same provider already renames the parameter, so the pattern exists; the chat-completions path needs the same class-aware choice. Durable fix: carry the reasoning flag into the provider request and select the parameter name from it, then release and bump archie-core's pin. Until then archie-core carries a mitigation (omit the bound for reasoning-class models).

Acceptance criteria

a reasoning-class model streams through the chat-completions path with a max-token bound honoured via max_completion_tokens, and a classic model still sends max_tokens; provider-level test covering both classes

Close reason

Moved to ai-sdk; tracked and fixed there.


Imported from beads archie-core-wivg · GitHub #1337 · type bug · priority P2 · created 2026-10-02 · closed 2026-10-05

Cross-repo root cause behind archie-core bead 7zu3. In ai-sdk (the pinned release archie-core consumes), provider/openai/chat_completions.go writes body[max_tokens] whenever the request sets a max-token bound, while reasoning-class models reject that parameter with HTTP 400 and require max_completion_tokens instead. The same module already resolves ModelInfo per model but the chat runtime discards its reasoning flag, so the provider has nothing to switch on. The Responses path in the same provider already renames the parameter, so the pattern exists; the chat-completions path needs the same class-aware choice. Durable fix: carry the reasoning flag into the provider request and select the parameter name from it, then release and bump archie-core's pin. Until then archie-core carries a mitigation (omit the bound for reasoning-class models). ### Acceptance criteria a reasoning-class model streams through the chat-completions path with a max-token bound honoured via max_completion_tokens, and a classic model still sends max_tokens; provider-level test covering both classes ### Close reason Moved to ai-sdk; tracked and fixed there. --- _Imported from beads `archie-core-wivg` · GitHub #1337 · type bug · priority P2 · created 2026-10-02 · closed 2026-10-05_
sam added the bugmedium labels 2026-10-27 13:41:13 +00:00
sam self-assigned this 2026-10-27 13:41:13 +00:00
sam closed this issue 2026-10-27 13:41:14 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1646