Prevent bad tool calling messages from locking the chat session#2718
Prevent bad tool calling messages from locking the chat session#2718slg95 wants to merge 2 commits intoolimorris:mainfrom
Conversation
It's possible to send a message during a tool call, which causes errors with all major LLM providers.
|
Can you share some detail on where and how this is happening? The buffer is locked so prevents any input from being sent. I'd rather get to the root cause than patch with code. |
Of course. I have two videos, before and after the patch. (sorry they are so short, I figure you can pause as needed. GItHub has a max of 10MB for file uploads) Before: before-patch3.mp4After: after-patch2.mp4Since you can send messages while the buffer is locked, sending an empty message causes the chat window to be unable to fix itself. So, another solution could be to prevent empty messages or prevent sending messages until the tool call result message is added to the message table. |
Description
If you attempt to send a message in-between a tool call message from the LLM and the result of that tool call, it creates an invalid message history and the LLM may refuse to send a reply. I know this is a problem with Claude, and all the other major LLMs also claim this is not supported (haven't verified with any other provider). This stops you from adding subsequent messages in the chat session since the issue is that the messages need to be reordered. This can be fixed through the debug window, but its a pain to try to do so.
AI Usage
Claude Opus helped with research, and Claude Sonnet did the implementation. Sonnet did all of the coding work, but I iterated over the result a few times and reviewed the final output.
Related Issue(s)
Screenshots
Checklist
make allto ensure docs are generated, tests pass and StyLua has formatted the code