litellm/litellm
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
..
a2a_protocol fix(mypy): resolve type checking errors in 5 files (#20627) 2026-02-06 18:34:55 -08:00
anthropic_interface
assistants
batch_completion
batches litellm_fix(azure): Fix acancel_batch not using Azure SDK client initialization (#20168) 2026-01-31 11:45:25 -08:00
caching fix(mypy): resolve type checking errors in 5 files (#20627) 2026-02-06 18:34:55 -08:00
completion_extras fix(proxy): forward extra_headers in chat 2026-02-04 08:56:50 +05:30
containers
endpoints/speech/speech_to_completion_bridge
experimental_mcp_client fix(mcp): resolve OAuth2 'Capabilities: none' bug for upstream MCP servers (#20602) 2026-02-06 15:00:35 -08:00
files fix(mypy): fix type errors in files, opentelemetry, gemini transformation, and key management (#20161) 2026-01-31 10:09:07 -08:00
fine_tuning
google_genai
images
integrations Add semgrep & Fix OOMs (#20912) 2026-02-10 17:50:14 -08:00
interactions
litellm_core_utils [Stability] Investigate + fix issue where model cost map became poorly formatted (#20895) 2026-02-10 15:17:01 -08:00
llms [Release - 02/10/2026] v1.81.10-nightly 2026-02-10 16:26:30 -08:00
ocr
passthrough
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
proxy_auth Fix mypy issues 2026-02-05 09:44:05 +05:30
rag
realtime_api [Feat] Add xAI /realtime API Support - works with LiveKitSDK (#20381) 2026-02-03 19:58:28 -08:00
rerank_api
responses Merge pull request #20783 from BerriAI/litellm_oss_staging_02_09_2026 2026-02-10 18:02:14 +05:30
router_strategy
router_utils feat: add support for anthropic_messages call type in prompt caching (#19233) 2026-02-07 22:51:06 -08:00
search
secret_managers
skills
types [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
vector_store_files
vector_stores
videos
__init__.py Fix mypy issues 2026-02-10 17:58:15 +05:30
_lazy_imports_registry.py [Release - 02/10/2026] v1.81.10-nightly 2026-02-10 16:26:30 -08:00
_lazy_imports.py
_logging.py fix:Parse embedded JSON in the message field of logs (#20366) 2026-02-10 16:13:33 +05:30
_redis.py
_service_logger.py
_uuid.py
_version.py
anthropic_beta_headers_config.json Fix : litellm/tests/test_litellm/llms/bedrock/chat/invoke_transformations/test_bedrock_chat_invoke_transformations_anthropic_claude3_transformation.py 2026-02-09 17:18:05 +05:30
anthropic_beta_headers_manager.py feat: Add Unsupported Anthropic beta headers for each provider json 2026-02-06 17:44:09 +05:30
budget_manager.py
constants.py [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
cost_calculator.py perf: guard debug log f-strings and remove redundant dict copy in hot path (#19961) 2026-02-07 10:40:29 -08:00
cost.json
exceptions.py
main.py Merge pull request #20386 from naaa760/fix/extra-head-chat-comp-brid 2026-02-04 09:11:43 +05:30
model_prices_and_context_window_backup.json feat(model-db): add azure_ai/kimi-k2.5 pricing entry (#20896) 2026-02-10 14:46:40 -08:00
mypy.ini
py.typed
router.py fix(router): propagate model-level tags from config to SpendLogs (#20769) 2026-02-10 15:52:52 -08:00
scheduler.py
timeout.py
utils.py Add perplexity response api routing 2026-02-10 17:01:08 +05:30