litellm/litellm/proxy/guardrails
mrinal-berri 3b05f390f2
feat(guardrails): opt-in pre_call scan of tool descriptions as text for PANW and Presidio (#50301)
* feat(guardrails): opt-in pre_call scan of tool descriptions as text for PANW and Presidio

PANW Prisma AIRS and Presidio only scan text, so the tools[] sent to the model
reached it unscanned. The new per-guardrail scan_tool_descriptions_as_text flag
scans every description string in tools[] on pre_call, one guardrail call per
tool, so a block returns 400 and a mask rewrites the description in place.
Other guardrails are unchanged and reject the flag at startup.

Resolves LIT-8384

* fix(guardrails): also scan legacy functions[] descriptions as text

With scan_tool_descriptions_as_text on, a Chat Completions client could move a
tool definition into the legacy functions[] list and skip the scan. The scan now
covers both tools[] and functions[], writing masks back to whichever field held
the definition. Test helpers are now fully typed.

* test(guardrails): cover untouched tools through PANW instead of patching Presidio

The Presidio case replaced a private session method. Its one unique check, that a
tool without a flagged description is sent unchanged, now runs through PANW's
injected HTTP client. Real Presidio is covered by the live proof in the PR.

* chore(ui): regenerate OpenAPI snapshot and UI types for scan_tool_descriptions_as_text

* refactor(guardrails): return tool-scan failures as values and raise them in one place

An over-deep tool definition and a guardrail that returns the wrong number of
descriptions now come back as _ToolNotScanned values, and _raise_public maps them
to the existing 400 body, as endpoint_image_scan does. Adds tests for both paths.

* fix(guardrails): scan tool descriptions carried in Responses additional_tools and tool_search_output input items

Tool definitions sent inside /v1/responses input items reach the model the same way
top-level tools do, through the chat bridge hoist or native forwarding, but the
opt-in pre_call scan only read the top-level tools and functions lists. Each tool is
now located by its path in the request and masked text is written back at that path.

* chore(guardrails): drop docstrings that restate the tool-description scan code
2026-11-19 14:04:10 -08:00
..
content_filter_data fix(packaging): keep wheel paths under Windows MAX_PATH for Store Python (#43903) 2026-09-30 22:20:36 +00:00
guardrail_hooks feat(guardrails): opt-in pre_call scan of tool descriptions as text for PANW and Presidio (#50301) 2026-11-19 14:04:10 -08:00
_content_utils.py fix(anthropic)!: do not surface server_tool_use as client tool_calls (#48385) 2026-11-06 03:54:34 -08:00
anthropic_sse.py fix(guardrails)!: keep the upstream error when a /v1/messages stream ends in one (#49088) 2026-10-31 02:56:20 -07:00
auto_router_compression.py refactor(router): move router callers onto the entry points and invert the proxy imports (#48847) 2026-10-29 17:26:33 +00:00
endpoint_image_scan.py feat(guardrails): scan an image on /apply_guardrail with a Bedrock guardrail (#51016) 2026-11-17 18:13:28 +00:00
exception_utils.py feat(guardrails): add mcp_block_behavior to raise 400 on MCP tool blocks (#50284) 2026-11-06 12:31:00 -08:00
guardrail_endpoints.py feat(guardrails): scan an image on /apply_guardrail with a Bedrock guardrail (#51016) 2026-11-17 18:13:28 +00:00
guardrail_helpers.py fix(proxy): reject unknown guardrail names on key, user, team and project writes (#51080) 2026-11-11 19:28:45 -08:00
guardrail_initializers.py Configure full Bedrock guardrail assessments (#49217) (#49470) 2026-10-31 23:37:45 +00:00
guardrail_registry.py feat(guardrails): opt-in pre_call scan of tool descriptions as text for PANW and Presidio (#50301) 2026-11-19 14:04:10 -08:00
init_guardrails.py refactor(router): move router callers onto the entry points and invert the proxy imports (#48847) 2026-10-29 17:26:33 +00:00
response_handlers.py fix(guardrails): log requests that a guardrail blocks on /apply_guardrail (#51014) 2026-11-16 15:18:08 -08:00
tool_name_extraction.py refactor(typing): clear 1181 basedpyright Any errors across 431 files (#47789) 2026-10-24 11:31:09 -07:00
usage_endpoints.py refactor(typing): clear 1181 basedpyright Any errors across 431 files (#47789) 2026-10-24 11:31:09 -07:00
usage_tracking.py feat(accounting): add opt-in SpendLogs ledger (#49856) 2026-11-04 17:49:15 -08:00