Skip to content

Commit d98676f

Browse files
authored
Support GPT-5.2 and GPT-5.2 Pro (#1266)
<!-- Thank you for opening a pull request! Please add a brief description of the proposed change here. Also, please tick the appropriate points in the checklist below. --> ## Motivation and Context <!-- Why is this change needed? What problem does it solve? --> Add GPT-5.2 to Koog #1265 Add support for GPT-5.2 and GPT-5.2 Pro models via OpenAI and OpenRouter clients; update parsing, tests, and integration scenarios. ## Breaking Changes <!-- Will users need to update their code or configurations? --> --- #### Type of the changes - [x] New feature (non-breaking change which adds functionality) - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Tests improvement - [ ] Refactoring #### Checklist - [x] The pull request has a description of the proposed change - [x] I read the [Contributing Guidelines](https://github.com/JetBrains/koog/blob/main/CONTRIBUTING.md) before opening the pull request - [x] The pull request uses **`develop`** as the base branch - [x] Tests for the changes have been added - [x] All new and existing tests passed ##### Additional steps for pull requests adding a new feature - [x] An issue describing the proposed change exists - [x] The pull request includes a link to the issue - [x] The change was discussed and approved in the issue - [x] Docs have been added / updated
1 parent 3cec11d commit d98676f

File tree

8 files changed

+132
-8
lines changed

8 files changed

+132
-8
lines changed

integration-tests/src/jvmTest/kotlin/ai/koog/integration/tests/agent/AIAgentIntegrationTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ class AIAgentIntegrationTest : AIAgentTestBase() {
12541254
strategy: HistoryCompressionStrategy,
12551255
strategyName: String
12561256
) = runTest(timeout = 10.minutes) {
1257-
val model = OpenAIModels.Chat.GPT5_1
1257+
val model = OpenAIModels.Chat.GPT5_2
12581258
val systemMessage = "You are a helpful assistant. JUST CALL THE TOOLS, NO QUESTIONS ASKED."
12591259

12601260
val historyCompressionStrategy = buildHistoryCompressionWithToolsStrategy(

integration-tests/src/jvmTest/kotlin/ai/koog/integration/tests/agent/AIAgentTestBase.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ open class AIAgentTestBase {
345345
return AIAgent(
346346
promptExecutor = executor,
347347
strategy = strategy,
348-
agentConfig = AIAgentConfig(prompt, OpenAIModels.Chat.GPT5_1, maxAgentIterations),
348+
agentConfig = AIAgentConfig(prompt, OpenAIModels.Chat.GPT5_2, maxAgentIterations),
349349
toolRegistry = tools,
350350
) {
351351
install(EventHandler, eventHandlerConfig)

integration-tests/src/jvmTest/kotlin/ai/koog/integration/tests/utils/MediaTestScenarios.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ object MediaTestScenarios {
6363
val models = listOf(
6464
AnthropicModels.Sonnet_4_5,
6565
GoogleModels.Gemini2_5Pro,
66-
OpenAIModels.Chat.GPT5_1,
66+
OpenAIModels.Chat.GPT5_2,
6767
)
6868

6969
@JvmStatic

integration-tests/src/jvmTest/kotlin/ai/koog/integration/tests/utils/Models.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object Models {
1717
@JvmStatic
1818
fun openAIModels(): Stream<LLModel> {
1919
return Stream.of(
20-
OpenAIModels.Chat.GPT5_1, // reasoning
20+
OpenAIModels.Chat.GPT5_2, // reasoning
2121
OpenAIModels.Chat.GPT4_1, // non-reasoning
2222
OpenAIModels.Chat.GPT5_1Codex
2323
)
@@ -103,7 +103,7 @@ object Models {
103103
@JvmStatic
104104
fun reasoningCapableModels(): Stream<LLModel> {
105105
return Stream.of(
106-
OpenAIModels.Chat.GPT5_1,
106+
OpenAIModels.Chat.GPT5_2,
107107
AnthropicModels.Haiku_4_5,
108108
GoogleModels.Gemini2_5Pro,
109109
GoogleModels.Gemini3_Pro_Preview,

koog-ktor/src/commonMain/kotlin/ai/koog/ktor/utils/LLMModelParser.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,17 @@ internal fun getModelFromIdentifier(identifier: String): LLModel? {
3030

3131
return when (providerName) {
3232
"openai" -> openAI(parts, identifier)
33+
3334
"anthropic" -> anthropic(parts, identifier)
35+
3436
"google" -> google(parts, identifier)
37+
3538
"mistral" -> mistral(parts, identifier)
39+
3640
"openrouter" -> openrouter(parts, identifier)
41+
3742
"deepseek" -> deepSeek(parts, identifier)
43+
3844
"ollama" -> ollama(parts, identifier)
3945

4046
else -> {
@@ -220,6 +226,8 @@ private val OPENAI_MODELS_MAP = mapOf(
220226
"gpt5_1" to OpenAIModels.Chat.GPT5_1,
221227
"gpt5pro" to OpenAIModels.Chat.GPT5Pro,
222228
"gpt5_1codex" to OpenAIModels.Chat.GPT5_1Codex,
229+
"gpt5_2" to OpenAIModels.Chat.GPT5_2,
230+
"gpt5_2pro" to OpenAIModels.Chat.GPT5_2Pro,
223231
"gpt4_1nano" to OpenAIModels.Chat.GPT4_1Nano,
224232
"gpt4_1mini" to OpenAIModels.Chat.GPT4_1Mini,
225233
"gpt4omini" to OpenAIModels.Chat.GPT4oMini,
@@ -289,14 +297,16 @@ private val OPENROUTER_MODELS_MAP = mapOf(
289297
"claude35sonnet" to OpenRouterModels.Claude3_5Sonnet,
290298
"claude4sonnet" to OpenRouterModels.Claude4Sonnet,
291299
"claude41opus" to OpenRouterModels.Claude4_1Opus,
300+
"gpt35turbo" to OpenRouterModels.GPT35Turbo,
292301
"gpt4" to OpenRouterModels.GPT4,
302+
"gpt4turbo" to OpenRouterModels.GPT4Turbo,
293303
"gpt4o" to OpenRouterModels.GPT4o,
304+
"gptoss120b" to OpenRouterModels.GPT_OSS_120b,
294305
"gpt5" to OpenRouterModels.GPT5,
295306
"gpt5mini" to OpenRouterModels.GPT5Mini,
296307
"gpt5nano" to OpenRouterModels.GPT5Nano,
297-
"gptoss120b" to OpenRouterModels.GPT_OSS_120b,
298-
"gpt4turbo" to OpenRouterModels.GPT4Turbo,
299-
"gpt35turbo" to OpenRouterModels.GPT35Turbo
308+
"gpt52" to OpenRouterModels.GPT5_2,
309+
"gpt52pro" to OpenRouterModels.GPT5_2Pro,
300310
)
301311

302312
private val DEEPSEEK_MODELS_MAP = mapOf(

koog-ktor/src/commonTest/kotlin/ai/koog/ktor/ModelIdentifierParsingTest.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,18 @@ class ModelIdentifierParsingTest {
114114
assertNotNull(gpt5_1codex)
115115
assertEquals(LLMProvider.OpenAI, gpt5_1codex.provider)
116116
assertEquals(OpenAIModels.Chat.GPT5_1Codex, gpt5_1codex)
117+
118+
// Test GPT-5.2
119+
val gpt5_2 = getModelFromIdentifier("openai.chat.gpt5_2")
120+
assertNotNull(gpt5_2)
121+
assertEquals(LLMProvider.OpenAI, gpt5_2.provider)
122+
assertEquals(OpenAIModels.Chat.GPT5_2, gpt5_2)
123+
124+
// Test GPT-5.2-Pro
125+
val gpt5_2pro = getModelFromIdentifier("openai.chat.gpt5_2pro")
126+
assertNotNull(gpt5_2pro)
127+
assertEquals(LLMProvider.OpenAI, gpt5_2pro.provider)
128+
assertEquals(OpenAIModels.Chat.GPT5_2Pro, gpt5_2pro)
117129
}
118130

119131
@Test
@@ -318,6 +330,18 @@ class ModelIdentifierParsingTest {
318330
assertNotNull(gpt35Turbo)
319331
assertEquals(LLMProvider.OpenRouter, gpt35Turbo.provider)
320332
assertEquals(OpenRouterModels.GPT35Turbo, gpt35Turbo)
333+
334+
// Test GPT-5.2
335+
val gpt5_2 = getModelFromIdentifier("openrouter.gpt52")
336+
assertNotNull(gpt5_2)
337+
assertEquals(LLMProvider.OpenRouter, gpt5_2.provider)
338+
assertEquals(OpenRouterModels.GPT5_2, gpt5_2)
339+
340+
// Test GPT-5.2 Pro
341+
val gpt5_2pro = getModelFromIdentifier("openrouter.gpt52pro")
342+
assertNotNull(gpt5_2pro)
343+
assertEquals(LLMProvider.OpenRouter, gpt5_2pro.provider)
344+
assertEquals(OpenRouterModels.GPT5_2Pro, gpt5_2pro)
321345
}
322346

323347
// DeepSeek model identifier tests

prompt/prompt-executor/prompt-executor-clients/prompt-executor-openai-client/src/commonMain/kotlin/ai/koog/prompt/executor/clients/openai/OpenAIModels.kt

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import ai.koog.prompt.llm.LLModel
3333
* | [Chat.GPT5Pro] | Slowest | $15-$120 | Text, Image, Tools, Document | Text, Tools |
3434
* | [Chat.GPT5_1] | Fast | $1.25-$10 | Text, Image, Tools, Document | Text, Image, Tools, Document |
3535
* | [Chat.GPT5_1Codex] | Medium | $1.25-$10 | Text, Image, Tools, Document | Text, Image, Tools, Document |
36+
* | [Chat.GPT5_2] | Fast | $1.75-$14 | Text, Image, Tools, Document | Text, Tools |
37+
* | [Chat.GPT5_2Pro] | Slowest | $21-$168 | Text, Image, Tools, Document | Text, Tools |
3638
* | [Audio.GptAudio] | Fast | $2.5-$10 | Text, Audio, Tools | Text, Audio, Tools |
3739
* | [Audio.GPT4oMiniAudio] | Fast | $0.15-$0.6/$10-$20 | Text, Audio, Tools | Text, Audio, Tools |
3840
* | [Audio.GPT4oAudio] | Medium | $2.5-$10/$40-$80 | Text, Audio, Tools | Text, Audio, Tools |
@@ -575,6 +577,70 @@ public object OpenAIModels : LLModelDefinitions {
575577
contextLength = 400_000,
576578
maxOutputTokens = 128_000,
577579
)
580+
581+
/**
582+
* GPT-5.2 is OpenAI's flagship model for coding and agentic tasks across industries.
583+
* Supports both reasoning and chat completions endpoints.
584+
*
585+
* 400,000 context window
586+
* 128,000 max output tokens
587+
* Aug 31, 2025 knowledge cutoff
588+
* Reasoning token support
589+
*
590+
* @see <a href="https://platform.openai.com/docs/models/gpt-5.2"\>Model page</a>
591+
*/
592+
593+
public val GPT5_2: LLModel = LLModel(
594+
provider = LLMProvider.OpenAI,
595+
id = "gpt-5.2",
596+
capabilities = listOf(
597+
LLMCapability.Completion,
598+
LLMCapability.Temperature,
599+
LLMCapability.Schema.JSON.Basic,
600+
LLMCapability.Schema.JSON.Standard,
601+
LLMCapability.Speculation,
602+
LLMCapability.Tools,
603+
LLMCapability.ToolChoice,
604+
LLMCapability.Vision.Image,
605+
LLMCapability.Document,
606+
LLMCapability.MultipleChoices,
607+
LLMCapability.OpenAIEndpoint.Completions,
608+
LLMCapability.OpenAIEndpoint.Responses,
609+
),
610+
contextLength = 400_000,
611+
maxOutputTokens = 128_000,
612+
)
613+
614+
/**
615+
* GPT-5.2 pro is available in the Responses API only to enable support for multi-turn model interactions
616+
* before responding to API requests, and other advanced API features in the future.
617+
* Supports reasoning.effort: medium, high, xhigh.
618+
*
619+
* 400,000 context window
620+
* 128,000 max output tokens
621+
* Aug 31, 2025 knowledge cutoff
622+
* Reasoning token support
623+
*
624+
* @see <a href="https://platform.openai.com/docs/models/gpt-5.2-pro"\>Model page</a>
625+
*/
626+
627+
public val GPT5_2Pro: LLModel = LLModel(
628+
provider = LLMProvider.OpenAI,
629+
id = "gpt-5.2-pro",
630+
capabilities = listOf(
631+
LLMCapability.Completion,
632+
LLMCapability.Temperature,
633+
LLMCapability.Speculation,
634+
LLMCapability.Tools,
635+
LLMCapability.ToolChoice,
636+
LLMCapability.Vision.Image,
637+
LLMCapability.Document,
638+
LLMCapability.MultipleChoices,
639+
LLMCapability.OpenAIEndpoint.Responses,
640+
),
641+
contextLength = 400_000,
642+
maxOutputTokens = 128_000,
643+
)
578644
}
579645

580646
/**

prompt/prompt-executor/prompt-executor-clients/prompt-executor-openrouter-client/src/commonMain/kotlin/ai/koog/prompt/executor/clients/openrouter/OpenRouterModels.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,30 @@ public object OpenRouterModels : LLModelDefinitions {
307307
contextLength = 16_385,
308308
)
309309

310+
/**
311+
* GPT-5.2 is offering stronger agentic and long context performance compared to GPT-5.1.
312+
* It uses adaptive reasoning to allocate computation dynamically, responding quickly to simple queries
313+
* while spending more depth on complex tasks.
314+
*/
315+
public val GPT5_2: LLModel = LLModel(
316+
provider = LLMProvider.OpenRouter,
317+
id = "openai/gpt-5.2",
318+
capabilities = multimodalCapabilities + additionalCapabilities,
319+
contextLength = 400_000,
320+
)
321+
322+
/**
323+
* GPT-5.2 Pro is offering major improvements in agentic coding and long context performance over GPT-5 Pro.
324+
* It is optimized for complex tasks that require step-by-step reasoning, instruction following,
325+
* and accuracy in high-stakes use cases.
326+
*/
327+
public val GPT5_2Pro: LLModel = LLModel(
328+
provider = LLMProvider.OpenRouter,
329+
id = "openai/gpt-5.2-pro",
330+
capabilities = multimodalCapabilities + LLMCapability.ToolChoice,
331+
contextLength = 400_000,
332+
)
333+
310334
/**
311335
* Represents the Llama3 model configuration provided by OpenRouter.
312336
* This model is identified by the unique ID "meta/llama-3-70b" and

0 commit comments

Comments
 (0)