litellm/litellm/types
Ishaan Jaff f83620157e
[Feat] Policies - Allow connecting Policies to Tags, Simulating Policies, Viewing how many keys, teams it applies on (#20904)
* init schema with TAGS

* ui: add policy test

* resolvePoliciesCall

* add_policy_sources_to_metadata + headers

* types Policy

* preview Impact

* def _describe_match_reason(

* match based on TAGs

* TestTagBasedAttachments

* test fixes

* add policy_resolve_router

* add_guardrails_from_policy_engine

* TestMatchAttribution

* refactor

* fix

* fix: address Greptile review feedback on policy resolve endpoints

- Track unnamed keys/teams as separate counts instead of inflating
  affected_keys_count with duplicate "(unnamed key)" placeholders.
  Added unnamed_keys_count and unnamed_teams_count to response.
- Push alias pattern matching to DB via _build_alias_where() which
  converts exact patterns to Prisma "in" and suffix wildcards to
  "startsWith" filters.
- Gate sync_policies_from_db/sync_attachments_from_db behind
  force_sync query param (default false) to avoid 2 DB round-trips
  on every /policies/resolve request.
- Remove worktree-only conftest.py that cleared sys.modules at import
  time — no longer needed since code moved to main repo.
- Rename MAX_ESTIMATE_IMPACT_ROWS → MAX_POLICY_ESTIMATE_IMPACT_ROWS.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: eliminate duplicate DB queries and fix header delimiter ambiguity

- Fetch teams table once in estimate_attachment_impact and reuse for
  both tag-based and alias-based lookups (was querying teams twice when
  both tag_patterns and team_patterns were provided).
- Convert tag/team filter functions from async DB queries to sync
  filters that operate on pre-fetched data (_filter_keys_by_tags,
  _filter_teams_by_tags).
- Fix comma ambiguity in x-litellm-policy-sources header: use '; '
  as entry delimiter since matched_via values can contain commas.
- Use '+' as the within-value separator in matched_via reason strings
  (e.g. "tag:healthcare+team:health-team") to avoid conflict with
  header delimiters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Update litellm/proxy/policy_engine/policy_resolve_endpoints.py

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

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-02-10 17:50:37 -08:00
..
containers
google_genai
images
integrations fix(cloudzero): update CBF field mappings per LIT-1907 (#20906) 2026-02-10 17:33:16 -08:00
interactions
litellm_core_utils
llms Merge branch 'main' into litellm_v1_messages_claude_4_6 2026-02-09 17:14:36 +05:30
management_endpoints Add fallback endpoints support 2026-01-16 10:51:33 +05:30
mcp_server [Feat] MCP Oauth2 Fixes - Add support for MCP M2M Oauth2 support (#20788) 2026-02-09 17:35:11 -08:00
passthrough_endpoints
prompts
proxy [Feat] Policies - Allow connecting Policies to Tags, Simulating Policies, Viewing how many keys, teams it applies on (#20904) 2026-02-10 17:50:37 -08:00
responses
secret_managers
videos
adapter.py
agents.py
caching.py fix mypy error in caching.py 2026-01-15 08:35:08 +05:30
completion.py
embedding.py
files.py [Feat] Manus FILES API - Add File upload, get, delete, list (#18904) 2026-01-10 13:27:54 -08:00
fine_tuning.py
guardrails.py Revert "feat(guardrails): implement team-based isolation guardrails mgmnt (#1…" (#20393) 2026-02-03 20:55:46 -08:00
mcp.py
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
rerank.py
router.py feat: enforce model-level TPM/RPM limits (enforce_model_rate_limits) … (#19230) 2026-02-02 18:18:46 +05:30
scheduler.py
search.py search tools list includes config defined search tools 2026-02-03 15:57:13 -08:00
services.py
tag_management.py
utils.py [Feat] Allow calling A2A agents through LiteLLM /chat/completions API (#20358) 2026-02-03 12:52:33 -08:00
vector_store_files.py
vector_stores.py [Feat] LiteLLM Vector Stores - Add permission management for users, teams (#19972) 2026-01-28 18:55:40 -08:00