Move post-request hook before sentinel creation#1177
Open
aagit wants to merge 1 commit intokarthink:masterfrom
Open
Move post-request hook before sentinel creation#1177aagit wants to merge 1 commit intokarthink:masterfrom
aagit wants to merge 1 commit intokarthink:masterfrom
Conversation
The gptel-post-request-hook is run after the process sentinel has been created. If this hook aborts a running background request (e.g., a kvcache preloading task) using gptel-abort, it can interfere with the new request's setup, causing a "Search failed" error when the new request tries to access the FSM state. This change ensures the post-request hook runs before the process sentinel is created, preventing interference between concurrent requests and avoiding the "Search failed" error when aborting background tasks. The error message observed was: ------ kvcache speculative prelaoding started by timer ------ Querying ryzen... Wrote /tmp/gptel-curl-datadgs2S0.json ------ gptel-post-request-hook calls gptel-abort to stop preloading ------ Stopped gptel request in buffer "*gptel-context-preload*" ------ real request fails to start ------ Querying ryzen... error in process sentinel: save-current-buffer: Search failed: "79f42ff48ff153e47dc3d3dba8020dc6" error in process sentinel: Search failed: "79f42ff48ff153e47dc3d3dba8020dc6" This is only observed if running a gptel-request in a gptel mode buffer, does not happen if it's gptel-rewrite issuing the gptel-request.
Contributor
Author
|
After reading your answer about how to inject the per rg-edit grammar, I wondered if I could use the gptel-prompt-transform-functions instead of gptel-post-request-hook and it works. So I worked around this issue by switching hook. |
Owner
@aagit Do you still want to pursue this PR? Note that there are some subtleties involved in the placement of this hook w.r.t. sentinel creation that will need to be investigated carefully. |
Contributor
Author
|
My workflow doesn't require this one anymore as I shifted hook successfully. It's up to you judje where's the best place to run those hooks. What I found is the place where it's run now breaks if gptel-abort is called by the hook. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The gptel-post-request-hook is run after the process sentinel has been created. If this hook aborts a running background request (e.g., a kvcache preloading task) using gptel-abort, it can interfere with the new request's setup, causing a "Search failed" error when the new request tries to access the FSM state.
This change ensures the post-request hook runs before the process sentinel is created, preventing interference between concurrent requests and avoiding the "Search failed" error when aborting background tasks.
The error message observed was:
This is only observed if running a gptel-request in a gptel mode buffer, does not happen if it's gptel-rewrite issuing the gptel-request.