litellm/litellm/types
Ishaan Jaff 965ca117bc
feat(realtime guardrails): end_session_after_n_fails + Endpoint Settings wizard step (#22165)
* feat(realtime guardrails): end_session_after_n_fails + Endpoint Settings wizard step

Adds per-session violation thresholds and an optional endpoint-settings step
to the guardrail wizard for /v1/realtime.

Backend:
- Add end_session_after_n_fails, on_violation, realtime_violation_message fields
  to BaseLitellmParams (no DB migration — stored in existing JSON column)
- Store same fields on CustomGuardrail instance attrs
- Pass through in litellm_content_filter initializer
- Track _violation_count per RealTimeStreaming session; close backend_ws when
  on_violation=end_session OR violation count >= end_session_after_n_fails
- Use realtime_violation_message as the spoken text (falls back to guardrail
  error string if not configured)

UI (add_guardrail_form.tsx):
- Rename "Default Categories" step to "Topics"
- Add step 5 "Endpoint Settings (Optional)" for content filter guardrails
- Call type dropdown shows /v1/realtime
- Settings are in a collapsed accordion (closed by default)
- "End session after X violations" + on_violation radio + spoken message field

Tests: 2 new tests in test_realtime_streaming.py
- test_end_session_after_n_fails_closes_connection
- test_on_violation_end_session_closes_on_first_fail

* fix(test): move inline imports to module level in realtime streaming tests

* Update ui/litellm-dashboard/src/components/guardrails/add_guardrail_form.tsx

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-02-25 23:49:03 -08:00
..
containers [Feat] Containers API - add new container API file management + UI Interface (#17745) 2025-12-09 17:33:26 -08:00
google_genai Fix Google GenAI types import to handle missing google.genai module 2025-10-01 01:56:52 +08:00
images fix: fix import errors 2025-09-14 09:32:21 -07:00
integrations feat(prometheus): add opt-in stream label to litellm_proxy_total_requests_metric (#22023) 2026-02-24 11:51:42 -08:00
interactions fix: add INCOMPLETE status to Interactions API enum and test 2026-02-23 15:07:41 -03:00
litellm_core_utils include server_tool_use in streaming usage (#16826) 2025-11-25 14:50:17 -08:00
llms fix: add prompt_cache_key and prompt_cache_retention support for OpenAI 2026-02-24 16:42:54 -08:00
management_endpoints Add fallback endpoints support 2026-01-16 10:51:33 +05:30
mcp_server Fix: skip health check for MCP integration with passthrough token authentication 2026-02-24 12:05:37 +05:30
passthrough_endpoints Revert "Add streamGenerateContent cost tracking in passthrough (#15199)" (#15202) 2025-10-04 14:37:02 -07:00
prompts Prompt Management - new API for integrating providers (#17829) 2025-12-11 15:43:40 -08:00
proxy feat(add-new-block_code_execution-guardrail): prevent agent from executing code (#22154) 2026-02-25 22:02:14 -08:00
responses remove comment 2026-02-25 17:40:46 +05:30
secret_managers [Feat] Adds IAM role assumption support for AWS Secret Manager (#16887) 2025-11-20 12:38:48 -08:00
videos Fix error about encoding video id for azure 2025-12-09 16:36:11 +05:30
access_group.py allow editing of access group names 2026-02-13 17:03:41 -08:00
adapter.py feat(anthropic_adapter.py): support for translating anthropic params to openai format 2024-07-10 00:32:28 -07:00
agents.py Agents - assign tools (#22064) 2026-02-25 11:44:30 -08:00
caching.py perf(proxy): pipeline Redis RPUSH/LPOP in spend update cycle 2026-02-24 12:46:52 -08:00
completion.py fix: correct CompletionRequest messages type to match OpenAI API spec (#12980) 2025-07-28 16:47:20 -07:00
embedding.py Removed config dict type definition 2024-05-17 10:39:00 +08:00
files.py [Feat] Manus FILES API - Add File upload, get, delete, list (#18904) 2026-01-10 13:27:54 -08:00
fine_tuning.py (feat) POST /fine_tuning/jobs support passing vertex specific hyper params (#7490) 2025-01-01 07:44:48 -08:00
guardrails.py feat(realtime guardrails): end_session_after_n_fails + Endpoint Settings wizard step (#22165) 2026-02-25 23:49:03 -08:00
mcp.py MCP Hub - publish/discover MCP Servers within a company (#16857) 2025-11-19 19:06:21 -08:00
policy_engine.py [Feat] New LiteLLM Policy engine - create policies to manage guardrails, conditions - permissions per Key, Team (#19612) 2026-01-22 19:49:53 -08:00
rag.py [Feat] RAG API - Add support for using s3 Vectors as Vector Store Provider for /rag/ingest (#19888) 2026-01-27 14:45:26 -08:00
realtime.py fix: fix import errors 2025-09-14 09:32:21 -07:00
rerank.py build(pyproject.toml): add new dev dependencies - for type checking (#9631) 2025-03-29 11:02:13 -07:00
router.py feat(router): Add complexity-based auto routing strategy (#21789) 2026-02-21 13:23:37 -08:00
scheduler.py Squashed commit of the following: (#9709) 2025-04-02 21:24:54 -07:00
search.py search tools list includes config defined search tools 2026-02-03 15:57:13 -08:00
services.py [Fix] CI/CD - mypy & check_code_and_doc_quality & mcp_testing (#17920) 2025-12-13 08:18:43 -08:00
tag_management.py [Feat] Tag Management - Add support for setting tag based budgets (#15433) 2025-10-10 19:24:50 -07:00
tool_management.py feat(proxy): tool policies - auto-discover tools + policy enforcement guardrail (#22041) 2026-02-24 16:27:06 -08:00
utils.py Fix: Test connect failing for bedrock batches mode 2026-02-25 15:03:27 +05:30
vector_store_files.py Vector store files Stable Release (#16643) 2025-11-15 13:00:33 -08:00
vector_stores.py [Feat] LiteLLM Vector Stores - Add permission management for users, teams (#19972) 2026-01-28 18:55:40 -08:00