Skip to content

Conversation

@mltheuser
Copy link
Contributor

Motivation and Context

Related to KG-545.

Currently, requestLLMOnlyCallingTools relies on executeSingle, which returns the first message received from the LLM. When using models that output Chain of Thought or "Thinking" blocks (e.g., Nova, Claude) prior to calling a tool, the response sequence is often [Message.Assistant(Thinking), Message.Tool.Call].

As a result:

  1. The method returns the "Thinking" text message instead of the expected Tool Call.
  2. The actual Tool Call is discarded and never executed or saved to history.

Changes:

  • Introduced requestLLMMultipleOnlyCallingTools() in AIAgentLLMSession to allow retrieving the full list of messages while enforcing ToolChoice.Required.
  • Updated requestLLMOnlyCallingTools to use this new method. It now persists all messages (preserving the reasoning context in the session history) but filters the return value to ensure the caller receives the Message.Tool.Call.

Breaking Changes

None. This is a behavioral fix to ensure the method contract (returning a tool call) is honored when the LLM is "chatty" or provides reasoning.


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

@aozherelyeva aozherelyeva requested review from EugeneTheDev and tiginamaria and removed request for EugeneTheDev November 28, 2025 11:25
@mltheuser
Copy link
Contributor Author

I am unable to recreate the test failure locally. Seems to be due to a flaky test (had this before on another Koog PR). Would be nice if someone could rerun the failed job (I am not allowed to do it without pushing a new commit).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant