{
  "id": "llm/langchain-tool-call-argument-type-error",
  "signature": "TypeError: 'NoneType' object is not iterable in tool call arguments parsing",
  "signature_zh": "TypeError：在工具调用参数解析中，'NoneType' 对象不可迭代",
  "regex": "'NoneType' object is not iterable in tool call arguments",
  "domain": "llm",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "LangChain's tool call parser receives a 'None' value for a required list or dict parameter from the LLM, often when the model fails to generate arguments for a tool invocation.",
  "root_cause_type": "generic",
  "root_cause_zh": "LangChain 的工具调用解析器从 LLM 接收到必需列表或字典参数的 'None' 值，通常发生在模型未能为工具调用生成参数时。",
  "versions": [
    {
      "version": "langchain==0.2.5",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "langchain-core==0.2.5",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "pydantic==2.7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Even at temperature=0, the model can still output incomplete or missing arguments due to model behavior, not randomness.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The issue is structural (missing argument), not truncation; more tokens won't fix a None value.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Silently ignoring means the tool call is lost, breaking the agent's chain of reasoning and potentially producing incorrect results.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Add validation in the tool's `_run` method to handle None defaults: `def _run(self, items: List[str] = None): items = items or []`",
      "success_rate": 0.9,
      "how": "Add validation in the tool's `_run` method to handle None defaults: `def _run(self, items: List[str] = None): items = items or []`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use LangChain's `PydanticToolsParser` with a BaseModel that has default values for optional fields: `class MyArgs(BaseModel): items: List[str] = Field(default_factory=list)`",
      "success_rate": 0.95,
      "how": "Use LangChain's `PydanticToolsParser` with a BaseModel that has default values for optional fields: `class MyArgs(BaseModel): items: List[str] = Field(default_factory=list)`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Implement a retry mechanism that re-prompts the LLM with a clear instruction to provide all required arguments: `f'Please provide all required arguments for the tool. Missing: {missing_fields}'`",
      "success_rate": 0.85,
      "how": "Implement a retry mechanism that re-prompts the LLM with a clear instruction to provide all required arguments: `f'Please provide all required arguments for the tool. Missing: {missing_fields}'`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Add validation in the tool's `_run` method to handle None defaults: `def _run(self, items: List[str] = None): items = items or []`",
    "Use LangChain's `PydanticToolsParser` with a BaseModel that has default values for optional fields: `class MyArgs(BaseModel): items: List[str] = Field(default_factory=list)`",
    "Implement a retry mechanism that re-prompts the LLM with a clear instruction to provide all required arguments: `f'Please provide all required arguments for the tool. Missing: {missing_fields}'`"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://python.langchain.com/docs/modules/agents/tools/custom_tools#handling-errors",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.87,
  "resolvable": "true",
  "first_seen": "2024-03-22",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}