From f47b978dfc1e4091f03fb57ba774cd37fcd125fa Mon Sep 17 00:00:00 2001 From: yucheng Date: Thu, 24 Sep 2026 09:05:40 +0000 Subject: [PATCH] test(guardrails): assert the scanned texts in the serialized tool output cases Co-authored-by: feng.tsai Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../guardrail_hooks/test_bedrock_guardrails.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_bedrock_guardrails.py b/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_bedrock_guardrails.py index c94da4513b2..a6010b88da8 100644 --- a/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_bedrock_guardrails.py +++ b/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_bedrock_guardrails.py @@ -7249,6 +7249,9 @@ async def test_during_call_hook_chat_tool_output_attachment_scans_as_text(): ) mock_post.assert_called_once() + sent_body = json.loads(mock_post.call_args.kwargs["data"]) + sent_texts = [item["text"]["text"] for item in sent_body["content"] if "text" in item] + assert tool_output in sent_texts @pytest.mark.asyncio @@ -7640,6 +7643,9 @@ async def test_during_call_hook_chat_tool_output_metadata_members_scan_as_text(m ) mock_post.assert_called_once() + sent_body = json.loads(mock_post.call_args.kwargs["data"]) + sent_texts = [item["text"]["text"] for item in sent_body["content"] if "text" in item] + assert json.dumps([member]) in sent_texts @pytest.mark.asyncio @@ -7687,6 +7693,9 @@ async def test_during_call_hook_responses_tool_output_metadata_members_scan_as_t ) mock_post.assert_called_once() + sent_body = json.loads(mock_post.call_args.kwargs["data"]) + sent_texts = [item["text"]["text"] for item in sent_body["content"] if "text" in item] + assert any(str(member.get("id", "")) in text or str(member.get("name", "")) in text for text in sent_texts) @pytest.mark.asyncio