Skip to content

Prevent bad tool calling messages from locking the chat session#2718

Open
slg95 wants to merge 2 commits intoolimorris:mainfrom
slg95:fix_tool_call_messages
Open

Prevent bad tool calling messages from locking the chat session#2718
slg95 wants to merge 2 commits intoolimorris:mainfrom
slg95:fix_tool_call_messages

Conversation

@slg95
Copy link
Contributor

@slg95 slg95 commented Feb 3, 2026

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

  • I've read the contributing guidelines and have adhered to them in this PR
  • I confirm that this PR has been majority created by me, and not AI (unless stated in the "AI Usage" section above)
  • I've run make all to ensure docs are generated, tests pass and StyLua has formatted the code
  • (optional) I've added test coverage for this fix/feature
  • (optional) I've updated the README and/or relevant docs pages

slg95 added 2 commits February 3, 2026 16:12
It's possible to send a message during a tool call, which causes errors
with all major LLM providers.
@olimorris
Copy link
Owner

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.

@slg95
Copy link
Contributor Author

slg95 commented Feb 4, 2026

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.mp4

After:

after-patch2.mp4

Since 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants