Bug description FunctionMessage class has a SYSTEM message type.

public class FunctionMessage extends AbstractMessage {
    public FunctionMessage(String content) {
        super(MessageType.SYSTEM, content);
}

Class located: spring-ai/spring-ai-core/src/main/java/org/springframework/ai/chat/messages/FunctionMessage.java

Minimal Complete Reproducible example

protected String messageToString(Message message) {
      switch (message.getMessageType()) {
          case SYSTEM:
              return message.getContent();
          case USER:
              return humanPrompt + " " + message.getContent();
          case ASSISTANT:
              return assistantPrompt + " " + message.getContent();
          case FUNCTION:
              throw new IllegalArgumentException("Tool execution results are not supported for Bedrock models");
      }

      throw new IllegalArgumentException("Unknown message type: " + message.getMessageType());
}

This snippet will not throw the following exception IllegalArgumentException("Tool execution results are not supported for Bedrock models"); for FunctionMessage messages as the type is marked as SYSTEM and not FUNCTION

The code is located: /spring-ai/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/MessageToPromptConverter.java

Comment From: tzolov

Good catch @PabloSanchi !

Apparently the FUNCTION message type is not used currently. It is not used in our OpenAI Function Calling impl. either. We shall see if this message type is ever required as we progress implementing function calling for other models.

In the meantime if fix the inconsistency.