From ecdb56a1cc7e8b7975b64a95e3a13e2926dc3d79 Mon Sep 17 00:00:00 2001 From: mateo Date: Tue, 27 Oct 2026 20:44:02 +0000 Subject: [PATCH] fix(anthropic): keep an untyped enum node untyped so shaping stays idempotent Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/llms/anthropic/output_schema.py | 1 + tests/unit/llms/anthropic/test_anthropic_output_schema.py | 1 + 2 files changed, 2 insertions(+) diff --git a/litellm/llms/anthropic/output_schema.py b/litellm/llms/anthropic/output_schema.py index 803e2e4a14d..d977c691d1a 100644 --- a/litellm/llms/anthropic/output_schema.py +++ b/litellm/llms/anthropic/output_schema.py @@ -152,6 +152,7 @@ def _object_fields(declared_type: object, schema: Mapping[str, object]) -> Mappi return {"additionalProperties": False} if ( declared_type is None + and "enum" not in schema and _as_schema(schema.get("properties")) is not None and not _COMPOSITION_KEYS & schema.keys() ): diff --git a/tests/unit/llms/anthropic/test_anthropic_output_schema.py b/tests/unit/llms/anthropic/test_anthropic_output_schema.py index 273f3c4cfd8..4133e165e9e 100644 --- a/tests/unit/llms/anthropic/test_anthropic_output_schema.py +++ b/tests/unit/llms/anthropic/test_anthropic_output_schema.py @@ -103,3 +103,4 @@ def test_nullable_object_enum_keeps_its_type_dropped_instead_of_forcing_object() ) assert shaped == {"properties": {"a": {"type": "string"}}, "enum": [None]} + assert shape_claude_output_schema(shaped) == shaped