fix: stop the LLM repeating a tool call it was given no cause for - #10109
Merged
Merged
Conversation
A chart or grid data update that failed with anything other than a ToolException returned a bare error, so the LLM had nothing to correct and sent the same query again until the turn was spent. The error now asks for a changed query rather than the same one, and for the failure to be reported if it cannot be changed. The cause itself still never reaches the LLM. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
vaadin-review-bot
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed the changes — left 1 comment.
| Finding | |
|---|---|
| 🧪 | No test asserts the retry guidance, and the two tests that could have were loosened in the same PR |
|
ugur-vaadin
approved these changes
Sep 14, 2026
tomivirkki
added a commit
that referenced
this pull request
Sep 14, 2026
…0109) (CP: 25.3) (#10115) This PR cherry-picks changes from the original PR #10109 to branch 25.3. --- #### Original PR description > ## Description > > A `DatabaseProvider` that throws anything other than a `ToolException` leaves the LLM with a bare error and nothing to correct, so it sent the same failing query again and again until the turn was spent. Seen with both gpt-4o and gpt-4o-mini against a provider that threw `IllegalArgumentException`. Repeating the call unchanged can only fail the same way, but a rewritten attempt is still worth one try, because the cause is often something the LLM can avoid by itself, such as an identifier the database reserves. > > - Added guidance to the error that `update_chart_data_source`, `update_chart_configuration` and `update_grid_data` return when they fail for a reason the LLM cannot be told: it now asks for a changed query rather than the same one, and for the failure to be reported if it cannot be changed > - Kept the cause itself out of the response, as before, so only a `ToolException` message reaches the LLM > - Narrowed two existing tests that asserted the whole error string down to what the wording cannot change: that the call reports an error, and that the cause never reaches the LLM > > ## Type of change > > - Bugfix > > > [!NOTE] > > Nothing enforces the "once more" count, so an LLM that ignores the guidance can still loop. Bounding it properly would mean counting attempts in the controller, which is a bigger change than this fix. > > 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Tomi Virkki <tomivirkki@users.noreply.github.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
A
DatabaseProviderthat throws anything other than aToolExceptionleaves the LLM with a bare error and nothing to correct, so it sent the same failing query again and again until the turn was spent. Seen with both gpt-4o and gpt-4o-mini against a provider that threwIllegalArgumentException. Repeating the call unchanged can only fail the same way, but a rewritten attempt is still worth one try, because the cause is often something the LLM can avoid by itself, such as an identifier the database reserves.update_chart_data_source,update_chart_configurationandupdate_grid_datareturn when they fail for a reason the LLM cannot be told: it now asks for a changed query rather than the same one, and for the failure to be reported if it cannot be changedToolExceptionmessage reaches the LLMType of change
Note
Nothing enforces the "once more" count, so an LLM that ignores the guidance can still loop. Bounding it properly would mean counting attempts in the controller, which is a bigger change than this fix.
🤖 Generated with Claude Code