mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-25 22:20:43 +00:00
* feat(model_armor): scan MCP tool results on post_mcp_call Model Armor now lists post_mcp_call as a supported event hook, so a guardrail with mode [post_call, post_mcp_call] loads at startup. post_mcp_call_hook also runs native-hook guardrails that override apply_guardrail and list post_mcp_call, which sends MCP tool results to sanitizeModelResponse. apply_guardrail masks de-identified response text when mask_response_content is set, and raises on a Model Armor API error when fail_on_error is true and the guardrail is not logging_only. * fix(model_armor): honor fail_on_error when a per-text response rescan fails * fix(mcp): pass request guardrails to post_mcp_call on the Responses MCP path A default_on false guardrail named on the key or the request was skipped for MCP tool results on /v1/responses, because the hook got request data without the resolved guardrails * fix(model_armor): log a block found on a per-text rescan as guardrail_flagged When masking rescans each text and one of them is blocked, the request was rejected but the only logged guardrail entry stayed at success from the joined scan. * fix(model_armor): keep logging_only flagging de-identified responses after one scan * fix(model_armor): fail a scan that skipped a filter and block redactions that span text blocks * fix(model_armor): fail a skipped filter only on post_mcp_call and scan a repeated tool result text once * fix(model_armor): leave whitespace-only texts out of the Model Armor scan Model Armor answers HTTP 400 for a whitespace-only text, so a tool result whose only text is blank was withheld, and a blank block next to a match failed the masking rescan. * fix(model_armor): mask a match found while another filter was skipped when failing open On post_mcp_call with fail_on_error false, a scan where Model Armor skipped a filter but its de-identify filter matched returned the raw value. It now masks that match. A text rescan that skipped a filter keeps its text, and the combined redaction check still blocks if a match is lost. fail_on_error true still withholds the result. * fix(model_armor): log a result masked after a skipped filter as guardrail_failed_to_respond * fix(model_armor): rescan only the texts the redaction changed, and never block on a rescan Masking rescanned every distinct text on its own, one Model Armor call each, and a short fragment could trip a classifier the full scan did not, blocking a clean result. Only texts whose lines the full redaction changed are rescanned now, and a rescan only supplies the rewrite. The check that the rewrites reproduce the full redaction still blocks when they do not. * fix(model_armor): find the texts a redaction changed in linear time SequenceMatcher was quadratic on repeated lines and ran on the event loop. A redaction that keeps the line count is compared line by line, and one that changes it rescans the span between the common prefix and suffix. * fix(model_armor): take each text's rewrite from the full redaction when it keeps the line count A rescan of one text alone can miss a value the full scan found from a neighbouring line, and the join check then blocked a result that only needed masking. When the full redaction has the same number of lines as the scanned texts, each text's rewrite is now its own lines of that redaction, with no rescan. Rescans run only when a redaction changes the line count. * test(model_armor): integration cells for blank blocks, skipped filters and the apply_guardrail endpoint The de-identify cell now expects one Model Armor scan, since a redaction that keeps the line count is split back into the texts without a rescan. * fix(model_armor): treat a de-identify match without a rewrite as a Model Armor error With mask_response_content on, a de-identify MATCH_FOUND that carried no data.text left the redaction equal to the original, so the raw text was returned. It now counts as an incomplete scan, so fail_on_error decides and the default withholds the result, as the streaming path already did. The incomplete-scan checks move into one helper. * fix(model_armor): fail open on every Model Armor error when fail_on_error is false Timeouts and Google token refresh errors skipped fails_open in apply_guardrail, so post_mcp_call answered 500 even with fail_on_error false. Both the full scan and the per-text rescan now route any non-block error through fails_open, the same as the native post_call hook. --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| _config_mcp_e2e.yaml | ||
| _math_server.py | ||
| test_admin_mcp_authorization.py | ||
| test_interactions.py | ||
| test_litellm_proxy_mcp_handler_real_io.py | ||
| test_mcp_access_matrix.py | ||
| test_mcp_accounting_guardrails.py | ||
| test_mcp_agent_365_guardrail.py | ||
| test_mcp_akto_logging_only.py | ||
| test_mcp_client_real_io.py | ||
| test_mcp_credentials.py | ||
| test_mcp_lifecycle.py | ||
| test_mcp_listed_tool_metadata.py | ||
| test_mcp_llm_endpoints.py | ||
| test_mcp_management.py | ||
| test_mcp_model_armor_post_mcp_call.py | ||
| test_mcp_oauth_flows.py | ||
| test_mcp_protocol_errors.py | ||
| test_mcp_rate_limits.py | ||
| test_mcp_resilience.py | ||
| test_mcp_submission_rules.py | ||
| test_mcp_tool_permission_merge.py | ||
| test_mcp_toolsets.py | ||
| test_mcp_transports.py | ||
| test_mcp_user_env_vars.py | ||
| test_oauth_configuration.py | ||
| test_openapi_to_mcp_generator_real_io.py | ||
| test_pagination.py | ||
| test_proxy_mcp_e2e.py | ||
| test_responses_mcp_mixed_tools.py | ||
| test_responses_mcp_streaming_round_history.py | ||