You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and it does work, but I think there is something I don't understand: the gptel buffer just stops and the progress notifications get displayed in the Message buffer.
I found the definition that is doing it in mcp.el and I tried to redefine it below: no matter what it doesn't write content in the gptel buffer...
I think I just need a pointer to get my code to write to the buffer and I can probably figure out how to fix also the tool state notification area (it seems to not update at all after calling the tool).
(defun mcp-notification-dispatcher (connection name method params)
"Handle notifications from MCP server.
CONNECTION is the JSON-RPC connection object. NAME identifies the
server. METHOD is the notification name. PARAMS contains the
notification data."
(pcase method
('notifications/message
(cond ((or (plist-member (mcp--capabilities connection) :logging)
(and (plist-member params :level)
(plist-member params :data)))
(cl-destructuring-bind (&key level data &allow-other-keys) params
(let ((logger (plist-get params :logger)))
(message "[mcp][%s][%s]%s: %s"
name
level
(if logger
(format "[%s]" logger)
"")
data))))))
('codex/event
(message "%s Received notification: method=%s, params=%s, fsm=" name method params )
(let* ((msg (plist-get params :msg))
(type (plist-get msg :type))
;; This assumes there's a gptel request active and this is the
;; buffer where it was made.
(info (and-let* ((fsm (with-current-buffer
"*OpenRouter*" ;; forcing the buffer because I couldn't get hold of the fsm -- sort of worked like this
gptel--fsm-last)))
(gptel-fsm-info fsm))))
(when info
(with-current-buffer (plist-get info :buffer)
(pcase type
('agent_reasoning
(when-let ((delta (plist-get msg :text)))
(gptel--display-reasoning-stream delta info)))
('agent_reasoning_delta
(when-let ((delta (plist-get msg :delta)))
(gptel--display-reasoning-stream delta info)))
('agent_message
(when-let ((delta (plist-get msg :message)))
(goto-char (point-max))
(insert delta);; (gptel-curl--stream-insert-response delta info) ;; no matter what, this doesn't write
))
('agent_message_delta
(when-let ((delta (plist-get msg :delta)))
(goto-char (point-max))
(insert delta)))
('exec_command_begin
(when-let ((command (plist-get msg :command)))
(goto-char (point-max))
(insert (concat "\n\n**Running command:**\n\n=sh\n" command "\n=\n\n"))))
('exec_command_output_delta
(when-let* ((chunk (plist-get msg :chunk))
(decoded-chunk (progn (require 'base64) (base64-decode-string chunk))))
(goto-char (point-max))
(insert decoded-chunk)
)))))))
(_
(message "%s Received notification: method=%s, params=%s" name method params))))
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hey thanks again for the useful package: it rocks!
I have been trying codex-cli and I thought it would be great to use it from gptel.
So with a bit of config through mcp.el I got to:
and it does work, but I think there is something I don't understand: the gptel buffer just stops and the progress notifications get displayed in the Message buffer.
I found the definition that is doing it in mcp.el and I tried to redefine it below: no matter what it doesn't write content in the gptel buffer...
I think I just need a pointer to get my code to write to the buffer and I can probably figure out how to fix also the tool state notification area (it seems to not update at all after calling the tool).
Beta Was this translation helpful? Give feedback.
All reactions