Skip to content

Filter unsupported tool messages in JdbcChatMemoryRepository - #6398

Closed
tzolov wants to merge 1 commit into
spring-projects:mainfrom
tzolov:filter-tool-messages-in-jdbc-chat-memory-repository
Closed

tzolov wants to merge 1 commit into
spring-projects:mainfrom
tzolov:filter-tool-messages-in-jdbc-chat-memory-repository

Conversation

@tzolov

@tzolov tzolov commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Previously, ToolResponseMessage and AssistantMessage instances with tool calls were silently saved with corrupted data and read back as empty stubs, polluting the LLM conversation context.

This commit explicitly filters out those message types on save to prevent corrupted messages from being injected into the LLM context. Legacy TOOL rows already in the database are skipped on read.

@tzolov tzolov added this to the 2.0.0 milestone Jun 11, 2026
@tzolov tzolov added bug Something isn't working chat memory labels Jun 11, 2026
Previously, ToolResponseMessage and AssistantMessage instances with
tool calls were silently saved with corrupted data and read back as
empty stubs, polluting the LLM conversation context.

This commit explicitly filters out those message types on save to
prevent corrupted messages from being injected into the LLM context.
Legacy TOOL rows already in the database are skipped on read.

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
@sdeleuze sdeleuze self-assigned this Jun 11, 2026
@tzolov
tzolov force-pushed the filter-tool-messages-in-jdbc-chat-memory-repository branch from 724b7aa to cdf63c8 Compare June 11, 2026 13:34
private static class MessageRowMapper implements RowMapper<Message> {

@Override
@SuppressWarnings("NullAway") // TOOL rows return null; caller filters them out

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should change return type to @Nullable Message instead to represent reality, or did I miss some exceptional situation that legitimizes this?

@sdeleuze sdeleuze closed this in e55144b Jun 11, 2026
@sdeleuze sdeleuze changed the title Filter unsupported tool messages in JdbcChatMemoryRepository Filter unsupported tool messages in JdbcChatMemoryRepository Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working chat memory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants