Skip to content

Conversation

pintonunes
Copy link
Contributor

What type of PR is this?

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:

  • When the tool to be called has no arguments, the message outputted by the ChatModel has an empty string in the function arguments which makes the Tool component to fail.

Example:

=====================================================================================================
[OnStart] Component: ToolsNode, Name: Tools, Type: 
 {
  "role": "assistant",
  "content": "I'll help you get information .......",
  "tool_calls": [
    {
      "index": 0,
      "id": "toolu_bdrk_01JTRPBZ46wZqEnfBurtM9sJ",
      "type": "",
      "function": {
        "name": "get_current_time_rfc3339"
      }
    }
  ],
  "response_meta": {
    "finish_reason": "tool_use",
    "usage": {
      "prompt_tokens": 5258,
      "completion_tokens": 70,
      "total_tokens": 5260
    }
  }
}
=====================================================================================================
[OnStart] Component: Tool, Name: get_current_time_rfc3339, Type: GetCurrentTimeRfc3339
 ""
=========[OnError]=========
[LocalFunc] failed to unmarshal arguments in json, toolName=get_current_time_rfc3339, err="Syntax error no sources available, the input json is empty: errors.SyntaxError{Pos:0, Src:\"\", Code:0x1, Msg:\"\"}"

(Optional) Which issue(s) this PR fixes:

Fixes #238

(optional) The PR that updates user documentation:

@pintonunes pintonunes changed the title fix: Claude tool call when the tool has no arguments fix(Claude): Tools with no arguments Apr 30, 2025
@meguminnnnnnnnn
Copy link
Contributor

This handling will eliminate the streaming effect of tool call arguments.
I came up with a solution: we can record the arguments of each tool call at the beginning, and if we know that the arguments are all empty at the end of the tool call (or at the start of the next tool call), we can manually add a frame with arguments {} for this tool call. Would this be feasible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Claude: Tools without arguments
2 participants