Skip to content

The Default System Prompt is not the first element in the messages array #2216

Closed
@rafaelrddc

Description

@rafaelrddc

Please do a quick search on GitHub issues first, there might be already a duplicate issue for the one you are about to create.
If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:

Bug description
When we use the chatClient class with "defaultSystem" and "MessageChatMemoryAdvisor", when making the call to OpenAI with a message history, the first element of the array is not of role "system"

Image

Environment
Spring AI: 1.0.0-M5
Java version: 21.0.5-zulu

Steps to reproduce
I created a chatClient linked to a "defaultSystem" and with the "MessageChatMemoryAdvisor", and checked the order of the messages sent to OpenAI.

Expected behavior
The default system message will always be the first message in the array sent to OpenAI.

Minimal Complete Reproducible example
Please provide a failing test or a minimal complete verifiable example that reproduces the issue.
Bug reports that are reproducible will take priority in resolution over reports that are not reproducible.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions