karthink / gptel

A simple LLM client for Emacs
GNU General Public License v3.0
1.59k stars 152 forks source link

Claude error: (HTTP/2 400) messages: text content blocks must contain non-whitespace text #452

Open benthamite opened 1 week ago

benthamite commented 1 week ago

Please update gptel first -- errors are often fixed by the time they're reported.

Bug Description

Continuing the discussion here: #442.

This is an instance of the phenomenon I described there as follows:

FWIW, I have also been experiencing this issue (with an up-to-date version of gptel). Strangely, in my case it is fixed by closing the org buffer and reopening the file it was visiting (NB: calling revert-buffer is not enough: the buffer has to be killed.)

Backend

Anthropic

Steps to Reproduce

  1. Open the attached Markdown file.
  2. Search for <.
  3. Delete the text enclosed in < and >.
  4. Invoke gptel-send.

It may be hard to reproduce the issue since, as noted, reopening the file fixes it. Hopefully, the other attached files will provide additional hints as to what may be going on. These fils capture the output of a dry run either before or after the fix.

Additional Context

GNU Emacs 30.0.91 (build 1, aarch64-apple-darwin24.0.0, NS appkit-2566.00 Version 15.0.1 (Build 24A348)) of 2024-10 macOS Sequoia

Backtrace

No response

Log Information

No response

Archive.zip syntax-errors.md

karthink commented 1 week ago

Thanks. The recorded response bounds in syntax-errors.md are wrong though, so I can't use it for testing. Do you have another file I could use?

gregoryg commented 1 week ago

I get this all the time with Claude, never with OpenAI. It's always mystifying, but I'll try to get a reproducible test for you!

benthamite commented 2 days ago

This finally happened again, though this time it doesn’t go away when I reopen the buffer. After some testing, it appears that problem occurs only when gptel-mode is activated. So it may be that the phenomenon I observed previously was due to the fact that closing the buffer and reopening the file had the effect of turning off gptel-mode.

Relevant files attached.

files.zip

benthamite commented 18 hours ago

Here’s another example of what I believe is the same phenomenon. I’m not entirely sure since the error message is slightly different:

Claude error: (HTTP/2 400) messages: final assistant content cannot end with trailing whitespace

[ETA: uploading a new set of files, which isolate the issue better]

files.zip