backstage / backstage/community-plugins
๐ mcp-chat: incorrect "tools used" being displayed report when reloading conversation from history
- Dominant language
- TypeScript
- Stars
- 422
- Forks
- 697
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 286
Description
### Workspace
mcp-chat
### ๐ Description
When reloading an old conversation from history, the "Tools used" section of **any** message from agent shows the tool that was used during the last query from user, along with its results.
Moreover, when inspecting the tool response, an error message is displayed:
> "No tools used or no tool responses available"
### ๐ Expected behavior
I would expect the chat reloaded from history the behave like a fresh new chat, displaying correct tool usage and outputs:
### ๐ Actual Behavior with Screenshots
The tool used for the last message in history is used for **any** assistant message (also for those that didn't required tool execution in the original conversation).
The tool response is also not available:
### ๐ Reproduction steps
1. Start a new conversation in which you ask the agent to perform some tool calls
2. Create a new conversation
3. Reload the first conversation from history and inspect agent messages
### ๐ Provide the context for the Bug.
Every time a new message is sent to the backend from an authenticated user, the backend stores (or update) the conversation. In doing this, [only the tools used during the last request](https://github.com/backstage/community-plugins/blob/main/workspaces/mcp-chat/plugins/mcp-chat-backend/src/routes/chatRoutes.ts#L84-L117) are passed to `ChatConversationStore`. This likely leads to overriding the tools used previously in the conversation.
In addition, when persisting tools used, no association to the agent message is created. The backend simply returns the tools that where used during the last request to the frontend, which applies them to any assistant message.
### ๐ Have you spent some time to check if this bug has been raised before?
- [x] I checked and didn't find similar issue
### ๐ข Have you read the Code of Conduct?
- [x] I have read the [Code of Conduct](https://github.com/backstage/community-plugins/blob/main/CODE_OF_CONDUCT.md)
### Are you willing to submit PR?
Yes I am willing to submit a PR!
Contributor guide
Assessment
This issue has not been assessed yet.