Skip to content

Commit b513b12

Browse files
Use deprecation utility for LLM.safety_settings removal tracking
Replace the REMOVE_AT comment with a proper warn_deprecated() call in a field validator. The deprecation check CI workflow will now automatically fail when version 1.20.0 is reached, ensuring the field is removed on schedule. Co-authored-by: openhands <openhands@all-hands.dev>
1 parent 2458776 commit b513b12

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

  • openhands-sdk/openhands/sdk/llm

openhands-sdk/openhands/sdk/llm/llm.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
from openhands.sdk.llm.fallback_strategy import FallbackStrategy
2525
from openhands.sdk.llm.utils.model_info import get_litellm_model_info
26+
from openhands.sdk.utils.deprecation import warn_deprecated
2627
from openhands.sdk.utils.pydantic_secrets import serialize_secret, validate_secret
2728

2829

@@ -336,7 +337,6 @@ class LLM(BaseModel, RetryMixin, NonNativeToolCallingMixin):
336337
seed: int | None = Field(
337338
default=None, description="The seed to use for random number generation."
338339
)
339-
# REMOVE_AT: 1.20.0 - Remove this field (REST API deprecation runway)
340340
safety_settings: list[dict[str, str]] | None = Field(
341341
default=None,
342342
deprecated=("Deprecated since v1.15.0 and scheduled for removal in v1.20.0."),
@@ -405,6 +405,20 @@ class LLM(BaseModel, RetryMixin, NonNativeToolCallingMixin):
405405
# =========================================================================
406406
# Validators
407407
# =========================================================================
408+
@field_validator("safety_settings", mode="before")
409+
@classmethod
410+
def _warn_safety_settings_deprecated(
411+
cls, v: list[dict[str, str]] | None
412+
) -> list[dict[str, str]] | None:
413+
if v is not None:
414+
warn_deprecated(
415+
"LLM.safety_settings",
416+
deprecated_in="1.15.0",
417+
removed_in="1.20.0",
418+
details="Safety settings are no longer applied.",
419+
)
420+
return v
421+
408422
@field_validator("api_key", "aws_access_key_id", "aws_secret_access_key")
409423
@classmethod
410424
def _validate_secrets(cls, v: str | SecretStr | None, info) -> SecretStr | None:

0 commit comments

Comments
 (0)