-
Notifications
You must be signed in to change notification settings - Fork 275
Insert newlines after streaming tool results #770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Insert newlines after streaming tool results #770
Conversation
Thanks for the PR. This is trickier than it appears. I need to test some edge cases when I can before merging. |
d6b4335
to
f55fe33
Compare
Think I've run into one of those edge cases you were talking about @karthink: we should really be inserting the separator before a chat response, rather than after a tool response - otherwise multiple tool calls in a row leads to a bunch of newlines. Not sure if I'll have time to tackle that today but should be able to soon-ish. |
f55fe33
to
f36fb33
Compare
@@ -266,6 +266,9 @@ Optional RAW disables text properties and transformation." | |||
(set-marker-insertion-type tracking-marker t) | |||
(plist-put info :tracking-marker tracking-marker)) | |||
(goto-char tracking-marker) | |||
(when (plist-get info :last-was-tool-result) | |||
(insert gptel-response-separator) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's another edge case.
When you test Claude it usually responds with text ("I'll run this tool for you"), then a tool call, then more text ("The results of the tool are X"). This fix works fine for those cases.
Suppose the LLM responds instead with a tool call followed by a response, as Gemini and OpenAI models do. (No preamble before the tool call.)
Then you get a response that looks like this (with response-prefix Response:
)
User: What is the time in Greece?
Response:
The time in Greece is ...
instead of
User: What is the time in Greece?
Response: The time in Greece is...
The extra gptel-response-separator
between Response:
and the result is from your :last-was-tool-call
tracking.
Also, a similar fix might be needed for non-streaming responses. |
f36fb33
to
7672ab9
Compare
7672ab9
to
e45bcec
Compare
e45bcec
to
7476897
Compare
7476897
to
a3493ad
Compare
@jdormit I see a couple of new commits from you here. Is the edge case from my comment above handled now? |
This is a fix for #769. It ensures that we insert a
gptel-response-separator
after a tool result comes in in streaming mode. This prevents weird formatting whengptel-include-tool-results
isnil
and the tool result came in between two chat responses (see the linked issue for details).