Fail to parse anthropic output

The llm’s output is correct, however it still have validation error:
Thought: I need to create the CompanyOverview.js file in the correct directory.

Action: FileWriterTool
Action Input: {“content”: “import React from ‘react’;\nimport { Pie } from ‘@ant-design/plots’;\n\nconst CompanyOverview = () => {\n const data = [\n { type: ‘餐饮外卖’, value: 50 },\n { type: ‘到店及酒旅’, value: 23 },\n { type: ‘新业务及其他’, value: 27 },\n ];\n\n const config = {\n appendPadding: 10,\n data,\n angleField: ‘value’,\n colorField: ‘type’,\n radius: 0.8,\n label: {\n type: ‘outer’,\n content: ‘{name} {percentage}’,\n },\n interactions: [{ type: ‘element-active’ }],\n };\n\n return (\n <div className="company-overview">\n

美团公司概况

\n

美团是一家科技零售公司,成立于2010年3月。公司以"零售+科技"的战略践行"帮大家吃得更好,生活更好"的使命。

\n

业务收入占比

\n <Pie {…config} />\n \n );\n};\n\nexport default CompanyOverview;”, “file_path”: “./meituan-analysis/src/components/CompanyOverview.js”}

I encountered an error while trying to use the tool. This was the error: 1 validation error for FileToolsSchema
file_path
field required (type=value_error.missing).
Tool FileWriterTool accepts these inputs: FileWriterTool(content: ‘string’, file_path: ‘string’) - Useful to write content to a file.

This is the tool I defined:

from crewai_tools import BaseTool

class FileTools(BaseTool):
    name: str = "FileWriterTool"
    description: str = "Useful to write content to a file."

    def _run(self, content: str, file_path: str) -> str:
        """Useful to write content to a file.
        The input to this tool should be a text representing the content,
        and the path of the file.
        """
        try:
            if not file_path.startswith("./meituan-analysis"):
                file_path = f"./meituan-analysis/{file_path}"
            with open(file_path, "w") as f:
                f.write(content)
            return f"File written to {file_path}."
        except Exception as e:
            print(e)
            return "Error with the input format for the tool."

The error suggests that the file_path param is not being passed to the tool.
While I’m not 100% familiar with your application, I did have a similar error myself which I solved:

from typing import Any, Optional, Type

from crewai_tools import BaseTool
from pydantic import BaseModel, Field


class AgentPromptInput(BaseModel):
    agent_name: Optional[str] = Field(None, description='The name Agent that the prompt belongs to.')
    prompt_name: Optional[str] = Field("get", description='The prompt name, derived directly, or via interpretation of a synonyms ')
    prompt_value: str = Field(..., description='The text that will be stored in the prompt ')


class AgentPromptUpdater(BaseTool):
    name: str = "Agent Prompt Updater"
    description: str = "Updates agent prompts."

    args_schema: Type[BaseModel] = AgentPromptInput
    # return_schema: Type[BaseModel] = WebSearchOutput
    attached_crew: Any = None

    def __init__(self, crew: Any):
        super().__init__()
        self.attached_crew = crew

    def _run(self, agent_name: str, prompt_name: str, prompt_value: str ) -> str:
        print(f"agent_name:{agent_name}")
        print(f"prompt_name:{prompt_name}")
        print(f"prompt_value:{prompt_value}")

        # TODO : Implement Agent prompt updater

        return f"prompt {prompt_name} of Agent {agent_name} updated to: {prompt_value}"

Take note of:
args_schema: Type[BaseModel] = AgentPromptInput
This is where I assign the input model (above tool) is assigned as the input schema.