mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-30 01:08:33 +00:00
* fix(guardrails): check tool calls in Google streamGenerateContent streams under tool_permission The tool_permission post-call hook read every raw SSE stream as Anthropic, so each Gemini stream on the Google streamGenerateContent route failed with a 400 naming an Anthropic parse failure. The hook now reads functionCall parts from those streams, delivers a stream with no denied call unchanged, blocks or rewrites a denied call, and still refuses a stream it cannot read * fix(guardrails): move a denied first call's thought signature to the next kept call in Gemini stream rewrites Gemini 3 signs only the first functionCall of a turn and answers 400 to a next turn whose first call has no thoughtSignature. Rewrite mode used to drop the signature with the denied call, so a client that sent the rewritten turn back got that 400 When a turn's first call is denied and a later call in the same candidate is kept, the signature now moves to the first kept call. Otherwise a denied call's signature stays on its text part. Lines without a changed part still go out byte for byte * test(guardrails): type the Gemini stream test parameters * fix(guardrails): match a Gemini stream rewrite's turn by candidate index The signature handoff grouped calls by their slot in a frame's candidates array, so frames that each carried a different candidate as their only element were treated as one turn. Group by the candidate's index field, and refuse a frame whose index is not an integer * fix(guardrails): keep a kept Gemini call's own thought signature in a stream rewrite --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| guardrail_hooks | ||
| __init__.py | ||
| test_anthropic_sse.py | ||
| test_auto_router_compression.py | ||
| test_content_filter_path_traversal.py | ||
| test_content_utils.py | ||
| test_custom_code_security.py | ||
| test_deferred_guardrail_logging.py | ||
| test_endpoint_image_scan.py | ||
| test_guardrail_coverage.py | ||
| test_guardrail_endpoints.py | ||
| test_guardrail_helpers.py | ||
| test_guardrail_initializers.py | ||
| test_guardrail_load_balancing.py | ||
| test_guardrail_registry.py | ||
| test_init_guardrails.py | ||
| test_llm_as_a_judge.py | ||
| test_mcp_jwt_signer.py | ||
| test_pillar_guardrails.py | ||
| test_prompt_security_guardrails.py | ||
| test_qostodian_nexus_guardrail.py | ||
| test_usage_endpoints.py | ||
| test_usage_tracking.py | ||