{"record":{"id":"71b2eaa4719ddd19","repo":"BerriAI/litellm","slug":"defer-loading-must-be-a-boolean","errorCode":null,"errorMessage":"defer_loading must be a boolean","messagePattern":"defer_loading must be a boolean","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/anthropic/chat/transformation.py","lineNumber":802,"sourceCode":"                    returned_tool[\"cache_control\"] = _cache_control\n                elif _cache_control_function is not None and isinstance(_cache_control_function, dict):\n                    returned_tool[\"cache_control\"] = ChatCompletionCachedContent(**_cache_control_function)\n\n        ## check if defer_loading is set in the tool\n        _defer_loading: Final = tool.get(\"defer_loading\", None)\n        _defer_loading_function: Final = tool.get(\"function\", {}).get(\"defer_loading\", None)\n        if returned_tool is not None:\n            # Only set defer_loading on tools that support it (not tool search tools or computer tools)\n            tool_type = returned_tool.get(\"type\", \"\")\n            if tool_type not in (\n                \"tool_search_tool_regex_20251119\",\n                \"tool_search_tool_bm25_20251119\",\n                \"computer_20241022\",\n                \"computer_20250124\",\n            ):\n                if _defer_loading is not None:\n                    if not isinstance(_defer_loading, bool):\n                        raise ValueError(\"defer_loading must be a boolean\")\n                    returned_tool[\"defer_loading\"] = _defer_loading\n                elif _defer_loading_function is not None:\n                    if not isinstance(_defer_loading_function, bool):\n                        raise ValueError(\"defer_loading must be a boolean\")\n                    returned_tool[\"defer_loading\"] = _defer_loading_function\n\n        ## check if allowed_callers is set in the tool\n        _allowed_callers: Final = tool.get(\"allowed_callers\", None)\n        _allowed_callers_function: Final = tool.get(\"function\", {}).get(\"allowed_callers\", None)\n        if returned_tool is not None:\n            # Only set allowed_callers on tools that support it (not tool search tools or computer tools)\n            tool_type = returned_tool.get(\"type\", \"\")\n            if tool_type not in (\n                \"tool_search_tool_regex_20251119\",\n                \"tool_search_tool_bm25_20251119\",\n                \"computer_20241022\",\n                \"computer_20250124\",\n            ):","sourceCodeStart":784,"sourceCodeEnd":820,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/anthropic/chat/transformation.py#L784-L820","documentation":"Anthropic tool translation guard: the tool specifies defer_loading but its value is not a boolean (checked at both top level and inside function), so it cannot be forwarded to Anthropic safely — type validation before API serialization.","triggerScenarios":"Thrown at litellm/llms/anthropic/chat/transformation.py:802 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass defer_loading as a boolean true/false, not a string."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}