-
-
Notifications
You must be signed in to change notification settings - Fork 37
Added ability to cancel tool calls. #145
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
Merged
ericdallo
merged 5 commits into
editor-code-assistant:master
from
bombaywalla:cancel-shell-calls
Oct 6, 2025
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,14 @@ | |
| (defmethod tool-call-details-after-invocation :default [_name _arguments details _result] | ||
| details) | ||
|
|
||
| (defmulti tool-call-destroy-resource! | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏻 |
||
| "Destroy the tool call resource." | ||
| (fn [name _resource-kwd _resource] (keyword name))) | ||
|
|
||
| (defmethod tool-call-destroy-resource! :default [_name _resource-kwd _resource] | ||
| ;; By default, do nothing | ||
| ) | ||
|
|
||
| (defn single-text-content [text & [error]] | ||
| {:error (boolean error) | ||
| :contents [{:type :text | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
what will happen when this comes nil? I believe
resultwill be nil as well? is that expected?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.
Good question.
When proc is
nil, that would mean that the tool call is in the:stoppingstatus and so we don't want to start another process. As you say,resultwill benil. The:elseclause of thecondwill trigger and an error will be reported. Admittedly, the error message will be less than useful.Would it be better to have
resultbe set to{:exit 1 :err "Tool call is :stopping, so shell process not started"}? Or would you prefer a different way to handle this?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.
hum, not sure, we certainly don't want to respond to LLM right? so it doesn't need to have a response with the exit/err format, maybe we should just throw a exception?
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.
Sorry, but I don't follow. If we throw an Exception, it will be caught right there and will return an exit/err anyways. What am I missing?
Why should we not respond to the LLM? It asked for a tool call, so should we not at least send a response saying why we are not running the call? I'm not familiar enough with what the LLMs would expect in such a case, but my guess would be that some feedback would be helpful.
My guess is that what I suggested with the exit/err is a reasonable way to proceed. But let me know if you'd prefer a different approach.
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.
if we are stopping, we don't want to request LLM again right? because the LLM loop are just requests and responses, if we are :stopping, we don't want to continure this loop (answer LLM), does that makes sense?
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.
I think this code was meant to be defensive in the following situation.
The LLM has requested a call. However, before the process was started, there was a stop request and so the call has transitioned to :stopping. Now, in the tool call future, just before spawning the process, the call checks to see what its status is. If it is :stopping, it will not spawn off the process.
Currently, the only way to request a stop is via stopping the whole prompt and the whole LLM loop.
We have also talked about the situation where the user might want to stop a particular tool call and continue with the rest. In that case, I would guess that we do want to continue the LLM loop with the remaining calls, right?
I was trying to be consistent with what happens if, for whatever reason (say reaching a process limit), the process cannot be spawned.
Perhaps you can explain more what you meant by throwing an Exception. In particular, where you expect this Exception would be handled.
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.
Good question, currently we don't have the option to stop one tool call so I don't know what would happen if 3 tool calls are running and user stop 1, what we should do? but yeah, maybe you are right, we want to respond that user stopped the tool call and respond to LLM , so I think it's ok to return that err/exit structure you mentioned.
Nvm, I was thinking in a case user stop the prompt, but not stopping a single tool call, I just think that: