Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

refactor(responses): simplify tool call argument serializer

milanade21da9d075
diff --git a/litellm/responses/litellm_completion_transformation/custom_tools.py b/litellm/responses/litellm_completion_transformation/custom_tools.py
index bd6abd3f45f..90491739bb0 100644
--- a/litellm/responses/litellm_completion_transformation/custom_tools.py
+++ b/litellm/responses/litellm_completion_transformation/custom_tools.py
@@ -53,13 +53,11 @@ def serialize_tool_call_arguments(raw_arguments: object, default: str = "") -> s
single quotes, which every downstream JSON parser rejects with errors like
"Expecting ',' delimiter".
"""
- if raw_arguments is None or raw_arguments == "":
- return default
if isinstance(raw_arguments, str):
- return raw_arguments
- if isinstance(raw_arguments, (dict, list, tuple, bool, int, float)):
- return json.dumps(raw_arguments)
- return str(raw_arguments)
+ return raw_arguments or default
+ if raw_arguments is None:
+ return default
+ return json.dumps(raw_arguments, default=str)
def unwrap_custom_tool_arguments(arguments: str) -> str: