Commit graph

33526 commits

Author SHA1 Message Date
ryan-crabbe
d581c229ef
Merge pull request #20376 from ryan-crabbe/fix/model-group-info-cache-invalidation
fix: add cache invalidation for _cached_get_model_group_info
2026-02-24 16:28:05 -08:00
Ishaan Jaff
6ee50ff73e
feat(proxy): tool policies - auto-discover tools + policy enforcement guardrail (#22041)
* feat(proxy): tool policies - auto-discover tools, manage policies, guardrail enforcement

- New LiteLLM_ToolTable in schema.prisma to store discovered tools
- Auto-discovery: tools seen in LLM responses get upserted via ToolDiscoveryQueue
  (hooks into DBSpendUpdateWriter, same pipeline as spend tracking)
- Management endpoints: GET /v1/tool/list, GET /v1/tool/{name}, POST /v1/tool/policy
- ToolPolicyGuardrail: blocks tool_calls in responses based on policy setting
- UI: Tool Policies page under Guardrails section with policy selector,
  filters by policy/team/key, live tail, sortable table
- Unit tests for queue, writer, endpoints, guardrail

* feat(tool-policies): track call_count + discover tools from request body and /messages API

- Add call_count column to LiteLLM_ToolTable; incremented on every flush
- Extract tools from request body too (not just response tool_calls):
  - OpenAI /chat/completions: tools[].function.name
  - Anthropic /messages pass-through: request_body.tools[].name
- Show call_count column in UI table (sortable)
- UI: drop dual_llm option, keep only trusted/blocked

* fix: address greptile review feedback

- Remove redundant @@index([tool_name]) from schema.prisma (tool_name has @unique which already creates an index)
- Replace gen_random_uuid()::text with str(uuid.uuid4()) for portability
- Rewrite test_tool_registry_writer.py to mock execute_raw/query_raw (actual implementation) instead of Prisma model methods
- Fix test patches in test_tool_management_endpoints.py to target source modules since imports are inside function bodies
- Add "Tool Policies" page title to ToolPolicies.tsx

* fix: address greptile review round 2

- Replace NOW() with Python datetime parameter in tool_registry_writer (SQLite portability)
- Fix cache key collision in tool_policy_guardrail: use null-byte separator instead of colon
- Remove type==function filter from request-side tool extraction to match response-side behavior
- Clear seen_tool_names on flush so call_count increments per batch cycle not per pod lifetime

* fix: address greptile review round 3

- Fix test_seen_names_persist_across_flushes to match actual per-flush-cycle behavior
- Update module docstring in tool_discovery_queue.py to accurately describe flush behavior
- Add created_at/updated_at to raw SQL INSERT in batch_upsert_tools and update_tool_policy

* fix: cache tool policies per tool name not per combination

Previously the cache key was built from the full set of tool names in a
request, so each unique combination of tools got its own cold cache entry
and triggered a separate DB query. With N distinct tools across requests
this was effectively a DB hit on every request.

Now each tool name is cached individually. Cache hits are checked per
tool, only missing tools are fetched from DB in a single batch query,
and each result is cached separately. Once a tool's policy is warm,
any subsequent request using that tool benefits from the cache regardless
of what other tools are in the request.

* Update ui/litellm-dashboard/src/components/ToolPolicies.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-24 16:27:06 -08:00
Ryan Crabbe
ba0f794591 Merge origin/main; keep both model_group_info and access_groups cache invalidation 2026-02-24 16:08:29 -08:00
yuneng-jiang
857816fe6d
Merge pull request #22043 from BerriAI/litellm_router_settings_vitest
[Test] UI - Unit Testing Coverage: Router Settings
2026-02-24 16:02:30 -08:00
yuneng-jiang
26e5482abb address greptile review feedback (greploop iteration 2)
- Wait for strategy select (API data loaded) before clicking Save
- Assert specific payload content in setCallbacksCall
- Move NotificationsManager import to top of file
2026-02-24 15:52:15 -08:00
yuneng-jiang
784af16cb4 address greptile review feedback (greploop iteration 1)
- Replace document.querySelector/querySelectorAll with screen.getByRole
- Replace raw dispatchEvent with userEvent.selectOptions
2026-02-24 15:48:31 -08:00
yuneng-jiang
b3bb744aa4 [Test] Add unit tests for router_settings components
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 15:26:06 -08:00
ryan-crabbe
8020276711
Merge pull request #21430 from BerriAI/litellm_perf_headers_caching
perf: use cached _safe_get_request_headers instead
2026-02-24 15:22:12 -08:00
Ryan Crabbe
9971b67587 fix: convert remaining dict(request.headers) to _safe_get_request_headers
Missed conversions in user_api_key_auth.py and litellm_pre_call_utils.py.
Both call sites are read-only so no .copy() needed.
2026-02-24 15:21:43 -08:00
Ryan Crabbe
53c10b0b64 Merge origin/main and address Greptile review feedback
- Resolve merge conflict in pass_through_endpoints.py
- Add .copy() to proxy_server_request headers to prevent cache corruption
- Add test for request.state unavailable fallback path
2026-02-24 15:13:19 -08:00
ryan-crabbe
e9a45bf75b
Merge pull request #20032 from ryan-crabbe/fix/mcp-server-unreachable-error-handling
fix: dead code cleanup in MCP server error handler
2026-02-24 15:03:01 -08:00
ryan-crabbe
56a507073b
Merge pull request #21690 from BerriAI/litellm_perf_o_series_short_circuit
perf: optimize is_model_o_series_model with startswith
2026-02-24 14:59:53 -08:00
ryan-crabbe
253792a1d1
Merge pull request #21611 from BerriAI/litellm_perf_skip_throwaway_usage
perf: skip throwaway Usage() construction in ModelResponse.__init__
2026-02-24 14:53:17 -08:00
Ryan Crabbe
6a0dd0a45f Merge remote-tracking branch 'origin/main' into litellm_perf_skip_throwaway_usage
# Conflicts:
#	tests/llm_translation/test_llm_response_utils/test_convert_dict_to_chat_completion.py
2026-02-24 14:51:57 -08:00
yuneng-jiang
80ebe722d9
Merge pull request #22029 from BerriAI/litellm_spend_tracking_logging
[Infra] Add Spend Tracking Lifecycle Logging
2026-02-24 12:52:32 -08:00
yuneng-jiang
2cabbccf6f address greptile review feedback (greploop iteration 3)
- Add missing traceback to team member spend enqueue error log
2026-02-24 12:49:48 -08:00
yuneng-jiang
8b56e1d969 trigger review 2026-02-24 12:37:43 -08:00
Ishaan Jaff
33719e6b38
docs: update v1.81.12-stable release notes to point to v1.81.12-stable.1 (#22036) 2026-02-24 12:30:18 -08:00
yuneng-jiang
70ef4d0d69 address greptile review feedback (greploop iteration 2)
- Remove re-raise in _store_transactions_in_redis so one Redis
  push failure doesn't drop remaining transaction types
- Downgrade per-push success log from info to debug to reduce noise
- Fix misleading error message in update_database — entity spend
  updates run as independent tasks and are not affected by this catch
2026-02-24 12:10:19 -08:00
Sameer Kankute
5219b1d0c3
Merge pull request #22035 from BerriAI/litellm_openai_codex_day_0_codex_5.3
[Feat] OpenAI codex 5.3 day 0 support
2026-02-25 01:29:27 +05:30
yuneng-jiang
235d60eb88 address greptile review feedback (greploop iteration 1)
- Add traceback to cache update warning logs (user, end_user, team, tag)
- Remove duplicate info log in non-redis commit path
2026-02-24 11:58:59 -08:00
Ishaan Jaff
c343bfffda
fix(router): emit x-litellm-overhead-duration-ms header for streaming requests (#22027)
* fix(router): preserve _hidden_params in FallbackStreamWrapper so x-litellm-overhead-duration-ms is emitted for streaming requests

* test(router): add regression test for FallbackStreamWrapper _hidden_params preservation
2026-02-24 11:56:16 -08:00
Ishaan Jaff
e44b9b6b35
feat(prometheus): add opt-in stream label to litellm_proxy_total_requests_metric (#22023)
Set prometheus_emit_stream_label: true in litellm_settings to emit a
stream label (True/False/None) on litellm_proxy_total_requests_metric.

Opt-in to avoid breaking cardinality on existing deployments.
2026-02-24 11:51:42 -08:00
Sameer Kankute
5d291c739f Fix phase docs link 2026-02-25 01:21:38 +05:30
Sameer Kankute
74abf0c8e6 Fix phase docs link 2026-02-25 01:19:10 +05:30
Sameer Kankute
aded14a55a Fix release version for gpt-5.3-codex 2026-02-25 01:04:12 +05:30
yuneng-jiang
c43a8dc842 feat(proxy): add warning/error level logging throughout spend tracking lifecycle
Elevate silent debug-level and bare except:pass error paths to
warning/error so spend tracking failures are visible in production logs.

All new log messages are prefixed with "Spend tracking -" for easy
filtering. Changes cover the full request-to-DB lifecycle:
enqueue, in-memory flush, Redis buffer push/pop, DB commit,
cache updates, spend log writes, and pod lock management.

Also fixes a copy-paste bug in _update_team_cache that logged
"end user" instead of "team".
2026-02-24 10:17:35 -08:00
yuneng-jiang
4321bc9285
Merge pull request #21985 from BerriAI/litellm_ui_testing_coverage_00
[Fix] UI - Virtual Keys: restrict Edit Settings to key owners
2026-02-24 10:16:40 -08:00
Sameer Kankute
1c48d8fda7 Add gpt-5.3-codex in model cost map 2026-02-24 23:37:09 +05:30
Ishaan Jaff
5e9f24f74c
fix(bedrock): pass timeout param to bedrock rerank http client (#22021)
* fix(bedrock): pass timeout to bedrock rerank http client

* refactor: extract large functions to fix PLR0915 ruff lint errors
2026-02-24 09:32:11 -08:00
Sean Marsh Glover
4652c73259
feat(proxy): limit concurrent health checks with health_check_concurrency (#20584)
* staged first pass

* black

* Update litellm/proxy/health_check.py

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

* simpler

* restore cached logo

* fix tests for perform_health_check max_concurrency arg

* implement pr suggestion

* and the helm chart

* add configureable resources and probes to the deployment in the helm chart

* more helm chart unittests

* move some background healthcheck loggin to debug

---------

Co-authored-by: Sean Glover <sglover@athenahealth.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-02-24 08:16:59 -08:00
Harshit Jain
1fa0aad3f2
Merge pull request #22008 from BerriAI/litellm_fix_CVE
security: fix critical/high CVEs in OS-level libs and NPM transitive
2026-02-24 21:44:19 +05:30
Harshit28j
132e2ed671 Merge branch 'main' of https://github.com/BerriAI/litellm into litellm_fix_CVE
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2026-02-24 21:09:16 +05:30
Harshit28j
3e6c10a071 security: fix critical/high CVEs in OS-level libs and NPM transitive 2026-02-24 19:40:09 +05:30
Sameer Kankute
a37cd0fe7c
Merge pull request #22005 from BerriAI/litellm_mcp_server_ui_fix
Fix: Transport Type for OpenAPI Spec on UI
2026-02-24 19:38:34 +05:30
Sameer Kankute
c17caf4cc7
Merge pull request #21992 from BerriAI/litellm_fix_oauth_mcp
fix: Missing OAuth session state
2026-02-24 19:37:09 +05:30
Sameer Kankute
6531d01959
Merge pull request #21982 from BerriAI/litellm_fix_pat_token_mcp
Fix: skip health check for MCP integration with passthrough token auth
2026-02-24 19:36:08 +05:30
Sameer Kankute
7a8499e89f
Merge pull request #21940 from BerriAI/litellm_oss_staging_02_23_2026
litellm oss staging 02 23 2026
2026-02-24 19:32:56 +05:30
Sameer Kankute
b38059b014
Merge branch 'main' into litellm_oss_staging_02_23_2026 2026-02-24 19:32:48 +05:30
Sameer Kankute
816f9052ff Fix: Transport Type for OpenAPI Spec on UI 2026-02-24 19:27:12 +05:30
Julio Quinteros Pro
d0330aa4e3
Merge pull request #22001 from jquinter/revert/pr-21957
Revert PR #21957: atomic RPM rate limiting
2026-02-24 09:53:25 -03:00
Julio Quinteros Pro
737a04b3ea Revert "Merge pull request #21957 from jquinter/fix/flaky-rpm-limit-test"
This reverts commit 77453ada2a, reversing
changes made to 7622f26918.
2026-02-24 09:52:50 -03:00
Julio Quinteros Pro
77453ada2a
Merge pull request #21957 from jquinter/fix/flaky-rpm-limit-test
fix: atomic RPM rate limiting in model rate limit check
2026-02-24 09:51:26 -03:00
Sameer Kankute
ac720defc3 Add documentation related to phase 2026-02-24 17:50:38 +05:30
Sameer Kankute
ef67b6b533 Add support for phase param 2026-02-24 17:48:55 +05:30
Shivam Rawat
7622f26918
Merge pull request #21997 from BerriAI/doc_fix_remove_harcoded_api_key
[Doc] replaced azure openai key with mock key
2026-02-24 03:32:37 -08:00
shivam
c86b174642 replaced with mock key 2026-02-24 03:28:28 -08:00
Sameer Kankute
12f37cea43 fix: Missing OAuth session state. Please retry 2026-02-24 14:22:38 +05:30
yuneng-jiang
c119adb6dc [Fix] UI - Virtual Keys: restrict Edit Settings button to key owners
Non-owner Internal Users could see and interact with the "Edit Settings"
button in the key Settings tab for keys they don't own. The button was
gated by `rolesWithWriteAccess.includes(userRole)` (role-only check)
instead of `canModifyKey` (ownership-aware), unlike the Regenerate and
Delete buttons which already used the correct check.

Replace the condition with `canModifyKey` so the Edit Settings button
follows the same proxy-admin / team-admin / key-owner logic as the
other action buttons. Add tests covering all permission paths.
2026-02-23 23:06:27 -08:00
Sameer Kankute
46ed7fc706 Add Additonal header field on UI for testing passthrough 2026-02-24 12:06:07 +05:30