-
Notifications
You must be signed in to change notification settings - Fork 240
Get rid of required finishTool
and support tools as functions in subgraphWithTask
, deprecate ToolArgs
and ToolResult
, auto-generate ToolDescriptor
#791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b8968c9
to
c10abf2
Compare
finishTool
and support tools as functions in subgraphWithTask
, deprecate ToolArgs and ToolResultfinishTool
and support tools as functions in subgraphWithTask
, deprecate ToolArgs
and ToolResult
, auto-generate ToolDescriptor
ed46f91
to
a03f1b7
Compare
Qodana for JVM848 new problems were found
@@ Code coverage @@
+ 69% total lines covered
12404 lines analyzed, 8647 lines covered
# Calculated according to the filters of your coverage tool ☁️ View the detailed Qodana report Contact Qodana teamContact us at qodana-support@jetbrains.com
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much nicer than it was!
It seems like not you can not provide a argument description for the primitive typed argument, or I miss something?
internal class PrimitiveTool(name: String) : Tool<Int, String>() {
override val name = "primitive_tool"
override val argsSerializer = Int.serializer()
override val resultSerializer = String.serializer()
override val toolDescription: String = "First tool description"
override suspend fun execute(args: Int): String = "Do nothing $args"
}
Also, I'd add more tests for such cases (for example how List of not primitive type will work and other unusual cases)
I like the simplified API. I have some small comments related to this change. Overall looks good for me. |
agents/agents-core/src/commonTest/kotlin/ai/koog/agents/core/feature/TestFeature.kt
Show resolved
Hide resolved
agents/agents-tools/src/commonMain/kotlin/ai/koog/agents/core/tools/Tool.kt
Outdated
Show resolved
Hide resolved
...-handler/src/jvmTest/kotlin/ai/koog/agents/features/eventHandler/feature/EventHandlerTest.kt
Show resolved
Hide resolved
agents/agents-tools/src/commonMain/kotlin/ai/koog/agents/core/tools/SimpleTool.kt
Outdated
Show resolved
Hide resolved
agents/agents-ext/src/commonMain/kotlin/ai/koog/agents/ext/tool/file/EditFileTool.kt
Show resolved
Hide resolved
If I correctly understand the new API, you need to do it through:
It would be nice if we can use a primitive types though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think not having args description for primitive types is not a blocker at all:
- You can just describe the argument in tool description string
- You can override tool description and define the proper schema
- You can always use
data class Args(value: Int)
with@property:LLMDescription
- Case with primitive input + tool as a class definition is super rear (only multiplatform I guess, but maybe it's better to work on cross-platform annotations or some other ways of supporting tools as function there)
f0503d7
to
803171e
Compare
Refactor `SerialToToolDescription` by extracting `parameterDescriptors` helper method to improve code reuse and clarity. Add comprehensive tests for `SerialDescriptor` to `ToolDescription` mapping and improve utility method structure. - Added unit tests in `LLMDescriptionUsageTest` and `SerialToToolDescriptionTest` to validate `SerialDescriptor` to `ToolDescriptor` conversions, covering edge cases and annotations. - Extracted private helper `description()` to streamline annotation description retrieval. - Improved parameter handling by introducing local variables for clarity and consistency. Refactor SimpleTool.kt to work with String instead of ToolResult.Text KtLint: Fix import order Remove unrelated change Introduce KMP support for deriving ToolDescription based on SerialDescriptor. Deprecate `ToolResult` and refactor tools to use KotlinX Serialization for results. Deprecate ToolArgs.kt, and remove usage.
…alizable abstract class for custom serialization of tool results as text/markdown
3e21c19
to
748d07f
Compare
…ations (#889) <!-- 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? --> As a follow-up to our last week discussion, it's good to test different input/output combinations in tool descriptors after the merge of #791. ## Breaking Changes <!-- Will users need to update their code or configurations? --> None. --- #### 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 - [x] 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 - [ ] Docs have been added / updated
Fixes @tool("customName") not working after JetBrains#791.
…ations (#889) <!-- 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? --> As a follow-up to our last week discussion, it's good to test different input/output combinations in tool descriptors after the merge of #791. ## Breaking Changes <!-- Will users need to update their code or configurations? --> None. --- #### 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 - [x] 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 - [ ] Docs have been added / updated (cherry picked from commit 58ba445)
Fixes @tool("customName") not working after JetBrains#791.
Fixes @tool("customName") not working after JetBrains#791.
…ubgraphWithTask`, deprecate `ToolArgs` and `ToolResult`, make `ToolDescriptor` auto-generated for class-based tools (JetBrains#791) 1. Automatic Tool Descriptor Generation - Tool descriptors no longer need to be written manually — they are generated automatically. - Tool parameters must be annotated with @LLMDescription to provide descriptions. 2. subgraphWithTask ыimplification (no longer requires finishTool, deduces all information by output type automatically) 3. Serialization Improvements - ToolArgs and ToolResult are no longer needed — everything is handled via serialization. - ToolResult is now always Serializable to Json - For rare cases where JSON is not applicable: - Inherit from ToolResult.TextSerializable and implement fun textForLLM(). - Specify resultSerializer = ToolResultUtils.toTextSerializer(). - The LLM will then receive the output from textForLLM(). 4. Agent.asTool() no longer requires a ToolDescriptor. (Requires only toolDescription: String, and only if the agent’s input type is a primitive (e.g., String). If the input type is not primitive, descriptions are taken from @LLMDescription.) --- #### Type of the changes - [x] New feature (non-breaking change which adds functionality) - [ ] Bug fix (non-breaking change which fixes an issue) - [x] Breaking change (fix or feature that would cause existing functionality to change) - [x] Documentation update - [x] Tests improvement - [x] 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 - [ ] 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 - [x] Docs have been added / updated --------- Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com> Co-authored-by: Anastasiia.Zarechneva <Anastasiia.Zarechneva@jetbrains.com>
…ations (JetBrains#889) <!-- 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? --> As a follow-up to our last week discussion, it's good to test different input/output combinations in tool descriptors after the merge of JetBrains#791. ## Breaking Changes <!-- Will users need to update their code or configurations? --> None. --- #### 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 - [x] 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 - [ ] Docs have been added / updated (cherry picked from commit 58ba445)
subgraphWithTask ыimplification (no longer requires finishTool, deduces all information by output type automatically)
Serialization Improvements
(Requires only toolDescription: String, and only if the agent’s input type is a primitive (e.g., String). If the input type is not primitive, descriptions are taken from @LLMDescription.)
Type of the changes
Checklist
develop
as the base branchAdditional steps for pull requests adding a new feature