Variable: gptel-pre-tool-call-functions

gptel-pre-tool-call-functions is a customizable variable defined in gptel.el.

Value

nil

Documentation

Abnormal hook called before each tool call.

Each hook function is called a plist with the following keys:

:name - the name of the tool being called, a string
:args - a plist of the tool call arguments, as specified in the tool
        definition. For a hypothetical edit_file tool that takes three
        arguments, a FILENAME, an ORIGINAL and REPLACEMENT strings, this
        plist is structured as

  (:filename "/path/to/file.md"
   :original "..."
   :replacement "...")

:buffer - The name of the buffer from which the request was sent.
:backend - The name of the gptel backend used for the request.
:model - The name of the gptel model used for the request.

The function can work by side effects and return nil, or return a plist with one or more of the following keys.

:stop - If non-nil, stop the request entirely.
:stop-reason - If :stop is non-nil, the reason for stopping. Intended
               for the user, not the LLM.

:block - If non-nil, continue the request but block this tool call and
           mark it as having erred. Can be a string to send as the
           result instead, typically an explanation for why the tool was
           not run. Intended for the LLM, not the user.

:confirm - Whether the tool call should seek confirmation from the user.
           t and nil are both meaningful, signifying that the tool call
           should and should not seek user confirmation, respectively.
           When present, this key overrides all other confirmation
           options (such as gptel-confirm-tool-calls and the tool's
           CONFIRM slot).
:args - The updated argument plist for the tool call.
:result - The result of this tool call, used instead of the tool call
           output. Not marked as an error.

Source Code

;; Defined in /nix/store/q3r7g81pvghw7a523kjk2k2zih3pfk8z-emacs-packages-deps/share/emacs/site-lisp/elpa/gptel-20261002.545/gptel.el
(defcustom gptel-pre-tool-call-functions nil
  "Abnormal hook called before each tool call.

Each hook function is called a plist with the following keys:

:name - the name of the tool being called, a string
:args - a plist of the tool call arguments, as specified in the tool
        definition.  For a hypothetical edit_file tool that takes three
        arguments, a FILENAME, an ORIGINAL and REPLACEMENT strings, this
        plist is structured as

  (:filename \"/path/to/file.md\"
   :original \"...\"
   :replacement \"...\")

:buffer  - The name of the buffer from which the request was sent.
:backend - The name of the gptel backend used for the request.
:model   - The name of the gptel model used for the request.

The function can work by side effects and return nil, or return a plist
with one or more of the following keys.

:stop        - If non-nil, stop the request entirely.
:stop-reason - If :stop is non-nil, the reason for stopping.  Intended
               for the user, not the LLM.

:block -   If non-nil, continue the request but block this tool call and
           mark it as having erred.  Can be a string to send as the
           result instead, typically an explanation for why the tool was
           not run.  Intended for the LLM, not the user.

:confirm - Whether the tool call should seek confirmation from the user.
           t and nil are both meaningful, signifying that the tool call
           should and should not seek user confirmation, respectively.
           When present, this key overrides all other confirmation
           options (such as `gptel-confirm-tool-calls' and the tool's
           CONFIRM slot).
:args    - The updated argument plist for the tool call.
:result  - The result of this tool call, used instead of the tool call
           output.  Not marked as an error."
  :type 'hook
  :group 'gptel)