BerriAI/litellm · error · ValueError
defer_loading must be a boolean
Error message
defer_loading must be a boolean
What it means
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.
Solutions
- Pass defer_loading as a boolean true/false, not a string.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at litellm/llms/anthropic/chat/transformation.py:802 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/71b2eaa4719ddd19.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/anthropic/chat/transformation.py:802
returned_tool["cache_control"] = _cache_control
elif _cache_control_function is not None and isinstance(_cache_control_function, dict):
returned_tool["cache_control"] = ChatCompletionCachedContent(**_cache_control_function)
## check if defer_loading is set in the tool
_defer_loading: Final = tool.get("defer_loading", None)
_defer_loading_function: Final = tool.get("function", {}).get("defer_loading", None)
if returned_tool is not None:
# Only set defer_loading on tools that support it (not tool search tools or computer tools)
tool_type = returned_tool.get("type", "")
if tool_type not in (
"tool_search_tool_regex_20251119",
"tool_search_tool_bm25_20251119",
"computer_20241022",
"computer_20250124",
):
if _defer_loading is not None:
if not isinstance(_defer_loading, bool):
raise ValueError("defer_loading must be a boolean")
returned_tool["defer_loading"] = _defer_loading
elif _defer_loading_function is not None:
if not isinstance(_defer_loading_function, bool):
raise ValueError("defer_loading must be a boolean")
returned_tool["defer_loading"] = _defer_loading_function
## check if allowed_callers is set in the tool
_allowed_callers: Final = tool.get("allowed_callers", None)
_allowed_callers_function: Final = tool.get("function", {}).get("allowed_callers", None)
if returned_tool is not None:
# Only set allowed_callers on tools that support it (not tool search tools or computer tools)
tool_type = returned_tool.get("type", "")
if tool_type not in (
"tool_search_tool_regex_20251119",
"tool_search_tool_bm25_20251119",
"computer_20241022",
"computer_20250124",
):View on GitHub (pinned to 77b7c6c40c)