Skip to content

fix: detect and correct text-based tool call hallucinations (MODEL_NO_TOOLS_USED loop)#5377

Merged
kevinvandijk merged 3 commits intoKilo-Org:mainfrom
benzntech:fix/model-no-tools-used-loop
Feb 13, 2026
Merged

fix: detect and correct text-based tool call hallucinations (MODEL_NO_TOOLS_USED loop)#5377
kevinvandijk merged 3 commits intoKilo-Org:mainfrom
benzntech:fix/model-no-tools-used-loop

Conversation

@benzntech
Copy link
Contributor

This PR addresses the recurring MODEL_NO_TOOLS_USED error where models output tool calls as text (e.g., [Tool Use: ...]) instead of using the native API format.

Fixes #5256
Fixes #5280

Changes

  1. Smart Error Handling: Modified src/core/task/Task.ts to detect text blocks matching the [Tool Use: ...] pattern. When detected, the system now provides a specific error message instructing the model to use the native tool calling capability. This immediate feedback breaks the retry loop.
  2. System Prompt Hardening: Updated src/core/prompts/sections/tool-use-guidelines.ts to include a critical guideline for native protocol sessions, explicitly forbidding text-based tool call mimicry.

This resolves the "mimicry loop" issues reported by users, particularly with Gemini and OpenRouter models.

…t MODEL_NO_TOOLS_USED loop

This fixes a common error loop where the model outputs '[Tool Use: ...]' as text instead of using the native API. The task loop now detects this pattern and issues a specific correction. Also updated system prompt guidelines.
@changeset-bot
Copy link

changeset-bot bot commented Jan 25, 2026

🦋 Changeset detected

Latest commit: 281e761

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
kilo-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Collaborator

@kevinvandijk kevinvandijk 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!

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.

MODEL_NO_TOOLS_USED when using GeminiCLI MODEL_NO_TOOLS_USED error since v4.146.0 in VSCode Kilo Code plugin

2 participants