From 8f1eaec0c332808e49be129b0144ee16eb52c019 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Tue, 15 Jul 2025 19:34:47 +0200 Subject: [PATCH] anthropic: drop new lines on empty system prompt --- pydantic_ai_slim/pydantic_ai/models/anthropic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydantic_ai_slim/pydantic_ai/models/anthropic.py b/pydantic_ai_slim/pydantic_ai/models/anthropic.py index 6aac2931a..7e09975d6 100644 --- a/pydantic_ai_slim/pydantic_ai/models/anthropic.py +++ b/pydantic_ai_slim/pydantic_ai/models/anthropic.py @@ -365,7 +365,7 @@ async def _map_message(self, messages: list[ModelMessage]) -> tuple[str, list[Be assert_never(m) system_prompt = '\n\n'.join(system_prompt_parts) if instructions := self._get_instructions(messages): - system_prompt = f'{instructions}\n\n{system_prompt}' + system_prompt = f'{instructions}\n\n{system_prompt}' if system_prompt else instructions return system_prompt, anthropic_messages @staticmethod