mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
test(anthropic): cover identity-strip drop and non-text block branches
Close the Codecov gaps on strip_claude_code_identity_from_system: identity+content same-block rewrite, non-text blocks, non-dict list items, non-str/non-list payload, and the identity-only system-pop path.
This commit is contained in:
parent
bbbf53bec1
commit
5f8c3f4707
2 changed files with 37 additions and 0 deletions
|
|
@ -6565,3 +6565,26 @@ def test_eager_input_streaming_reaches_anthropic_request_tools():
|
|||
|
||||
assert result["tools"][0]["eager_input_streaming"] is True
|
||||
assert result["tools"][0]["name"] == "write_file"
|
||||
|
||||
|
||||
def test_messages_request_strips_identity_only_system_for_minimax():
|
||||
"""Identity-only system drops the whole system param (pop path)."""
|
||||
from litellm.llms.minimax.messages.transformation import MinimaxMessagesConfig
|
||||
from litellm.types.router import GenericLiteLLMParams
|
||||
|
||||
config = MinimaxMessagesConfig()
|
||||
optional_params = {
|
||||
"max_tokens": 16,
|
||||
"system": [
|
||||
{"type": "text", "text": "You are Claude Code, Anthropic's official CLI for Claude."},
|
||||
],
|
||||
}
|
||||
result = config.transform_anthropic_messages_request(
|
||||
model="MiniMax-M2",
|
||||
messages=[{"role": "user", "content": "hi"}],
|
||||
anthropic_messages_optional_request_params=optional_params,
|
||||
litellm_params=GenericLiteLLMParams(),
|
||||
headers={},
|
||||
)
|
||||
|
||||
assert "system" not in result
|
||||
|
|
|
|||
|
|
@ -108,6 +108,20 @@ CLAUDE_CODE_IDENTITY = "You are Claude Code, Anthropic's official CLI for Claude
|
|||
],
|
||||
[{"type": "text", "text": "real system prompt", "cache_control": {"type": "ephemeral"}}],
|
||||
),
|
||||
# List form: identity + real content in the same block -> rewritten block.
|
||||
(
|
||||
[{"type": "text", "text": f"{CLAUDE_CODE_IDENTITY}\nreal system prompt"}],
|
||||
[{"type": "text", "text": "real system prompt"}],
|
||||
),
|
||||
# List form: a non-text block (type "other") is kept as-is.
|
||||
(
|
||||
[{"type": "text", "text": CLAUDE_CODE_IDENTITY}, {"type": "other", "foo": "bar"}],
|
||||
[{"type": "other", "foo": "bar"}],
|
||||
),
|
||||
# List form: non-dict items are kept as-is.
|
||||
([{"type": "text", "text": CLAUDE_CODE_IDENTITY}, "loose item"], ["loose item"]),
|
||||
# Non-string, non-list system payload is passed through untouched.
|
||||
(None, None),
|
||||
],
|
||||
)
|
||||
def test_strip_claude_code_identity_from_system(system_param, expected):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue