Skip to content

Conversation

sichang824
Copy link

Description

Fix invalid tool type error in EditTool20250429 class by updating the api_type from 'str_replace_based_edit_tool' to 'text_editor_20250429'.

Problem

The current api_type 'str_replace_based_edit_tool' is not recognized by the Claude API, causing validation errors.

Request body (causing error):

{
    "model": "claude-sonnet-4-20250514",
    "messages": [
        {
            "role": "user",
            "content": "who are u?"
        }
    ],
    "max_tokens": 1024,
    "stream": false,
    "tools": [
        {
            "name": "computer",
            "type": "computer_20250124",
            "display_width_px": 1024,
            "display_height_px": 768,
            "display_number": null
        },
        {
            "name": "str_replace_based_edit_tool",
            "type": "str_replace_based_edit_tool"
        },
        {
            "type": "bash_20250124",
            "name": "bash"
        }
    ]
}

Error response:

{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "tools.1: Input tag 'str_replace_based_edit_tool' found using 'type' does not match any of the expected tags: 'bash_20250124', 'computer_20250124', 'custom', 'text_editor_20250124', 'text_editor_20250429', 'web_search_20250305'"
  }
}

Solution

Updated the api_type to 'text_editor_20250429' which is the correct type for the EditTool20250429 class.

Fixed request body:

{
    "model": "claude-sonnet-4-20250514",
    "messages": [
        {
            "role": "user",
            "content": "who are u?"
        }
    ],
    "max_tokens": 1024,
    "stream": false,
    "tools": [
        {
            "name": "computer",
            "type": "computer_20250124",
            "display_width_px": 1024,
            "display_height_px": 768,
            "display_number": null
        },
        {
            "name": "str_replace_based_edit_tool",
            "type": "text_editor_20250429"
        },
        {
            "type": "bash_20250124",
            "name": "bash"
        }
    ]
}

Successful response:

{
  "id": "msg_01RKgx3hur6gzcYBFbAr4SHY",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-4-20250514",
  "content": [
    {
      "type": "text",
      "text": "I'm Claude, an AI assistant created by Anthropic. I'm designed to be helpful, harmless, and honest. I can assist you with a wide variety of tasks including answering questions, helping with analysis, writing, coding, and more.\n\nI have access to several tools that allow me to:\n- Take screenshots and interact with computer interfaces (mouse, keyboard)\n- View, create, and edit files\n- Run bash commands\n\nIs there something specific I can help you with today?"
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 2651,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "output_tokens": 107,
    "service_tier": "standard"
  }
}

Changes

  • Updated api_type from "str_replace_based_edit_tool" to "text_editor_20250429" in EditTool20250429 class
  • Tool name remains "str_replace_based_edit_tool" as expected by the API

Testing

Verified that the tool configuration now matches the expected API format:

  • name: "str_replace_based_edit_tool"
  • type: "text_editor_20250429"

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

Successfully merging this pull request may close these issues.

1 participant