litellm/tests
yucheng-berri 5f9dd38867
feat(guardrails): add decision model guardrail with Admin UI flow (#45663)
* feat(guardrails): add decision_model guardrail for decisions-API models

Adds a new guardrail provider that scores request and response text with a
decisions-API model (e.g. Jev) against named predicate checks. Each check
carries its own threshold and action (block or log); a flagged block check
rejects the request with a 400 naming the flagged checks, and call failures
honor unreachable_fallback (fail_open or fail_closed).

Ships four preset checks for the Admin UI (prompt injection, jailbreak,
system prompt extraction, data exfiltration) served from
/guardrails/ui/add_guardrail_settings, plus a Decision Model step in the
add-guardrail form filtered to evaluation-mode models.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(guardrails): fail closed on verdict errors and drop comments in decision_model

* feat(guardrails): cap decision_model input with head and tail elision

* fix(guardrails): list only block checks in decision_model 400s and tighten inputs

* feat(guardrails): honor timeout, cap checks at MAX_DECISION_QUESTIONS, and reject duplicate check names

* fix(guardrails): decorate decision_model apply_guardrail with log_guardrail_information

* fix(guardrails): suppress untyped-decorator pyright error on log_guardrail_information import

* feat(guardrails): screen each text in overlapping chunks with a shared decisions-call semaphore

Replace head/tail elision with per-text screening: each non-empty text is
sent to the decision model on its own, split into overlapping chunks when
it exceeds max_input_chars, and all calls run under a per-event-loop
semaphore shared across requests (max_concurrent_decision_calls,
default 8). Check verdicts aggregate the max probability across calls; a
missing predicate answer on a Block check blocks under fail_closed and
only warns under fail_open, while log-only checks are never flagged for
it. The 400 detail now lists flagged check names only. The provider
combobox also matches Decision Model on jev, typesafe, prompt injection,
jailbreak, and decision

* fix(ui): align decision model custom check rows with preset rows

* fix(ui): move decision model custom check remove button to the row end

* style(ui): run prettier on decision model check files

* fix(ui): inline decision model evaluation-mode filter after lens module removal

* fix(guardrails): keep decision model detections when a chunk call fails

* fix(ui): require an enabled decision model check before create

* fix(guardrails): screen decision model texts sequentially like presidio

* feat(guardrails): replace decision model presets with provider picker and per-question test

* fix(ui): render decision model question test as a full-width row

* feat(ui): add run-history test section to decision model form

* fix(ui): prevent threshold overlap and show test shortcut

* feat(guardrails): default decision model threshold to 0.7

* test(ui): expect decision model default threshold 0.7 in characterization payload

* feat(guardrails): screen tool call arguments with the decision model

* refactor(guardrails): freeze the decision model config model

* feat(guardrails): list only evaluation-mode deployments in the decision model picker

* feat(guardrails): hide the decision model questions table until a question exists

* style(ui): format DecisionModelFields

* style(ui): format decisionModelQuestion tests

* refactor(guardrails): type the tool call function extraction

* refactor(guardrails): build tool call texts without a mutable accumulator

* refactor(ui): share isDecisionMode for the decision model picker

* fix(guardrails): screen prior Responses function call arguments in the decision model guardrail

The Responses input handler leaves function_call arguments out of texts and tool_calls, so a prompt injection in a prior call's arguments passed unscreened. Assistant tool calls from structured messages are now screened too, deduplicated against the request's tool calls

* test(integration): send instructions with the decision model guardrail check

Checks require instructions, so creating the guardrail returned 422 and the test never sent a chat request

* fix(ui): score the decision model test preview the way the guardrail does

An unanswered block question now shows Block, disabled questions no longer count, and a run is hidden once the model or a question's text changes since it was scored

* fix(ui): clear the decision model error on pick and list questions under Add a question

Picking a model after a failed Create left "Select a decision model" on screen, because the form only validates on submit. The field now revalidates when it already shows an error. The Questions table and its heading appear only once a question exists, below the Add a question box

* test(ui): move the decision model form tests into an integration test file

They render the whole AddGuardrailForm, so they belong in a .integration.test.tsx file. Plain fields are now filled with fireEvent.change, and the two existing form test files go back to main apart from the modelHubCall mock the form now needs

* test(guardrails): build the decision model test params without mutating a local

* fix(guardrails): reject list checks outside decision_model and honor streaming scan settings

- LitellmParams now rejects a list `checks` for any guardrail other than
  decision_model, so a Bedrock guardrail with list checks gets 422 again
  instead of being stored and failing every request
- The decision model guardrail reads streaming_end_of_stream_only and
  streaming_sampling_rate, so a streamed post_call response can be scored
  once at end of stream instead of every 5 chunks
- max_concurrent_decision_calls is described as a per-worker limit

* fix(ui): match guardrail providers like the default picker filter

- The provider search uses the Base UI collator filter on the label and
  the aliases, so searches such as presidio_pii or llm_as_a_judge match
  again, as they did before the alias filter
- Model groups from /model_group/info are parsed defensively and after the
  providers are populated, so a malformed response cannot empty the
  provider list

* fix(ui): edit decision model questions in place and show passing test chips in green

Questions start as an Add question button. Each click adds a blank question
card with its name, text, action and threshold, editable until the guardrail
is created, mirroring the per-model budget editor. Create and Next reject a
blank or duplicate enabled question. Test run verdicts and chips use the
success tone for Pass, the error tone for Block and the warning tone for a
flagged Log only question

* fix(ui): drop the per-question enable checkbox from the decision model form

A question is either in the list or removed with its X, so every listed
question is sent and scored. The card now labels Name and Question the way
it labels Action and Threshold

* fix(ui): give the question name field the full card width

* fix(ui): show the provider logo on the selected decision provider

* fix(ui): show the full threshold slider track on decision model questions

* feat(ui): add decision model cards to the guardrail garden

Adds a Decision Model section to the guardrail garden with TypeSafe Jev,
Perplexity, Microsoft, OpenAI and Databricks cards. Each card opens the
create form scoped to that provider's decision models.

The create form drops the Decision Provider picker and lists every
decision model on the proxy with its provider logo, prompts to add a
model when none is available, and says that test runs are billed and
logged.

* fix(ui): shorten the decision model test hint to one line

* fix(ui): prefill the decision model from the garden card's provider

* chore(ui): regenerate the dashboard API types after merging main

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: yucheng-berri <293926326+yucheng-berri@users.noreply.github.com>
2026-10-10 16:00:27 -07:00
..
_support fix(params): validate stream_chunk_size once, before any provider call (#43222) 2026-09-26 23:01:20 +00:00
agent_tests/local_only_agent_tests test: move whole-unit legacy test files into tests/unit and delete dead skips (#44807) 2026-10-07 05:02:28 +00:00
audio_tests test: move 81 legacy live tests in pass-through, spend, batches, audio, search, guardrails, image and ocr dirs offline (#45288) 2026-10-08 02:38:12 -07:00
base_sdk_tests test: move packaging and install checks off CircleCI build_and_test (#45757) 2026-10-10 09:33:51 -07:00
basic_proxy_startup_tests fix(security): remove the publicly known master key from the repo (#44718) 2026-10-06 10:55:24 -07:00
batches_tests test: move 81 legacy live tests in pass-through, spend, batches, audio, search, guardrails, image and ocr dirs offline (#45288) 2026-10-08 02:38:12 -07:00
benchmarks refactor: expose core private helpers under public names (#44871) 2026-10-07 00:05:27 +00:00
code_coverage_tests docs(proxy): describe /v1/decisions and /v1/systemone in Swagger UI (#45838) 2026-10-10 21:04:59 +00:00
documentation_tests fix(proxy): let configured pass-through endpoints outrank built-in provider prefix routes (#44133) 2026-10-10 12:26:17 -07:00
e2e fix(proxy/auth): expand all-team-models sentinel for project model access checks (#43734) 2026-10-10 15:49:27 -07:00
e2e_harness docs(agents): ban semicolons and colons in human-facing text (#45684) 2026-10-09 16:36:32 -07:00
guardrails_tests test: move 81 legacy live tests in pass-through, spend, batches, audio, search, guardrails, image and ocr dirs offline (#45288) 2026-10-08 02:38:12 -07:00
harness_e2e feat: add litellm.agent() to run claude code, codex, opencode and deep agents through the ai gateway (#43885) 2026-10-01 22:27:49 +00:00
image_gen_tests test: move 81 legacy live tests in pass-through, spend, batches, audio, search, guardrails, image and ocr dirs offline (#45288) 2026-10-08 02:38:12 -07:00
integration feat(guardrails): add decision model guardrail with Admin UI flow (#45663) 2026-10-10 16:00:27 -07:00
litellm_utils_tests test: move offline proxy auth, hook, spend and pass-through tests to tests/unit (#45568) 2026-10-09 09:49:13 -07:00
llm_translation test: fix stale and flaky tests across CircleCI, GHA and Buildkite (#45530) 2026-10-09 11:40:14 -07:00
load_tests fix(security): remove the publicly known master key from the repo (#44718) 2026-10-06 10:55:24 -07:00
local_testing test: move packaging and install checks off CircleCI build_and_test (#45757) 2026-10-10 09:33:51 -07:00
logging_callback_tests test: move offline proxy auth, hook, spend and pass-through tests to tests/unit (#45568) 2026-10-09 09:49:13 -07:00
mcp_tests perf(ci): isolate and shard integration suites (#44146) 2026-10-10 11:15:19 -07:00
multi_instance_e2e_tests fix(security): remove the publicly known master key from the repo (#44718) 2026-10-06 10:55:24 -07:00
ocr_tests test: move 81 legacy live tests in pass-through, spend, batches, audio, search, guardrails, image and ocr dirs offline (#45288) 2026-10-08 02:38:12 -07:00
openai_endpoints_tests test: move 81 legacy live tests in pass-through, spend, batches, audio, search, guardrails, image and ocr dirs offline (#45288) 2026-10-08 02:38:12 -07:00
otel_tests test: replace 61 live logging and otel tests with offline unit and integration coverage (#45362) 2026-10-08 15:55:57 -07:00
pass_through_tests test: delete 34 legacy tests already covered by e2e (#45340) 2026-10-08 09:43:56 -07:00
pass_through_unit_tests test: move offline proxy auth, hook, spend and pass-through tests to tests/unit (#45568) 2026-10-09 09:49:13 -07:00
proxy_admin_ui_tests test: move the unit half of 126 mixed legacy files into tests/unit (#45090) 2026-10-07 14:07:43 -07:00
proxy_behavior refactor(lens): connect LiteLLM to the independent Lens service (#45529) 2026-10-09 16:17:05 -07:00
proxy_e2e_anthropic_messages_tests fix(security): remove the publicly known master key from the repo (#44718) 2026-10-06 10:55:24 -07:00
proxy_migration_tests perf(ci): isolate and shard integration suites (#44146) 2026-10-10 11:15:19 -07:00
proxy_security_tests fix(security): remove the publicly known master key from the repo (#44718) 2026-10-06 10:55:24 -07:00
proxy_unit_tests fix(security): remove the publicly known master key from the repo (#44718) 2026-10-06 10:55:24 -07:00
router_unit_tests test: make 77 legacy live tests offline in litellm_utils, router_unit and responses dirs (#45298) 2026-10-08 02:37:55 -07:00
rust-python-harness docs(agents): ban semicolons and colons in human-facing text (#45684) 2026-10-09 16:36:32 -07:00
search_tests test: move 81 legacy live tests in pass-through, spend, batches, audio, search, guardrails, image and ocr dirs offline (#45288) 2026-10-08 02:38:12 -07:00
store_model_in_db_tests fix(security): remove the publicly known master key from the repo (#44718) 2026-10-06 10:55:24 -07:00
test_litellm refactor(lens): connect LiteLLM to the independent Lens service (#45529) 2026-10-09 16:17:05 -07:00
test_litellm_rust fix(python-bridge): preserve callback keyword deletions in native requests (#45692) 2026-10-10 02:36:49 +00:00
typing fix: support OpenAI SDK 3 while retaining SDK 2 compatibility (#44927) 2026-10-09 19:45:50 -07:00
unified_google_tests test: move whole-unit legacy test files into tests/unit and delete dead skips (#44807) 2026-10-07 05:02:28 +00:00
unit feat(guardrails): add decision model guardrail with Admin UI flow (#45663) 2026-10-10 16:00:27 -07:00
vector_store_tests refactor: expose core private helpers under public names (#44871) 2026-10-07 00:05:27 +00:00
windows_tests test: move packaging and install checks off CircleCI build_and_test (#45757) 2026-10-10 09:33:51 -07:00
__init__.py refactor: expose core private helpers under public names (#44871) 2026-10-07 00:05:27 +00:00
_fake_openai_endpoint_server.py
_flush_vcr_cache.py
_live_test_helpers.py refactor(test): validate cost-map entries into a typed model 2026-09-16 14:32:08 -07:00
_master_key.py fix(security): remove the publicly known master key from the repo (#44718) 2026-10-06 10:55:24 -07:00
_openai_record_replay_proxy.py
_process_helpers.py test: count a zombie grandchild as gone in the migrate deploy timeout test (#42570) 2026-09-22 14:59:26 -07:00
_vcr_conftest_common.py fix(tests): stop VCR recording and replaying a test's own localhost upstream (#43346) 2026-09-26 15:49:39 -07:00
_vcr_redis_persister.py
_wait_helpers.py
_ws_vcr.py
AGENTS.md docs(agents): ban semicolons and colons in human-facing text (#45684) 2026-10-09 16:36:32 -07:00
capturing_transport.py test(vcr): guard leaked cassette patches and make injected-transport embedding tests immune (#42542) 2026-09-22 14:20:18 -07:00
eval_swe_bench.py
fake_openai_endpoint.py
gettysburg.wav
large_text.py
openai_batch_completions.jsonl
pyrightconfig.json
README.MD test: finish the non-proxy half of tests/test_litellm (#43281) 2026-09-25 22:43:41 -07:00
test_debug_warning.py
test_keys.py test: move 76 live top-level tests to offline unit and integration coverage (#45352) 2026-10-08 10:33:35 -07:00
test_litellm_proxy_responses_config.py test: move 76 live top-level tests to offline unit and integration coverage (#45352) 2026-10-08 10:33:35 -07:00
test_logging.conf
test_models.py test: move 76 live top-level tests to offline unit and integration coverage (#45352) 2026-10-08 10:33:35 -07:00
test_new_vector_store_endpoints.py test: move 76 live top-level tests to offline unit and integration coverage (#45352) 2026-10-08 10:33:35 -07:00
test_openai_endpoints.py test: move 76 live top-level tests to offline unit and integration coverage (#45352) 2026-10-08 10:33:35 -07:00
test_proxy_server_non_root.py
test_rust_python_harness.py test: move 76 live top-level tests to offline unit and integration coverage (#45352) 2026-10-08 10:33:35 -07:00
test_service_logger_otel.py test: move 76 live top-level tests to offline unit and integration coverage (#45352) 2026-10-08 10:33:35 -07:00
test_spend_logs.py test: move 76 live top-level tests to offline unit and integration coverage (#45352) 2026-10-08 10:33:35 -07:00
test_team_logging.py fix(security): remove the publicly known master key from the repo (#44718) 2026-10-06 10:55:24 -07:00
test_users.py test: move 76 live top-level tests to offline unit and integration coverage (#45352) 2026-10-08 10:33:35 -07:00
white_100x100.png test: stop CI tests from downloading tokenizer files and images (#43257) 2026-09-25 19:27:48 -07:00

In total litellm runs 1000+ tests

[02/20/2025] Update:

To make it easier to contribute and map what behavior is tested,

we've started mapping the litellm directory in tests/unit

This folder can only run mock tests.