spring-projects / spring-projects/spring-ai

Model Tool Calls not persisted in chat memory

Open
#2,101 16 comments 12 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

chat memory
Dominant language
Java
Stars
9.5k
Forks
2.9k
Avg merge
1d 7h
Merged PRs (30d)
6

Description

Bug description
When adding a MessageChatMemoryAdvisor to my chat client. I would expect it to persist all messages, including the tool calls that the model makes. However, when getting the final chatResponse, I can only see the user message and the final model response in the chat memory.

Environment
Java 21, SpringAI M4, InMemoryChatMemory

Steps to reproduce

  1. Create a chat client with at least one tool call and add a MessageChatMemoryAdvisor with an InMemoryChatMemory instance passed in to it.
  2. Make a user query which invokes the tool call
  3. Investigate the ChatMemory instance and see that only the user input and the model response are included in the history.

Expected behavior
I expected to also be able to see the model tool calls in the ChatHistory

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the tool-call flow with MessageChatMemoryAdvisor and InMemoryChatMemory, then trace how the user message, tool calls, and final model response are added to chat history. Done means the ChatMemory history includes the model tool calls as well as the user input and final response.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
ai, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.