litellm/litellm
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
..
a2a_protocol fix: prompt registry 2026-02-18 00:34:54 +05:30
anthropic_interface fix: prompt registry 2026-02-18 00:34:54 +05:30
assistants
batch_completion fix: prompt registry 2026-02-18 00:34:54 +05:30
batches Fix: Test connect failing for bedrock batches mode 2026-02-25 15:03:27 +05:30
caching fix(proxy): add LPOP pipeline error checking and fix org spend ServiceType 2026-02-24 14:22:57 -08:00
completion_extras fix code quality tests and mypy 2026-02-18 17:36:36 +05:30
containers fix: prompt registry 2026-02-18 00:34:54 +05:30
endpoints/speech/speech_to_completion_bridge
evals fix: prompt registry 2026-02-18 00:34:54 +05:30
experimental_mcp_client fix: prompt registry 2026-02-18 00:34:54 +05:30
files fix: prompt registry 2026-02-18 00:34:54 +05:30
fine_tuning
google_genai fix: prompt registry 2026-02-18 00:34:54 +05:30
images fix: prompt registry 2026-02-18 00:34:54 +05:30
integrations feat(realtime guardrails): end_session_after_n_fails + Endpoint Settings wizard step (#22165) 2026-02-25 23:49:03 -08:00
interactions fix: prompt registry 2026-02-18 00:34:54 +05:30
litellm_core_utils feat(realtime guardrails): end_session_after_n_fails + Endpoint Settings wizard step (#22165) 2026-02-25 23:49:03 -08:00
llms fix(realtime): guardrails with pre_call/post_call mode now work on realtime WebSocket (#22161) 2026-02-25 23:43:13 -08:00
ocr [Feat] /ocr - Add VertexAI OCR provider support + cost tracking (#16216) 2025-11-03 15:56:49 -08:00
passthrough fix(types): fix mypy errors in pass-through endpoint query param types 2026-02-19 12:24:14 -03:00
proxy feat(realtime guardrails): end_session_after_n_fails + Endpoint Settings wizard step (#22165) 2026-02-25 23:49:03 -08:00
proxy_auth fix: prompt registry 2026-02-18 00:34:54 +05:30
rag fix: prompt registry 2026-02-18 00:34:54 +05:30
realtime_api fix(realtime): guardrails with pre_call/post_call mode now work on realtime WebSocket (#22161) 2026-02-25 23:43:13 -08:00
rerank_api fix(bedrock): pass timeout param to bedrock rerank http client (#22021) 2026-02-24 09:32:11 -08:00
responses fix(responses): eliminate per-chunk thread spawning in async streaming path (#21709) 2026-02-20 16:26:23 -08:00
router_strategy fix(lint): fix ruff/flake8 violations - unused imports, PLR0915, print statements (#21846) 2026-02-21 15:07:47 -08:00
router_utils Revert "Merge pull request #21957 from jquinter/fix/flaky-rpm-limit-test" 2026-02-24 09:52:50 -03:00
search [Bug Fix] Exa Search API - ensure request params are sent to Exa AI (#15855) 2025-10-23 11:56:30 -07:00
secret_managers fix: prompt registry 2026-02-18 00:34:54 +05:30
skills fix: prompt registry 2026-02-18 00:34:54 +05:30
types feat(realtime guardrails): end_session_after_n_fails + Endpoint Settings wizard step (#22165) 2026-02-25 23:49:03 -08:00
vector_store_files Vector store files Stable Release (#16643) 2025-11-15 13:00:33 -08:00
vector_stores Fix vector store configuration synchronization failure 2025-12-05 11:46:14 +05:30
videos fix(ollama): thread api_base to get_model_info + graceful fallback (#21970) 2026-02-23 21:00:37 -08:00
__init__.py feat(prometheus): add opt-in stream label to litellm_proxy_total_requests_metric (#22023) 2026-02-24 11:51:42 -08:00
_lazy_imports.py fix: prompt registry 2026-02-18 00:34:54 +05:30
_lazy_imports_registry.py Merge branch 'main' into litellm_oss_staging_02_17_2026 2026-02-18 17:26:33 +05:30
_logging.py fix: prompt registry 2026-02-18 00:34:54 +05:30
_redis.py fix: close leaked Redis connection pools on cache eviction and disconnect 2026-02-20 17:09:32 -08:00
_service_logger.py fix: prompt registry 2026-02-18 00:34:54 +05:30
_uuid.py
_version.py
anthropic_beta_headers_config.json fix: enable context-1m-2025-08-07 beta header for vertex_ai provider (#21867) 2026-02-21 20:12:23 -08:00
anthropic_beta_headers_manager.py fix: prompt registry 2026-02-18 00:34:54 +05:30
blog_posts.json fix(ollama): thread api_base to get_model_info + graceful fallback (#21970) 2026-02-23 21:00:37 -08:00
budget_manager.py
constants.py feat(proxy): tool policies - auto-discover tools + policy enforcement guardrail (#22041) 2026-02-24 16:27:06 -08:00
cost.json
cost_calculator.py fix(ollama): thread api_base to get_model_info + graceful fallback (#21970) 2026-02-23 21:00:37 -08:00
exceptions.py fix: prompt registry 2026-02-18 00:34:54 +05:30
main.py fix(ollama): thread api_base to get_model_info + graceful fallback (#21970) 2026-02-23 21:00:37 -08:00
model_prices_and_context_window_backup.json [Chore] Update aiml model pricing 2026-02-26 08:53:57 +05:30
mypy.ini
policy_templates_backup.json feat(add-new-block_code_execution-guardrail): prevent agent from executing code (#22154) 2026-02-25 22:02:14 -08:00
py.typed
router.py Merge origin/main; keep both model_group_info and access_groups cache invalidation 2026-02-24 16:08:29 -08:00
scheduler.py fix: prompt registry 2026-02-18 00:34:54 +05:30
timeout.py
utils.py Fix None (TypeError: 'NoneType' object is not a mapping) 2026-02-25 14:39:12 +05:30