From e776b3d96f735ce3d42b9c137eb4283c3c8a0853 Mon Sep 17 00:00:00 2001 From: Yuxiang Zhou Date: Wed, 4 Nov 2026 01:57:18 -0500 Subject: [PATCH] fix(prompt_templates): keep argument content out of the repair warning parse_tool_call_arguments logged up to 200 characters of the original arguments when it repaired truncated JSON. That warning is written even when message logging is turned off, so tool arguments with personal or confidential data could reach the logs. Log only the tool name, context and length. --- .../prompt_templates/common_utils.py | 4 +--- ...llm_core_utils_prompt_templates_common_utils.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/litellm/litellm_core_utils/prompt_templates/common_utils.py b/litellm/litellm_core_utils/prompt_templates/common_utils.py index f48a42963cf..af6d4a9333e 100644 --- a/litellm/litellm_core_utils/prompt_templates/common_utils.py +++ b/litellm/litellm_core_utils/prompt_templates/common_utils.py @@ -3261,12 +3261,10 @@ def parse_tool_call_arguments( repaired: Final = _attempt_json_repair(arguments) if repaired is not None: verbose_logger.warning( - "Repaired truncated tool call arguments for tool '%s' (%s). Original (%d chars): %.200s%s", + "Repaired truncated tool call arguments for tool '%s' (%s). Original length: %d chars", tool_name or "", context or "unknown context", len(arguments), - arguments, - "..." if len(arguments) > 200 else "", ) return repaired diff --git a/tests/unit/litellm_core_utils/prompt_templates/test_litellm_core_utils_prompt_templates_common_utils.py b/tests/unit/litellm_core_utils/prompt_templates/test_litellm_core_utils_prompt_templates_common_utils.py index a17deedf7a9..44c9252d213 100644 --- a/tests/unit/litellm_core_utils/prompt_templates/test_litellm_core_utils_prompt_templates_common_utils.py +++ b/tests/unit/litellm_core_utils/prompt_templates/test_litellm_core_utils_prompt_templates_common_utils.py @@ -297,6 +297,20 @@ def test_parse_tool_call_arguments_rejects_concatenated_json() -> None: parse_tool_call_arguments('{"a":1}{"b":2}') +def test_parse_tool_call_arguments_repair_warning_omits_argument_content() -> None: + from unittest.mock import patch + + secret: Final = "patient-record-4471" + with patch("litellm.litellm_core_utils.prompt_templates.common_utils.verbose_logger") as logger: + result: Final = parse_tool_call_arguments('{"note": "' + secret + '"', tool_name="save_note", context="test") + + assert result == {"note": secret} + logger.warning.assert_called_once() + logged: Final = " ".join(str(arg) for arg in logger.warning.call_args.args) + assert "save_note" in logged + assert secret not in logged + + def _distinct_json_objects(count: int) -> str: return "".join(json.dumps({"n": index}, separators=(",", ":")) for index in range(count))