mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-05 08:07:05 +00:00
Fix: map Anthropic compaction finish_reason to stop instead of length
When Anthropic's context compaction triggers with pause_after_compaction=True, the API returns finish_reason "compaction". This was incorrectly mapped to "length", which signals output truncation due to max_tokens and causes downstream consumers to retry or attempt continuation. Compaction means the context was summarized and the model paused naturally, so "stop" is the semantically correct mapping. Fixes #25165 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d251238bd7
commit
3cc452a54c
2 changed files with 2 additions and 2 deletions
|
|
@ -65,7 +65,7 @@ _FINISH_REASON_MAP: dict[str, OpenAIChatCompletionFinishReason] = {
|
|||
"max_tokens": "length",
|
||||
"tool_use": "tool_calls",
|
||||
"refusal": "content_filter",
|
||||
"compaction": "length",
|
||||
"compaction": "stop",
|
||||
# Cohere
|
||||
"COMPLETE": "stop",
|
||||
"ERROR_TOXIC": "content_filter",
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class TestMapFinishReasonAnthropic:
|
|||
("end_turn", "stop"),
|
||||
("max_tokens", "length"),
|
||||
("tool_use", "tool_calls"),
|
||||
("compaction", "length"),
|
||||
("compaction", "stop"),
|
||||
("content_filtered", "content_filter"),
|
||||
],
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue