-
Notifications
You must be signed in to change notification settings - Fork 331
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
| (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
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? |
26e3dac to
002c7cf
Compare
dd500de to
77c289f
Compare
|
@jdormit I'd like to merge this PR but I'm not sure all the edge cases are covered. If you're still interested in it, please let me know -- we'll need some tests to ensure that they are, and I can work on merging. Please let me know if you've moved on as well, and I can close the PR. |
This is a fix for #769. It ensures that we insert a
gptel-response-separatorafter a tool result comes in in streaming mode. This prevents weird formatting whengptel-include-tool-resultsisniland the tool result came in between two chat responses (see the linked issue for details).