Skip to content

Anthropic tool call with no input returns empty string instead of empty dict while streaming #2107

@deep-rloebbert

Description

@deep-rloebbert

Describe the bug
Both the Amazon Bedrock integration and the Anthropic integration do not check for an empty string in the arguments. The arguments fail to load. Hence the error message:

Amazon Bedrock returned a malformed JSON string for tool call arguments. This tool call will be skipped. Tool call ID: tooluse_asdf, Tool name: get_tool_no_input, Arguments:

Tool Arguments: ""
Tool Name: "get_tool_no_input"

This is known issue of Anthropic models on other frameworks: BerriAI/litellm#5063

To Reproduce
yaml config of an component tool:

type: haystack.tools.component_tool.ComponentTool
        data:
          component:
            type: haystack.components.builders.prompt_builder.PromptBuilder
            init_parameters:
              template: "Lorem ipsum..."
              required_variables:
              variables:
          name: get_tool_no_input
          description: A tool to retrieve the weather. No input required.
          parameters:
            type: object
            properties: {}
            required: []
            additionalProperties: false

Describe your environment (please complete the following information):

  • OS: deepset AI Platform
  • Haystack version: 2.14.3
  • Integration version:

Metadata

Metadata

Assignees

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