Skip to content

iFlow API Compatibility Issue: Fix "Unknown tool called by model:nil" Error Caused by Fragmented Tool Call Transmission #1166

@iT-Boyer

Description

@iT-Boyer

Briefly describe what you are trying to do
When trying to integrate gptel with the iFlow API, the "Unknown tool called by model:nil" error occurs when the model returns tool calls (such as web_search). This
issue is caused by the iFlow API fragmenting tool call information during streaming responses.

Detailed Problem Description

The iFlow API fragments tool call information during streaming responses, specifically manifested as:

  1. The first chunk may only contain the tool name but no arguments (e.g., {"name": "web_search"})
  2. Subsequent chunks may have an empty name but contain argument fragments (e.g., {"arguments": "{"query": "current news 2024"}"})
  3. This causes gptel to encounter tool calls with nil names during parsing, resulting in the "Unknown tool called by model:nil" error

Although the gptel-iflow-debug.el file already implements a tool call accumulation mechanism, there are defects in processing tool calls after accumulation is
complete, failing to properly merge previously accumulated data.

log.txt

Additional context
Emacs version: 30.2
Operating system: macOS 26.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions