gptel icon indicating copy to clipboard operation
gptel copied to clipboard

User message lost when redirecting to another buffer

Open pabl0 opened this issue 8 months ago • 0 comments

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

  • [x] I have updated gptel to the latest commit and tested that the issue still exists

Bug Description

This appears to be a fairly basic bug. Am I misunderstanding how this is supposed to function? I tested older versions back to 0.9.7, and they all behaved the same way, suggesting it wasn't introduced in a recent commit, or that this is the expected behavior and my mental model is wrong.

Backend

None

Steps to Reproduce

  1. Create a new empty buffer in either fundamental-mode or gptel-mode.

  2. Enter a prompt (Apua, apua, kissa syö rapua!).

  3. Execute M-x gptel-menu.

  4. Press J to inspect the request. The expected JSON should appear:

{
  "model": "gpt-4o-mini",
  "messages": [
    {
      "role": "system",
      "content": "You are a large language model living in Emacs and a helpful assistant. Respond concisely."
    },
    {
      "role": "user",
      "content": "Apua, apua, kissa syö rapua!"
    }
  ],
  "stream": true,
  "temperature": 1.0
}
  1. Press C-c C-k to cancel, then hit d and enter a new buffer name. Inspect again with `J. The resulting request only contains the system message:
{
  "model": "gpt-4o-mini",
  "messages": [
    {
      "role": "system",
      "content": "You are a large language model living in Emacs and a helpful assistant. Respond concisely."
    }
  ],
  "stream": true,
  "temperature": 1.0
}
  1. Repeat the above steps with g (response to gptel buffer). The behavior is inconsistent; sometimes only the system message is included, while other times the user message appears.

  2. Test with e (echo area) and k (kill-ring) – these consistently work as expected.

Additional Context

Emacs version 29.4 on linux.

Backtrace


Log Information


pabl0 avatar Feb 15 '25 14:02 pabl0