Merge pull request #23899 from Chesars/fix/map-anthropic-refusal-finish-reason

fix(core): map Anthropic 'refusal' finish reason to 'content_filter'
This commit is contained in:
Cesar Garcia 2026-03-17 18:49:03 -03:00 committed by GitHub
commit c1db67ab67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View file

@ -64,6 +64,7 @@ _FINISH_REASON_MAP: dict[str, OpenAIChatCompletionFinishReason] = {
"end_turn": "stop",
"max_tokens": "length",
"tool_use": "tool_calls",
"refusal": "content_filter",
"compaction": "length",
# Cohere
"COMPLETE": "stop",

View file

@ -73,6 +73,9 @@ class TestMapFinishReasonAnthropic:
def test_anthropic_finish_reasons(self, provider_reason: str, expected: str) -> None:
assert map_finish_reason(provider_reason) == expected
def test_refusal(self):
assert map_finish_reason("refusal") == "content_filter"
class TestMapFinishReasonGemini:
@pytest.mark.parametrize(