Skip to content

v0.3.3 causes illegal argument exception in Google GenAi - Only one system message is allowed in the prompt #1381

@LiveNathan

Description

@LiveNathan

All tests were passing. I upgraded from 0.3.2 to 0.3.3 and now they are all failing for the same reason: java.lang.IllegalArgumentException: Only one system message is allowed in the prompt

Here's an example usage:

ClassifiedIntents classifyIntent(String userMessage, Ai ai) {
        return ai.withLlm(LlmOptions.withFirstAvailableLlmOf(ModelRole.BALANCED.preferredModels()).withTemperature(0.1))
                .withId("classify-intent")
                .creating(ClassifiedIntents.class)
                .withExample("Request example: Where's the lead vocal? Send it to the vocal buss.", createIndependentRequestsExample())
                .withExample("Request example: Rename channels 1-4 to RF 1-4 then change the color to red and then disable routes to main.", createCompoundRequestExample())
                .withExample("Request example: Hello there!", createOtherRequestExample())
                .fromPrompt(createClassifyIntentPrompt(userMessage));
    }

It fails:

09:53:05.428 [ForkJoinPool-1-worker-1] INFO Embabel - [strange_hopper] (classify-intent) using LLM gemini-2.5-flash, creating ClassifiedIntents: LlmOptions(modelSelectionCriteria=FallbackByNameModelSelectionCriteria(names=[gemini-2.5-flash, gemini-2.5-pro, gemini-2.0-flash, llama3.2:latest, llama3.1:8b, llama3.2:1b]), model=null, role=null, temperature=0.1, frequencyPenalty=null, maxTokens=null, presencePenalty=null, topK=null, topP=null, thinking=null, timeout=null)
09:53:05.429 [ForkJoinPool-1-worker-1] INFO RetryProperties - Operation googlegenai-gemini-2.5-flash: Retry error. Retry count: 1
java.lang.IllegalArgumentException: Only one system message is allowed in the prompt
at org.springframework.util.Assert.isTrue(Assert.java:116)
at org.springframework.ai.google.genai.GoogleGenAiChatModel.createGeminiRequest(GoogleGenAiChatModel.java:823)
at org.springframework.ai.google.genai.GoogleGenAiChatModel.lambda$internalCall$3(GoogleGenAiChatModel.java:439)
at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:357)
at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:230)
at org.springframework.ai.google.genai.GoogleGenAiChatModel.lambda$internalCall$4(GoogleGenAiChatModel.java:437)
at io.micrometer.observation.Observation.observe(Observation.java:564)
at org.springframework.ai.google.genai.GoogleGenAiChatModel.internalCall(GoogleGenAiChatModel.java:437)

I tried removing all of the examples. Same result. I tried removing withId. Same result. I will have to downgrade back to 0.3.2 until this is resolve.

Thanks!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions