From 37d147caa1b435e7fa6731804c3236db3d41ce7e Mon Sep 17 00:00:00 2001 From: Shiva Kumar Date: Thu, 20 Aug 2026 18:34:40 +0530 Subject: [PATCH] fix(openai): route max_completion_tokens for namespaced GPT-5 and reasoning models (#5498) --- src/openhuman/inference/http/server.rs | 6 ++++-- src/openhuman/inference/http/types.rs | 2 ++ vendor/tinyagents | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/openhuman/inference/http/server.rs b/src/openhuman/inference/http/server.rs index 281fe3b13b..b5bad679ed 100644 --- a/src/openhuman/inference/http/server.rs +++ b/src/openhuman/inference/http/server.rs @@ -144,10 +144,12 @@ async fn chat_completions_handler( }; let completion_id = format!("chatcmpl-{}", uuid::Uuid::new_v4()); let created = chrono::Utc::now().timestamp(); - let model_name = req.model.clone(); - let model_request = ModelRequest::new(messages) + let mut model_request = ModelRequest::new(messages) .with_model(model_id.clone()) .with_temperature(temperature); + if let Some(tokens) = req.max_completion_tokens.or(req.max_tokens) { + model_request = model_request.with_max_tokens(tokens); + } if req.stream { let model_stream = match chat_model.stream(&(), model_request).await { diff --git a/src/openhuman/inference/http/types.rs b/src/openhuman/inference/http/types.rs index 6bf58fe518..8ed2153e6f 100644 --- a/src/openhuman/inference/http/types.rs +++ b/src/openhuman/inference/http/types.rs @@ -14,6 +14,8 @@ pub struct ChatCompletionRequest { pub temperature: Option, #[serde(default)] pub max_tokens: Option, + #[serde(default)] + pub max_completion_tokens: Option, /// Optional tool definitions (ignored if the provider doesn't support them). #[serde(default)] pub tools: Option, diff --git a/vendor/tinyagents b/vendor/tinyagents index c6a5f24bd0..a610adb4b8 160000 --- a/vendor/tinyagents +++ b/vendor/tinyagents @@ -1 +1 @@ -Subproject commit c6a5f24bd015fc2acfa423b161cedfdbc47bae12 +Subproject commit a610adb4b826143ee9fcb6bc146183af100ee89c