{
  "id": "llm/langchain-tool-call-missing-arguments",
  "signature": "langchain_core.exceptions.ToolException: Tool 'search_tool' called with missing required arguments. Expected: ['query'], got: [].",
  "signature_zh": "langchain_core.exceptions.ToolException: 工具 'search_tool' 调用缺少必需参数。期望：['query']，实际：[]。",
  "regex": "langchain_core\\.exceptions\\.ToolException.*Tool.*called with missing required arguments",
  "domain": "llm",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The LLM generates a tool call with an empty arguments dict or missing required parameters, often due to the model misinterpreting the tool schema or truncating the function call JSON during streaming.",
  "root_cause_type": "generic",
  "root_cause_zh": "LLM 生成一个参数字典为空或缺少必需参数的工具调用，通常是由于模型误解了工具架构，或在流式传输期间截断了函数调用 JSON。",
  "versions": [
    {
      "version": "langchain==0.3.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "langchain-core==0.3.5",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "langchain-openai==0.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "While helpful, verbose descriptions can confuse the LLM or lead to token limit issues. The root cause is often the model's inability to consistently produce valid JSON for complex schemas.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Deterministic settings reduce variability but don't fix the underlying schema parsing issue. The model may still generate malformed calls if the prompt or tool definitions are ambiguous.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Retrying the same request with the same configuration will likely produce the same error because the model's behavior is consistent for the same input.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Implement a validation wrapper that catches ToolException and re-prompts the LLM with a correction message: `try: result = tool.run(tool_call) except ToolException: corrected_call = llm.invoke(\"The previous tool call was invalid. Please provide valid arguments for 'search_tool' with a 'query' string.\")`. This allows the model to self-correct.",
      "success_rate": 0.85,
      "how": "Implement a validation wrapper that catches ToolException and re-prompts the LLM with a correction message: `try: result = tool.run(tool_call) except ToolException: corrected_call = llm.invoke(\"The previous tool call was invalid. Please provide valid arguments for 'search_tool' with a 'query' string.\")`. This allows the model to self-correct.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Simplify the tool schema by using primitive types (str, int) instead of complex objects or enums. Example: change `query: Optional[str]` to `query: str = Field(description=\"...\")` to make it required and explicit.",
      "success_rate": 0.8,
      "how": "Simplify the tool schema by using primitive types (str, int) instead of complex objects or enums. Example: change `query: Optional[str]` to `query: str = Field(description=\"...\")` to make it required and explicit.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use LangChain's `StructuredTool` with `handle_tool_error=True` to automatically retry with a fallback message: `tool = StructuredTool.from_function(func=search, handle_tool_error=True)`.",
      "success_rate": 0.75,
      "how": "Use LangChain's `StructuredTool` with `handle_tool_error=True` to automatically retry with a fallback message: `tool = StructuredTool.from_function(func=search, handle_tool_error=True)`.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "实现一个验证包装器，捕获 ToolException 并使用更正消息重新提示 LLM：`try: result = tool.run(tool_call) except ToolException: corrected_call = llm.invoke(\"之前的工具调用无效。请为 'search_tool' 提供有效的参数，包含 'query' 字符串。\")`。这允许模型自我纠正。",
    "通过使用原始类型（str、int）而不是复杂对象或枚举来简化工具架构。示例：将 `query: Optional[str]` 改为 `query: str = Field(description=\"...\")` 使其成为必需且明确的参数。",
    "使用 LangChain 的 `StructuredTool` 并设置 `handle_tool_error=True` 以自动重试并回退消息：`tool = StructuredTool.from_function(func=search, handle_tool_error=True)`。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://python.langchain.com/docs/how_to/custom_tools/#tool-validation",
  "official_doc_section": null,
  "error_code": "LANG-ERR-0078",
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.76,
  "resolvable": "partial",
  "first_seen": "2024-11-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}