-
Notifications
You must be signed in to change notification settings - Fork 266
Fix reasoning message handling in strategy #1166
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
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.
Pull request overview
This PR fixes reasoning message handling in the agent strategy by introducing proper filtering capabilities and adding support for requesting multiple LLM responses without tools.
Key Changes:
- Added
skipReasoningMessageparameter tonodeLLMRequestto filter out reasoning messages when enabled - Introduced new edge filter functions
onReasoningMessageandonMultipleReasoningMessagesfor handling reasoning message flows - Implemented
requestLLMMultipleWithoutTools()methods in session classes to support multiple responses without tool usage - Fixed consistency issues by replacing
.any()with.isNotEmpty()and adding missing empty checks
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| AIAgentNodes.kt | Added skipReasoningMessage parameter and logic to filter reasoning messages from multiple LLM responses |
| AIAgentEdges.kt | Added reasoning message edge filters and improved consistency of empty collection checks |
| AIAgentEdgeBuilder.kt | Extended EdgeTransformationDslMarker annotation to classes for broader DSL marker coverage |
| AIAgentLLMWriteSession.kt | Implemented requestLLMMultipleWithoutTools() to request and append multiple responses without tools |
| AIAgentLLMSession.kt | Added base implementation of requestLLMMultipleWithoutTools() method |
| AIAgentSimpleStrategies.kt | Reordered edge definitions for better code organization (no semantic change) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
agents/agents-core/src/commonMain/kotlin/ai/koog/agents/core/dsl/extension/AIAgentNodes.kt
Outdated
Show resolved
Hide resolved
Qodana for JVM1166 new problems were found
@@ Code coverage @@
+ 72% total lines covered
16784 lines analyzed, 12175 lines covered
# Calculated according to the filters of your coverage tool☁️ View the detailed Qodana report Contact Qodana teamContact us at [email protected]
|
BLannoo
left a comment
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.
If I understand it correctly the goal is to fix the issue described in #1153
And while this does look a lot cleaner solution and I would be interested in finding one more in this direction, it currently does not seem to fix the core issue:
Which is that
| strategy = singleRunStrategy(ToolCalls.SEQUENTIAL), |
The error is still:
AIAgentStuckInTheNodeException: AI Agent has run into a problem: When executing agent graph, stuck in node nodeSendToolResult because output Reasoning(
Maybe merging in develop could help, because some other issue related to it was fixed recently, so the version in develop now works with: ToolCalls.SEQUENTIAL
But I am quite sure we would like it to work without that parameter too.
1f5bc4c to
8255de8
Compare
8255de8 to
549d800
Compare
I’ve fixed the issue, the exception was actually occurring in another node |
|
Could you please cover changes with some basic unit-tests? Apart from this, the code looks good to me! |
c6daa9b to
ed174ad
Compare
| .let { preparePrompt(it, emptyList()) } | ||
|
|
||
| return executeSingle(promptWithDisabledTools, emptyList()) | ||
| return executeMultiple(promptWithDisabledTools, emptyList()).first { it !is Message.Reasoning } |
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.
nit: seems like you can simplify this method by reusing requestLLMMultipleWithoutTools and only applying first
tiginamaria
left a comment
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.
Thank you! Looks good!
- Add `onReasoningMessage` edge transformation for reasoning message filtering - Reorder `onMultipleToolCalls` edge to prioritize execution flow - Expand `EdgeTransformationDslMarker` target scope to include classes and annotate `AIAgentEdgeBuilderIntermediate` - Add `skipReasoningMessage` support and `requestLLMMultipleWithoutTools` implementation - Document `skipReasoningMessage` behavior in `nodeLLMRequest` API function
…d refactor logic
ed174ad to
0828a67
Compare
BLannoo
left a comment
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.
Validated the codeagent step01 and step02 to work after the fix (including the SINGLE_RUN_SEQUENTIAL version)
related to #1153
Motivation and Context
Breaking Changes
None
Type of the changes
Checklist
developas the base branchAdditional Context
To add tests need to modify and refactor mock executor