Skip to content

[Bug/Regression] tool_use_enforcement auto-mode excludes Qwen/DeepSeek causing hallucination #28079

@wzgrx

Description

@wzgrx

Describe the bug

When using Qwen or DeepSeek models (e.g., qwen-plus, qwen-max), the agent exhibits severe degradation in tool usage, often failing to execute tools entirely, hallucinating execution ("I'm running the command..." but no tool is called), or ignoring existing code/memory.

Root Cause Analysis

I traced this back to agent/prompt_builder.py line ~271:

TOOL_USE_ENFORCEMENT_MODELS = ("gpt", "codex", "gemini", "gemma", "grok", "glm")

This list is missing qwen and deepseek.

When tool_use_enforcement is set to auto (default), the system checks if the model name matches this tuple. Since qwen3.6-plus does not match, the critical tool-use enforcement system prompt is never injected.

Without this strict enforcement, strong non-OpenAI models tend to default to "chatty" behavior:

  1. They describe intended actions instead of calling the tools.
  2. They ignore existing project context/memory (hallucinating new code).
  3. They silently fail or stop mid-execution.

Proposed Fix

  1. Immediate Fix: Add qwen, deepseek, and potentially mistral/llama to the TOOL_USE_ENFORCEMENT_MODELS tuple.
  2. Robust Fix: Change the default behavior of tool_use_enforcement to true for all models, rather than relying on a hardcoded allowlist.

Environment

  • Hermes Agent: v0.13.0
  • Model: qwen3.6-plus (Alibaba Cloud)
  • Symptom: "Lazy" tool usage, hallucination of execution, ignoring existing code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/agentCore agent loop, run_agent.py, prompt builderprovider/deepseekDeepSeek APIprovider/qwenQwen / Alibaba Cloud (OAuth)type/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions