litellm/tests/unit/proxy/guardrails
collieai-dev 208a5863a5
feat(guardrails): add the CollieAi guardrail integration (#49224)
* feat(guardrails): add the CollieAi guardrail integration

* refactor(guardrails): tighten the CollieAi wrapper and its tests

The loader takes its importer as a parameter, so a test covers the fallback for a package that is too old, and the install hint names the Python the package needs

The config model is frozen, the Garden preset's phases and default_on are pinned by a test, and comments the code already says are gone

* fix(guardrails): use the generated Collieai provider key in the dashboard

The dashboard builds provider keys from the proxy's provider list, so collieai becomes Collieai. The static CollieAi key came first in the provider map, which left saved CollieAi guardrails without their display name and logo. The map, the Garden preset and the card now use Collieai, and a test covers the lookup

The preset expectation is a named value now, which keeps the dashboard under its inline object lint budget

* refactor(guardrails): drop the CollieAi wrapper's function docstrings

AGENTS.md keeps comments to complex logic and tool input, and these only restated what each function returns

* fix(guardrails): declare CollieAi's phases, read COLLIEAI_API_KEY and plate its logo

The dashboard offered every mode for CollieAi, and a guardrail saved with a mode the package refuses was reported as created but never loaded. The wrapper now declares pre_call and post_call, so the form offers only those

api_key falls back to COLLIEAI_API_KEY as its description says, and the navy logo gets a plate in dark mode like DeepKeep's

The tests now also cover an entry's own name, phase and default_on, the key fallback, and the modes the dashboard offers

* fix(guardrails): reject CollieAi guardrails the package refuses and stop env-keyed rebuilds

A Garden create whose key or settings the package refuses now answers 400 and
saves nothing, instead of saving a guardrail that checks nothing. Every setting
on the entry now reaches the package, like the class-path route. DB guardrails
keyed with an os.environ/ reference are no longer rebuilt on every DB poll.
The Garden card says which calls CollieAi checks.

* fix(guardrails): load CollieAi stream_scope and import errors as setup errors, default the Garden card off

Pass stream_scope into the package constructor inside the setup-error wrap so a refused scope answers 400 on create and stops a config-file proxy at startup. Drop settings cleared to null so the package default applies. Say an installed package failed to load, with the error, instead of asking to install it, and keep any import-time exception from breaking the guardrail routes. Make api_key optional in the form since COLLIEAI_API_KEY is the fallback, and open the Garden card with Always On off like the other partner presets.

* fix(guardrails): leave CollieAi form fields empty and share one guardrail setup error

The Garden form no longer pre-fills api_base, deadline_ms or forward_conversation_id, so a
create saves only what the admin typed and the package keeps its own defaults. Setup failures
raise GuardrailSetupError from custom_guardrail, the missing-package hint covers the Docker
image, and the card copy no longer repeats the package's eligibility rules.

* test(guardrails): cover env-reference api_base in the DB poll comparison

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-12 01:05:12 +00:00
..
guardrail_hooks feat(guardrails): add the CollieAi guardrail integration (#49224) 2026-11-12 01:05:12 +00:00
__init__.py feat(guardrails): send a configured gateway_name from noma_v2 to Noma (#43678) 2026-09-29 10:20:40 -07:00
test_anthropic_sse.py fix(guardrails)!: keep the upstream error when a /v1/messages stream ends in one (#49088) 2026-10-31 02:56:20 -07:00
test_auto_router_compression.py refactor(router): move router callers onto the entry points and invert the proxy imports (#48847) 2026-10-29 17:26:33 +00:00
test_content_filter_path_traversal.py test(proxy): move management_endpoints, management_helpers and guardrails tests into tests/unit/proxy (#44003) 2026-10-01 10:52:03 -07:00
test_content_utils.py fix(guardrails): skip embeddings input in google_text_moderation (#48934) 2026-10-28 20:05:03 -07:00
test_custom_code_security.py test(proxy): move management_endpoints, management_helpers and guardrails tests into tests/unit/proxy (#44003) 2026-10-01 10:52:03 -07:00
test_deferred_guardrail_logging.py fix(responses): keep unset-effort gpt-5.4/5.5 tool calls on chat completions (#50968) 2026-11-10 18:33:27 +00:00
test_guardrail_coverage.py fix(guardrails)!: make lakera_v2 on_flagged block reject PII-only detections, add mask (#48944) 2026-10-29 11:48:37 -07:00
test_guardrail_endpoints.py feat(guardrails): write guardrail changes to the audit log (#51118) 2026-11-11 15:55:27 -08:00
test_guardrail_initializers.py refactor(types): replace Any with proven types in 157 files (#44798) 2026-10-06 15:31:54 +00:00
test_guardrail_load_balancing.py test: migrate SDK and proxy-booting legacy CircleCI tests to their tiers (#45758) 2026-10-11 00:17:21 -07:00
test_guardrail_registry.py feat(guardrails): add the CollieAi guardrail integration (#49224) 2026-11-12 01:05:12 +00:00
test_init_guardrails.py fix(config): treat blank env values as unset so the proxy neither crash-loops nor silently drops a guardrail (#46341) 2026-10-14 12:49:31 -07:00
test_llm_as_a_judge.py test(proxy): move management_endpoints, management_helpers and guardrails tests into tests/unit/proxy (#44003) 2026-10-01 10:52:03 -07:00
test_mcp_jwt_signer.py fix(mcp)!: forward the LiteLLM key when the admin configures it (#50604) 2026-11-10 20:51:34 -08:00
test_pillar_guardrails.py refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986) 2026-11-06 13:31:15 -08:00
test_prompt_security_guardrails.py fix(anthropic)!: send /v1/messages PDF documents to OpenAI-shaped providers as file parts (#47166) 2026-10-29 08:06:12 -07:00
test_qostodian_nexus_guardrail.py test(proxy): move management_endpoints, management_helpers and guardrails tests into tests/unit/proxy (#44003) 2026-10-01 10:52:03 -07:00
test_usage_endpoints.py test(proxy): move management_endpoints, management_helpers and guardrails tests into tests/unit/proxy (#44003) 2026-10-01 10:52:03 -07:00
test_usage_tracking.py feat(accounting): add opt-in SpendLogs ledger (#49856) 2026-11-04 17:49:15 -08:00