KEMBAR78
add `additionalProperties` across clients by devcrocod · Pull Request #836 · JetBrains/koog · GitHub
Skip to content

Conversation

devcrocod
Copy link
Contributor

@devcrocod devcrocod commented Sep 21, 2025

KG-313 Ability to pass (really) custom LLM params

Motivation and Context

Passing properties to the LLM client that are not supported in requests

Breaking Changes

No


Type of the changes

  • 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

  • The pull request has a description of the proposed change
  • I read the Contributing Guidelines before opening the pull request
  • The pull request uses develop as the base branch
  • Tests for the changes have been added
  • All new and existing tests passed
Additional steps for pull requests adding a new feature
  • An issue describing the proposed change exists
  • The pull request includes a link to the issue
  • The change was discussed and approved in the issue
  • Docs have been added / updated

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for additionalProperties across all LLM clients, enabling developers to pass custom parameters that are not explicitly supported in the request models. The feature allows custom properties to be seamlessly merged into the final JSON request while preserving the ability to deserialize them back during response processing.

Key Changes

  • Added additionalProperties field to core LLMParams class with helper functions for type conversion
  • Implemented AdditionalPropertiesSerializer for handling JSON serialization/deserialization
  • Updated all client implementations to support and pass through additional properties

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
LLMParams.kt Added additionalProperties field and utility functions for JSON element conversion
AdditionalPropertiesSerializer.kt Core serializer implementing flattening/collecting logic for additional properties
Various client request models Added additionalProperties field to all request DTOs
Various client implementations Updated to use custom serializers and pass additional properties
Test files Comprehensive serialization tests for all clients verifying round-trip behavior

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-actions
Copy link

github-actions bot commented Sep 21, 2025

Qodana for JVM

846 new problems were found

Inspection name Severity Problems
Check Kotlin and Java source code coverage 🔶 Warning 809
Vulnerable imported dependency 🔶 Warning 21
Missing KDoc for public API declaration 🔶 Warning 16
@@ Code coverage @@
+ 69% total lines covered
12337 lines analyzed, 8592 lines covered
# Calculated according to the filters of your coverage tool

☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

Copy link
Collaborator

@kpavlov kpavlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @devcrocod
I like the design approach, but some more testing is needed: AdditionalParams got lost during the copy operation

* @param pairs A variable number of key-value pairs, where the keys are strings and the values are any type.
* @return A map with the provided keys associated with their corresponding JsonElement representations as values.
*/
public fun additionalPropertiesOf(vararg pairs: Pair<String, Any>): Map<String, JsonElement> =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it make sense to define the type/typealias for Map<String, JsonElement>. I am introducing the utils module, where this type and it's serializer may live.

@devcrocod devcrocod requested a review from kpavlov September 24, 2025 08:13
@aozherelyeva aozherelyeva requested a review from sdubov September 24, 2025 12:40
@devcrocod devcrocod force-pushed the devcrocod/KG-313-custom-LLM-params branch from b0b8784 to 1a7ec71 Compare September 25, 2025 09:48
kpavlov and others added 3 commits September 25, 2025 14:44
…nd deserialization strategies, update dependencies, and improve Anthropic client tests with JSON assertion using Kotest.
…geRequest`

- Annotated `maxTokens` and `stream` with `@EncodeDefault` for consistent serialization defaults.
- Introduced `@SerialName` for the `max_tokens` and `tool_choice` properties.
Copy link
Collaborator

@kpavlov kpavlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @devcrocod

@kpavlov kpavlov self-requested a review September 26, 2025 06:47
@kpavlov
Copy link
Collaborator

kpavlov commented Sep 26, 2025

Need more tests...

@kpavlov kpavlov added enhancement New feature or request tests Add new tests or modify existing labels Sep 26, 2025
…urrentLinkedQueue` for logs, and enable parallel test execution in JUnit; update dependencies.
@devcrocod devcrocod merged commit 1c57548 into develop Sep 26, 2025
11 checks passed
@devcrocod devcrocod deleted the devcrocod/KG-313-custom-LLM-params branch September 26, 2025 10:21
karloti pushed a commit to karloti/koog that referenced this pull request Oct 21, 2025
[KG-313](https://youtrack.jetbrains.com/issue/KG-313) Ability to pass
(really) custom LLM params

## Motivation and Context
Passing properties to the LLM client that are not supported in requests

---

Co-authored-by: Konstantin Pavlov <1517853+kpavlov@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request tests Add new tests or modify existing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants