Skip to content

[Bug] read_file crashes with TypeError (int + str) due to schema mismatch, and execute_command misses required 'command' argument. Custom body / Tool Prompt is ignored. #396

Description

@Qaridarium

Description:
There is a severe type-mismatch and argument handling bug in the built-in tools integration (DefaultToolsIntegration) when using local LLMs via llama.cpp server (tested with Qwen 3.6 and Gemma 4).

First, the application forces the LLM to provide the limit parameter as a string, which causes a Python backend crash. Second, when trying to override the tool prompt to fix this behavior or provide better instructions, Newelle throws a popup error stating that the custom body is ignored.
Steps to Reproduce

Connect Newelle to a local llama.cpp server (e.g., running gemma-4-31b or Qwen3.6-27B-NEO-CODE).

Ask the AI to read a file or perform a code modification task that triggers the internal read_file tool.

The LLM generates the JSON tool call based on the schema exposed by Newelle.

The tool execution fails immediately with a Python error.

Error Log / Output

  1. The read_file Type Error:

The LLM generates the following valid JSON according to the schema provided by the app:
JSON

{
"tool": "read_file",
"arguments": {
"absolute_path": "/home/qaridarium/pflegesyndikat/src/main.rs",
"limit": "400",
"offset": 216
},
"id": "ReyuKhN822dWEDxoHKUVsxNerlaM3Z7M"
}

Resulting Error:

Error reading file /path/to/file: unsupported operand type(s) for +: 'int' and 'str'

Root Cause: The internal schema defines "limit": {"type": "string"}. The LLM complies and sends "400". However, the Python backend treats offset as an integer and tries to calculate offset + limit without casting the string to an integer first.
2. The execute_command Argument Error:

When the model tries to switch to execute_command as a fallback, it frequently sends an empty arguments object:
JSON

{"tool": "execute_command", "arguments": {}, "id": "D8DDCSs4mb3smY9tU6w8Ty9DfTZTL57v"}

Resulting Error:

Error: DefaultToolsIntegration.execute_command_widget() missing 1 required positional argument: 'command'

Root Cause: Newelle registers the tool in a compact form under {TOOLS} without exposing the parameters properly to the model, leading to missing required positional arguments during execution.
3. Custom Prompt Override Failure:

When attempting to fix this by modifying the Tool Prompt in Newelle's settings to explicitly instruct the model to treat limit as an integer or force the command string, Newelle pops up the following error:

custom body given LLM does ignore it

The custom tool system prompt is entirely bypassed and overridden by the application's hardcoded default template.
Environment & Hardware Setup

OS: Fedora Linux

Frontend: Newelle (latest version)

Backend: llama.cpp server (API Mode) mit Vulkan Backend

Hardware: AMD Ryzen 9 + Radeon PRO W7900 (RADV / Vulkan)

Models tested: Qwen3.6-27B-NEO-CODE, Gemma-4-31B-it

Suggested Fixes for the Developer

In the read_file Python Backend:
Cast the incoming limit argument safely to an integer before doing any arithmetic:
Python

limit = int(arguments.get("limit", 500))

Alternatively, update the internal tool schema definition so that "limit" is explicitly typed as an integer, not a string.

  1. Fix Custom Body/Prompt Handling:
    Allow the user-defined Tool Prompt / Custom Body to actually reach the local LLM instead of silently ignoring it or falling back to the hardcoded broken default template.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions