Skip to content

Commit 4ea9e32

Browse files
committed
Prefix tool call with server name.
Fixes #53
1 parent ebc3500 commit 4ea9e32

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

eca-chat.el

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,6 @@ Must be a positive integer."
166166
(defvar-local eca-chat--tool-call-prepare-content-cache (make-hash-table :test 'equal)
167167
"Hash table mapping toolCall ID to accumulated argument text.")
168168

169-
(defvar-local eca-chat--tool-call-prepare-metadata-cache (make-hash-table :test 'equal)
170-
"Hash table mapping toolCall ID to tool metadata (name, summary, etc).")
171-
172169
(defcustom eca-chat-tool-call-approval-content-size 0.9
173170
"The size of font of tool call approval."
174171
:type 'number
@@ -1557,6 +1554,7 @@ string."
15571554
("toolCallPrepare"
15581555
(let* ((id (plist-get content :id))
15591556
(name (plist-get content :name))
1557+
(server (plist-get content :server))
15601558
(argsText (plist-get content :argumentsText))
15611559
(summary (or (plist-get content :summary)
15621560
(format "Preparing tool: %s" name)))
@@ -1571,7 +1569,6 @@ string."
15711569
;; Always cache the metadata and content
15721570
(puthash id (1+ current-count) eca-chat--tool-call-prepare-counters)
15731571
(puthash id new-content eca-chat--tool-call-prepare-content-cache)
1574-
(puthash id (list :name name :summary summary) eca-chat--tool-call-prepare-metadata-cache)
15751572
;; Only update UI when throttling permits
15761573
(when should-update-ui-p
15771574
(let ((label (concat (propertize summary 'font-lock-face 'eca-chat-mcp-tool-call-label-face)
@@ -1584,16 +1581,14 @@ string."
15841581
id label
15851582
(eca-chat--content-table
15861583
`(("Tool" . ,name)
1584+
("Server" . ,server)
15871585
("Arguments" . ,new-content)))))))))
15881586
("toolCallRun"
15891587
(let* ((id (plist-get content :id))
1590-
(cached-metadata (gethash id eca-chat--tool-call-prepare-metadata-cache))
15911588
(args (plist-get content :arguments))
1592-
(name (or (plist-get content :name)
1593-
(plist-get cached-metadata :name)))
1594-
(summary (or (plist-get content :summary)
1595-
(plist-get cached-metadata :summary)
1596-
(format "Calling tool: %s" name)))
1589+
(name (plist-get content :name))
1590+
(server (plist-get content :server))
1591+
(summary (format "Calling tool: %s__%s" server name))
15971592
(manual? (plist-get content :manualApproval))
15981593
(status eca-chat-mcp-tool-call-loading-symbol)
15991594
(approval-text (when manual?
@@ -1630,16 +1625,15 @@ string."
16301625
approval-text)
16311626
(eca-chat--content-table
16321627
`(("Tool" . ,name)
1628+
("Server" . ,server)
16331629
("Arguments" . ,args)))))))
16341630
("toolCallRunning"
16351631
(let* ((id (plist-get content :id))
1636-
(cached-metadata (gethash id eca-chat--tool-call-prepare-metadata-cache))
16371632
(cached-args (gethash id eca-chat--tool-call-prepare-content-cache ""))
1638-
(name (or (plist-get content :name)
1639-
(plist-get cached-metadata :name)))
1633+
(name (plist-get content :name))
1634+
(server (plist-get content :server))
16401635
(summary (or (plist-get content :summary)
1641-
(plist-get cached-metadata :summary)
1642-
(format "Running tool: %s" name)))
1636+
(format "Running tool: %s__%s" server name)))
16431637
(details (plist-get content :details))
16441638
(status eca-chat-mcp-tool-call-loading-symbol))
16451639
(if (and (stringp (plist-get details :type))
@@ -1669,12 +1663,14 @@ string."
16691663
" " status)
16701664
(eca-chat--content-table
16711665
`(("Tool" . ,name)
1666+
("Server" . ,server)
16721667
("Arguments" . ,cached-args)))))))
16731668
("toolCalled"
16741669
(let* ((id (plist-get content :id))
16751670
(name (plist-get content :name))
1671+
(server (plist-get content :server))
16761672
(summary (or (plist-get content :summary)
1677-
(format "Called tool: %s" name)))
1673+
(format "Called tool: %s__%s" server name)))
16781674
(args (plist-get content :arguments))
16791675
(outputs (plist-get content :outputs))
16801676
(output-text (if outputs
@@ -1689,7 +1685,6 @@ string."
16891685
;; Cleanup counters for this tool-call id to avoid unbounded growth
16901686
(remhash id eca-chat--tool-call-prepare-counters)
16911687
(remhash id eca-chat--tool-call-prepare-content-cache)
1692-
(remhash id eca-chat--tool-call-prepare-metadata-cache)
16931688
(if (and (stringp (plist-get details :type))
16941689
(string= "fileChange" (plist-get details :type)))
16951690
(let* ((path (plist-get details :path))
@@ -1716,10 +1711,12 @@ string."
17161711
" " status time)
17171712
(eca-chat--content-table
17181713
`(("Tool" . ,name)
1714+
("Server" . ,server)
17191715
("Arguments" . ,args)
17201716
("Output" . ,output-text)))))))
17211717
("toolCallRejected"
17221718
(let* ((name (plist-get content :name))
1719+
(server (plist-get content :server))
17231720
(args (plist-get content :arguments))
17241721
(details (plist-get content :details))
17251722
(summary (plist-get content :summary))
@@ -1728,7 +1725,6 @@ string."
17281725
;; Cleanup counters for this tool-call id
17291726
(remhash id eca-chat--tool-call-prepare-counters)
17301727
(remhash id eca-chat--tool-call-prepare-content-cache)
1731-
(remhash id eca-chat--tool-call-prepare-metadata-cache)
17321728
(if (string= "fileChange" (plist-get details :type))
17331729
(eca-chat--update-expandable-content
17341730
id
@@ -1741,11 +1737,12 @@ string."
17411737
(eca-chat--file-change-diff (plist-get details :path) (plist-get details :diff) roots)))
17421738
(eca-chat--update-expandable-content
17431739
id
1744-
(concat (propertize (format "Rejected tool: %s" name)
1740+
(concat (propertize (format "Rejected tool: %s__%s" server name)
17451741
'font-lock-face 'eca-chat-mcp-tool-call-label-face)
17461742
" "
17471743
eca-chat-mcp-tool-call-error-symbol)
17481744
(eca-chat--content-table `(("Tool" . ,name)
1745+
("Server" . ,server)
17491746
("Arguments" . ,args)))))))
17501747
("progress"
17511748
(pcase (plist-get content :state)
@@ -1904,7 +1901,6 @@ string."
19041901
;; Reset per-buffer tool prepare counters to avoid leaking across sessions
19051902
(setq-local eca-chat--tool-call-prepare-counters (make-hash-table :test 'equal))
19061903
(setq-local eca-chat--tool-call-prepare-content-cache (make-hash-table :test 'equal))
1907-
(setq-local eca-chat--tool-call-prepare-metadata-cache (make-hash-table :test 'equal))
19081904
(eca-chat--clear (eca-session))))
19091905

19101906
;;;###autoload

0 commit comments

Comments
 (0)