fix(anthropic-responses): preserve nested strict setting

This commit is contained in:
eugene-yao-zocdoc 2026-08-24 19:26:22 -04:00
parent 1e2645203b
commit 690656e2b3
2 changed files with 9 additions and 1 deletions

View file

@ -520,7 +520,7 @@ class LiteLLMAnthropicToResponsesAPIAdapter:
"type": "json_schema",
"name": "structured_output",
"schema": schema,
"strict": bool(output_format.get("strict")),
"strict": output_format.get("strict", False),
}
}

View file

@ -142,6 +142,14 @@ class TestOutputConfigStructuredOutput:
assert fmt["strict"] is False
assert fmt["name"] == "structured_output"
def test_output_config_format_explicit_strict_true_is_preserved(self):
"""Nested output_config.format with explicit strict=True is preserved."""
req = _make_request(
output_config={"format": {"type": "json_schema", "schema": self._SCHEMA, "strict": True}}
)
kwargs = _ADAPTER.translate_request(req)
assert kwargs["text"]["format"]["strict"] is True
def test_output_config_without_format_does_not_set_text(self):
"""output_config with only non-format keys doesn't produce text.format."""
req = _make_request(output_config={"effort": "high"})