litellm/tests/test_litellm/proxy/guardrails/guardrail_hooks
devin-ai-integration[bot] 317430db4e
fix(panw_prisma_airs): honor experimental_use_latest_role_message_only on every request shape (#42447)
* fix(panw_prisma_airs): apply experimental_use_latest_role_message_only to every request shape

Explicit true/false now applies to chat completions, Anthropic /v1/messages and /v1/responses alike; unset keeps latest-only for Anthropic and full history otherwise. Text indices are mapped back to their source message by value instead of by count, so Responses instructions, function_call_output and reasoning items no longer derail the alignment and silently rescan the whole history

Co-authored-by: scthornton <scthornton@gmail.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor(panw_prisma_airs): type latest-message helpers against AllMessageValues

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(panw_prisma_airs): require forward and reverse text attribution to agree

A Responses function_call_output whose text equals the latest user turn could claim that turn's slot in a forward-only walk and demote the latest-only scan to an earlier message. Walk both directions and fall back to the full role-filter scan when they disagree

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(panw_prisma_airs): pick the latest human turn from messages, not from aligned texts

An image-only latest user turn no longer promotes an earlier user turn into the
latest-only scan; it scans nothing on the request side, as the Anthropic path did
before. A latest user/developer message whose text never reached texts (a trailing
Responses reasoning item) falls back to the role-filter scan instead of narrowing.
Types the test helpers, drops the narrating docstrings and adds regressions for both
shapes

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(panw_prisma_airs): log when latest-only selection leaves nothing to scan

An image-only latest user turn with experimental_use_latest_role_message_only=true intentionally yields zero scanner calls. Emit a debug line naming the call_id so operators can tell this apart from the guardrail not firing.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(panw_prisma_airs): keep Responses reasoning items out of latest-turn selection

The Responses translation handler gives reasoning input items the default user
role, so a reasoning item with text content after the latest prompt was picked
as the latest human turn and the real prompt went unscanned under
experimental_use_latest_role_message_only. Map reasoning items back to their
texts positions from the raw input and exclude them; fall back to the
role-filter scan when the raw items do not account for every text

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: yucheng <yucheng@berri.ai>
Co-authored-by: scthornton <scthornton@gmail.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-28 21:16:18 +00:00
..
azure test(guardrails): drop regression docstrings from the api_version tests 2026-09-19 02:52:42 -07:00
content_filter fix(content_filter): refuse a trim that splits a conditional word across the cut 2026-09-16 12:45:58 +00:00
guardrails_ai style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
openai Revert "Merge pull request #41220 from BerriAI/litellm_post_call_guardrail_context" 2026-09-19 17:45:15 +00:00
unified_guardrails test(guardrails): gate the video e2e on a chat probe so a miss starts at most one paid job 2026-09-21 23:20:29 +00:00
_cisco_ai_defense_test_utils.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
code_execution_compliance_dataset.json feat(add-new-block_code_execution-guardrail): prevent agent from executing code (#22154) 2026-02-25 22:02:14 -08:00
test_agent_365.py refactor(guardrails): fix agent 365 to the production endpoint and log the opt-in fail_open at error level (#43189) 2026-09-28 12:05:47 -07:00
test_aim.py feat(guardrails): add inspect_embeddings toggle for AIM and Cato (#39918) 2026-09-05 17:15:46 -07:00
test_alice.py feat(guardrails): add Alice guardrail (#38898) 2026-09-01 12:33:39 -07:00
test_bedrock_guardrails.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_bedrock_invoke_guardrail_checks.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_block_code_execution.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_block_code_execution_compliance.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_cato_networks.py feat(guardrails): add inspect_embeddings toggle for AIM and Cato (#39918) 2026-09-05 17:15:46 -07:00
test_cisco_ai_defense_chat.py test: drop the leftover set_verbose from eleven test files (#37845) 2026-08-22 08:23:27 -07:00
test_cisco_ai_defense_mcp.py fix(mcp): apply post-call rewrites without stale structured output (#41530) 2026-09-22 13:44:25 -07:00
test_compresr.py fix(guardrails): preserve cache_control breakpoints in compresr write-back 2026-07-25 14:47:25 -07:00
test_conduct.py feat(lint): add LIT013 flagging *-ok suppressions that suppress nothing and remove the 240 stale ones (#42793) 2026-09-23 17:50:09 -07:00
test_crowdstrike_aidr.py Revert "Merge pull request #41220 from BerriAI/litellm_post_call_guardrail_context" 2026-09-19 17:45:15 +00:00
test_custom_code_bounded_execution.py fix(guardrails): block private destinations in custom code http_request and bound guardrail execution time (#43280) 2026-09-26 12:57:41 -07:00
test_deepkeep.py test(guardrails): stop five guardrail test files leaking env vars on failure (#37828) 2026-08-21 21:29:31 -07:00
test_dynamoai.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_enkryptai.py test: require a match= on broad pytest.raises, and drop duplicate parametrize cases (#37769) 2026-08-20 20:24:49 -07:00
test_generic_guardrail_api.py fix(guardrails): read the rewrite from texts when a guardrail echoes every row back unchanged 2026-09-13 03:02:15 -07:00
test_grayswan.py fix(guardrails): forward grayswan scan id header (#32544) 2026-07-08 15:05:27 -07:00
test_headroom.py refactor(anthropic): rename experimental_pass_through to pass_through (#43329) 2026-09-26 13:00:50 -07:00
test_hiddenlayer.py Revert "Merge pull request #41220 from BerriAI/litellm_post_call_guardrail_context" 2026-09-19 17:45:15 +00:00
test_javelin.py test(guardrails): drop regression docstrings from the api_version tests 2026-09-19 02:52:42 -07:00
test_lakera_ai_v2.py fix(guardrails): stop Lakera monitor mode forwarding unmasked PII on Responses-API bodies (#38841) 2026-08-29 17:07:39 -07:00
test_lasso.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_mcp_end_user_permission.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_mcp_security.py fix(guardrails): accept on_violation block and alert for mcp_security (#40155) 2026-09-07 14:33:02 -07:00
test_microsoft_purview.py test: enforce PT012 so a pytest.raises block cannot hide dead assertions (#37748) 2026-08-20 19:36:26 -07:00
test_model_armor.py test(model_armor): inject HTTP handler and token provider 2026-09-14 18:03:22 +00:00
test_noma.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_noma_v2.py perf(guardrails): stop sending the conversation twice in the noma v2 payload (#36764) 2026-08-17 15:37:17 -07:00
test_onyx.py test(guardrails): stop five guardrail test files leaking env vars on failure (#37828) 2026-08-21 21:29:31 -07:00
test_ovalix.py feat: litellm oss 110626 (#30202) 2026-06-11 22:30:26 -07:00
test_pangea.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_panw_prisma_airs.py fix(panw_prisma_airs): honor experimental_use_latest_role_message_only on every request shape (#42447) 2026-09-28 21:16:18 +00:00
test_presidio.py fix(presidio): mask streamed /v1/messages output when the first upstream read is a keepalive, a data-less ping, or a split utf8 character (#43023) 2026-09-25 00:48:42 -07:00
test_presidio_union_fix.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_promptguard.py Revert "Merge pull request #41220 from BerriAI/litellm_post_call_guardrail_context" 2026-09-19 17:45:15 +00:00
test_qualifire.py Revert "Merge pull request #41220 from BerriAI/litellm_post_call_guardrail_context" 2026-09-19 17:45:15 +00:00
test_repelloai.py test(guardrails): stop five guardrail test files leaking env vars on failure (#37828) 2026-08-21 21:29:31 -07:00
test_response_rejection_guardrail_code.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_singulr.py fix(guardrails): run Singulr logging_only through the base hook, key MCP scans off the proxy call type and type the payloads 2026-09-15 19:14:49 -07:00
test_straiker.py feat(guardrails): straiker guardrail speaks the v3 platform API (/api/v3/detect) (#41880) 2026-09-23 12:21:09 -07:00
test_structured_messages_writeback.py fix(guardrails/headroom): stop compressing the turn the model must act on (#35294) 2026-07-30 18:53:31 -07:00
test_tool_permission.py fix(anthropic): satisfy strict lint and update tests pinned to the dropped served model 2026-09-16 17:44:59 +00:00
test_tool_policy_guardrail.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_typesafe.py fix(guardrails): keep typesafe registries as dicts so guardrail discovery finds them 2026-09-18 06:05:43 +00:00
test_vigil_guard.py Litellm OSS Staging 010626 (#29422) 2026-06-01 21:42:51 -07:00
test_xecguard.py fix(xecguard): sanitize scan result before recording it for logging (#32935) 2026-07-12 02:46:02 +00:00