diff --git a/autogen/oai/anthropic.py b/autogen/oai/anthropic.py index 8ed6f909e6bc..4472c177cfdf 100644 --- a/autogen/oai/anthropic.py +++ b/autogen/oai/anthropic.py @@ -314,7 +314,7 @@ def oai_messages_to_anthropic_messages(params: Dict[str, Any]) -> list[dict[str, last_tool_result_index = -1 for message in params["messages"]: if message["role"] == "system": - params["system"] = message["content"] + params["system"] = params.get("system", "") + ("\n" if "system" in params else "") + message["content"] else: # New messages will be added here, manage role alternations expected_role = "user" if len(processed_messages) % 2 == 0 else "assistant"