-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Expected Behavior
SpringAI should leverage the native response schema mechanism provided by the underlying GenAI model when a response class is provided via .entity(...).
Example:
ResponseSchema response = ChatClient.builder(chatModel)
.build()
.prompt(prompt)
.call()
.entity(ResponseSchema.class);
Internally, SpringAI should translate this into a structured call without injecting additional instructions into the last UserMessage.
Current Behavior
Currently, SpringAI appends additional instructions to the last UserMessage to guide the LLM response formatting when .entity(...) is used.
This breaks the intended use of GenAI-native response schema features, and may reduce reliability or introduce hallucinations, especially when dealing with complex schemas.
Context
This affects use cases where strict adherence to schema is expected or required - e.g., structured output for downstream automation or parsing.
Using injected instructions is less robust and prone to failures with non-trivial or deeply nested schemas.