Commit graph

34557 commits

Author SHA1 Message Date
Jay Prajapati
ab2d6e4eac fix(chatgpt): drop unsupported responses params for Codex
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-15 00:18:02 +05:30
Ishaan Jaffer
ad910de1e3 test_o1_parallel_tool_calls 2026-02-14 10:47:38 -08:00
Julio Quinteros Pro
90d61432cf Fix LiteLLM_JWTAuth annotations access bug
The __init__ method was trying to access self.__annotations__ before
super().__init__() was called, resulting in an empty annotations dict.

Changed to use the class annotations directly: LiteLLM_JWTAuth.__annotations__
instead of self.__annotations__.

This fixes the ValueError:
"Invalid arguments provided: user_email_jwt_field, user_id_upsert,
user_allowed_email_domain. Allowed arguments are: ."

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 15:44:02 -03:00
Julio Quinteros Pro
3f4ba9f03f Fix JWT auth email domain validation error message
Fixes issue where users with disallowed email domains receive a
generic "user doesn't exist" error instead of a clear message
about the email domain not being allowed.

Changes:
- Add explicit check for valid_user_email before get_user_object
- Raise ProxyException with clear error message when email domain
  is not in the allowed list
- Prevents confusing error message for email domain restrictions

This fixes the test_allow_access_by_email test failure.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 15:39:39 -03:00
jquinter
d60a832aae
Merge pull request #21207 from BerriAI/fix/content-filter-too-many-statements
Fix: Refactor content filter to reduce statement count (PLR0915)
2026-02-14 15:23:59 -03:00
jquinter
ae0ffdf5a6
Update litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/content_filter.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-02-14 15:20:08 -03:00
Julio Quinteros Pro
9084fdeeb4 Refactor _filter_single_text to reduce statement count
Fixes PLR0915 linting error (too many statements: 64 > 50) by extracting
repeated logic into four helper methods:
- _handle_conditional_match
- _handle_category_keyword_match
- _handle_pattern_match
- _handle_blocked_word_match

This improves code organization and maintainability while preserving
all existing functionality.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 15:16:39 -03:00
Ishaan Jaffer
3b89b14687 fix schema 2026-02-14 09:56:45 -08:00
Ishaan Jaffer
d4bb040755 bump pyproject 2026-02-14 09:56:45 -08:00
Ishaan Jaffer
ab31725b4a bump 2026-02-14 09:56:45 -08:00
Ishaan Jaffer
c445011025 fix extras 2026-02-14 09:56:45 -08:00
Ishaan Jaffer
cba886dbb1 add new migrations 2026-02-14 09:56:45 -08:00
Ishaan Jaffer
54bd5632d1 new schema 2026-02-14 09:56:45 -08:00
Ishaan Jaffer
8d9ae1d2b4 codex test fixes 2026-02-14 09:56:45 -08:00
jquinter
a68d61ad76
Merge pull request #21203 from jquinter/fix-too-many-statements-pre-call-utils
refactor: extract helper functions to reduce statement count in add_guardrails_from_policy_engine
2026-02-14 14:55:16 -03:00
Julio Quinteros Pro
3b7cc1d138 docs: improve comment clarity per Greptile feedback
Restructure comments to make the intent clearer:
- First function: matches/tracks policies (may find nothing)
- Second function: always runs independent resolution (may find inherited guardrails)

This makes it clear why both functions must always be called.
2026-02-14 14:43:20 -03:00
Julio Quinteros Pro
0f0b7a3f50 fix: preserve original behavior - always call PolicyResolver
Remove early return when applied_policy_names is empty to preserve
original behavior where PolicyResolver.resolve_guardrails_for_context()
is always called. The resolver does its own independent matching and
inheritance resolution, which can apply guardrails from parent policies
even when child policies fail their conditions.

This ensures no guardrails are silently dropped due to the refactoring.

Addresses Greptile review feedback on behavioral change.
2026-02-14 14:43:20 -03:00
Julio Quinteros Pro
9e0af32d46 fix: add PolicyMatchContext to TYPE_CHECKING imports
Add PolicyMatchContext to TYPE_CHECKING block to fix F821 undefined
name errors in helper function type hints.

Fixes:
- proxy/litellm_pre_call_utils.py:1524:15: F821
- proxy/litellm_pre_call_utils.py:1596:15: F821
2026-02-14 14:43:20 -03:00
Julio Quinteros Pro
ade2ae1977 refactor: extract helper functions to reduce statement count
Refactor add_guardrails_from_policy_engine by extracting two helper
functions to reduce the statement count from 52 to under 50:

- _match_and_track_policies: Handles policy matching and tracking
- _apply_resolved_guardrails_to_metadata: Handles guardrail resolution

Fixes Ruff PLR0915 linting error (too many statements).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 14:43:20 -03:00
Krish Dholakia
e41ecc7a71
Guardrails - add nsfw policy template, toxic keywords in multiple languages, child safety content filter, json content viewer (#21205)
* fix(content_filter.py): fix filter on toxic keywords

* feat: improve toxic/abusive language detection

* fix: additional improvements to nsfw filters

* feat: more improvements to nsfw filter

* feat(content_filter.json): add new australia specific nsfw content filter

ensure complete coverage for australia nsfw

* fix: cleanup policy templates

* fix(index.tsx): alert notice

* fix(index.tsx): add disclaimer notice

* feat(harmful_child_safety.yaml): new child safety content filter

ensure we catch inappropriate, child-specific content

* feat(policy_templates.json): add child safety and self harm filters

* fix(content_filter.py): improve racial bias filter to use a similar identifier + block word pattern and cover a wider range of ethnicities

* feat(policy_templates.json): add racial bias to nsfw policy template

* feat: add json content viewer
2026-02-14 09:41:55 -08:00
jquinter
2e8056432f
Merge pull request #21202 from jquinter/fix-unused-variable-pipeline-executor
fix: remove unused variable original_guardrails in pipeline_executor
2026-02-14 14:36:01 -03:00
Ishaan Jaffer
1e257db0a5 fix MYPY linting + JSON refs 2026-02-14 09:34:56 -08:00
Julio Quinteros Pro
6caedfd2a5 fix: remove unused variable original_guardrails in pipeline_executor
Remove unused local variable 'original_guardrails' that was assigned
but never used in the _execute_guardrail_step method.

Fixes Ruff F841 linting error.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 14:32:32 -03:00
yuneng-jiang
951c230ff0
Merge pull request #21201 from BerriAI/ui_build_feb14
[Infra] UI - Building for Release
2026-02-14 09:30:57 -08:00
yuneng-jiang
0f3494659a chore: update Next.js build artifacts (2026-02-14 17:29 UTC, node v22.16.0) 2026-02-14 09:29:42 -08:00
yuneng-jiang
c311033f48 cache adjustment for deleted teams and keys 2026-02-14 09:28:02 -08:00
Ishaan Jaff
f8334dfeda
ci/cd fixes - streaming role & bedrock model cost (#21200)
* fix(model_cost): add missing supports_system_messages and supports_tool_choice to bedrock/moonshotai.kimi-k2.5

* fix(streaming): ensure role=assistant is set on first streaming chunk via strip_role_from_delta

* fix(vertex_ai): ensure role=assistant on first streaming chunk for Llama models

Add VertexAILlama3StreamingHandler that injects role='assistant' into the
first streaming chunk delta when the Vertex AI Llama API omits it.
2026-02-14 09:18:29 -08:00
yuneng-jiang
b06d7166e5 addressing comments 2026-02-14 09:17:19 -08:00
Ishaan Jaffer
c32544a284 fix MYPY linting 2026-02-14 09:11:09 -08:00
shin-bot-litellm
84934a7258
fix(anthropic): filter unsupported JSON schema constraints for structured outputs (#20813)
* fix(anthropic): filter unsupported JSON schema constraints for structured outputs

Fixes 400 error when using Anthropic models with structured outputs that have
min/max constraints.

The Anthropic API doesn't support these JSON schema constraints:
- minimum/maximum (numeric)
- exclusiveMinimum/exclusiveMaximum (numeric)
- minLength/maxLength (string)
- minItems/maxItems (array)

This mirrors the transformation done by the official Anthropic Python SDK.
See: https://platform.claude.com/docs/en/build-with-claude/structured-outputs#how-sdk-transformation-works

Adds tests for the schema filtering function.

* fix: update descriptions with removed constraint info in filter_anthropic_output_schema

Address review feedback: the function now appends removed constraint
information to the description field (matching Anthropic SDK behavior),
rather than silently dropping constraints.

---------

Co-authored-by: OpenClaw <openclaw@users.noreply.github.com>
2026-02-14 09:07:40 -08:00
yuneng-jiang
890927b69c Merge remote-tracking branch 'origin' into litellm_access_groups_inte 2026-02-14 09:06:49 -08:00
Ephrim Stanley
cd0fed826b fix: batch retrieve returns unified input_file_id 2026-02-14 11:24:08 -05:00
Ephrim Stanley
e59c8d22af fix: afile_retrieve returns unified ID for batch output files 2026-02-14 10:07:12 -05:00
yuneng-jiang
91226fb0bb adjusting UI for model name 2026-02-13 22:07:24 -08:00
yuneng-jiang
5a78486a15 tests 2026-02-13 22:01:28 -08:00
Ryan Crabbe
75ca44434a fix: close streaming connections to prevent connection pool exhaustion
- Add aclose() to CustomStreamWrapper to delegate to underlying stream
- Add finally block in async_data_generator to release HTTP connections
- Thread shared_session through async_streaming to reuse connection pool
- Set finite default timeout (600s) in _get_openai_client
2026-02-13 21:53:28 -08:00
yuneng-jiang
5525dd4f20 access groups pt 2 2026-02-13 21:50:16 -08:00
Harshit Jain
3743513bb6
Update tests/test_litellm/proxy/management_endpoints/test_ui_sso.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-02-14 11:01:25 +05:30
Ephrim Stanley
5433ae7e8c Fix: bypass managed files access check in batch polling by calling afile_content directly 2026-02-14 00:30:35 -05:00
Ephrim Stanley
358180eb2d Fix: pass deployment credentials to afile_retrieve in managed_files post-call hook 2026-02-14 00:16:34 -05:00
Ephrim Stanley
1b6a7ed6c1 Fix errors when callbacks are invoked for file operations 2026-02-13 23:30:22 -05:00
Ishaan Jaff
96802e177b
Add pipeline flow builder UI for guardrail policies (#21188)
* Add pipeline type definitions for guardrail pipelines

PipelineStep, GuardrailPipeline, PipelineStepResult, PipelineExecutionResult
with validation for actions (allow/block/next/modify_response) and modes.

* Export pipeline types from policy_engine types package

* Add optional pipeline field to Policy model

* Add pipeline executor for sequential guardrail execution

* Parse pipeline config in policy registry

* Add pipeline validation in policy validator

* Add pipeline resolution and managed guardrail tracking

* Resolve pipelines and exclude managed guardrails in pre-call

* Integrate pipeline execution into proxy pre_call_hook

* Add test guardrails for pipeline E2E testing

* Add example pipeline config YAML

* Add unit tests for pipeline type definitions

* Add unit tests for pipeline executor

* Add pipeline column to LiteLLM_PolicyTable schema

* Add pipeline field to policy CRUD request/response types

* Add pipeline support to policy DB CRUD operations

* Add PipelineStep and GuardrailPipeline TypeScript types

* Add Zapier-style pipeline flow builder UI component

* Integrate pipeline flow builder with mode toggle in policy form

* Add pipeline display section to policy info view

* Add unit tests for pipeline in policy CRUD types

* Refactor policy form to show mode picker first with icon cards

* Add full-screen FlowBuilderPage component for pipeline editing

* Wire up full-screen flow builder in PoliciesPanel with edit routing

* Restyle flow builder to match dev-tool UI aesthetic

* Restyle flow builder cards to match reference design

* Update step card to expanded layout with stacked ON PASS / ON FAIL sections

* Add end card to flow builder showing return to normal control flow

* Add PipelineTestRequest type for test-pipeline endpoint

* Export PipelineTestRequest from policy_engine types

* Add POST /policies/test-pipeline endpoint

* Add testPipelineCall networking function

* Add PipelineStepResult and PipelineTestResult types

* Add test pipeline panel to flow builder with run button and results display

* Fix pipeline executor: inject guardrail name into metadata so should_run_guardrail allows execution

* Update litellm/proxy/policy_engine/pipeline_executor.py

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

* Update litellm/proxy/utils.py

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

* Update litellm/proxy/policy_engine/policy_endpoints.py

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

* Update litellm/proxy/policy_engine/pipeline_executor.py

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-13 20:06:03 -08:00
yuneng-jiang
9d73a98e4f Merge remote-tracking branch 'origin' into litellm_access_groups_inte 2026-02-13 20:01:51 -08:00
yuneng-jiang
cd148dcb82 added access groups permission checks 2026-02-13 20:01:25 -08:00
Ishaan Jaff
08b61f49a4
[Guardrails] Add guardrail pipeline support for conditional sequential execution (#21177)
* Add pipeline type definitions for guardrail pipelines

PipelineStep, GuardrailPipeline, PipelineStepResult, PipelineExecutionResult
with validation for actions (allow/block/next/modify_response) and modes.

* Export pipeline types from policy_engine types package

* Add optional pipeline field to Policy model

* Add pipeline executor for sequential guardrail execution

* Parse pipeline config in policy registry

* Add pipeline validation in policy validator

* Add pipeline resolution and managed guardrail tracking

* Resolve pipelines and exclude managed guardrails in pre-call

* Integrate pipeline execution into proxy pre_call_hook

* Add test guardrails for pipeline E2E testing

* Add example pipeline config YAML

* Add unit tests for pipeline type definitions

* Add unit tests for pipeline executor

* Update litellm/proxy/policy_engine/pipeline_executor.py

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

* Update litellm/proxy/utils.py

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-13 19:49:12 -08:00
Ephrim Stanley
bac6d1127c Fix errors when callbacks are invoked for file delete operations: 2026-02-13 22:18:19 -05:00
Harshit Jain
d90f3d558e
Update litellm/proxy/utils.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-02-14 08:46:07 +05:30
shin-bot-litellm
f915b15e92
fix(mypy): Fix type errors across multiple files (#21180)
- vertex_ai/gemini/transformation.py: Fix TypedDict assignment via dict alias
- mcp_server/server.py: Convert ASGI scope to dict for type compatibility
- pass_through_endpoints.py: Add explicit Optional[dict] type annotation
- vector_store_endpoints/endpoints.py: Add Any type for dynamic proxy hook
- responses transformation.py: Use dict(Reasoning()) and setattr for compatibility
- zscaler_ai_guard.py: Add assert for api_base nullability

Co-authored-by: OpenClaw <openclaw@users.noreply.github.com>
2026-02-13 18:20:31 -08:00
shin-bot-litellm
933955bfa0
fix(ci): Fix E2E login button selector - use exact match (#21176)
* fix(ci): Fix ruff lint error - unused import

Remove unused 'cast' import in vertex_ai_ingestion.py (ruff F401)

* fix(ci): Fix E2E login button selector - use exact match

Login button selector now matches both 'Login' and 'Login with SSO',
causing strict mode violation. Use { exact: true } to match only 'Login'.

---------

Co-authored-by: OpenClaw <openclaw@users.noreply.github.com>
2026-02-13 18:20:10 -08:00
shin-bot-litellm
e957030997
fix(ci): Fix mypy type errors across 6 files (#21179)
- vertex_ai/gemini: fix TypedDict assignment via explicit dict cast
- mcp_server: convert MutableMapping scope to dict for type safety
- pass_through_endpoints: simplify custom_body logic to fix type narrowing
- vector_store_endpoints: add Any annotation for dynamic hook return
- responses transformation: use dict() for Reasoning and setattr for dynamic field
- zscaler_ai_guard: add assert for api_base None check

Co-authored-by: shin-bot-litellm <shin-bot-litellm@users.noreply.github.com>
2026-02-13 18:14:43 -08:00