Skip to content

🐛 [Bug] Session blocked when LLM tool call returns empty tool_name; automatic retry mechanism suggested #3070

Description

@Zim-Inn

Description

Problem Description

Currently, when invoking the Large Language Model (LLM) for Tool Calling, the system does not properly handle exceptions if the model returns an empty tool_name.

Once this occurs, the entire chat session is abnormally blocked. Users cannot send further messages or receive any responses. The only current workaround is for users to manually open the local crush.db database and delete the corrupted record, which severely damages the user experience.

Proposed Solution

It is recommended to validate the tool_name returned from the tool call at the code level. When an empty tool_name is detected, the system should:

  1. Trigger an automatic retry mechanism (re-send the request to the LLM) with a maximum retry limit (e.g., 2–3 times).
  2. If the retries still fail, elegantly display an error message like "Tool call failed, please try again" on the frontend UI, rather than letting the backend crash, create dirty database records, and freeze the app.

Steps to Reproduce

  1. Start a conversation that triggers Tool Calling / Function Calling.
  2. The LLM responds with an empty tool_name field (possibly due to model hallucination or network truncation).
  3. The session freezes immediately, and all subsequent interactions become unresponsive.
  4. Users must manually access the crush.db database and delete the invalid entry to restore functionality.

Expected Behavior

Even if the LLM returns an invalid or empty tool name, the system should be robust enough to handle it. It should maintain session continuity through automatic retries or graceful degradation, eliminating the need for users to manually modify the database.

Metadata

Metadata

Assignees

No one assigned

    Fields

    No fields configured for feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions