File tree Expand file tree Collapse file tree 4 files changed +27
-9
lines changed
Expand file tree Collapse file tree 4 files changed +27
-9
lines changed Original file line number Diff line number Diff line change 33## Unreleased
44
55- Improve tool call result marking as error when not expected output.
6+ - Fix cases when tool calls output nothing.
67
78## 0.12.4
89
Original file line number Diff line number Diff line change 281281 :text (or message (ex-message exception))})
282282 (finish-chat-prompt! :idle chat-ctx))})))
283283
284- (defn ^:private send-mcp-prompt! [{:keys [prompt args]} {:keys [db*] :as chat-ctx}]
284+ (defn ^:private send-mcp-prompt!
285+ [{:keys [prompt args]}
286+ {:keys [db*] :as chat-ctx}]
285287 (let [{:keys [arguments]} (first (filter #(= prompt (:name %)) (f.mcp/all-prompts @db*)))
286- i (atom -1 )
287- args-vals (reduce
288- (fn [a {:keys [name]}]
289- (swap! i inc)
290- (assoc a name (nth args @i)))
291- {}
292- arguments)
288+ args-vals (zipmap (map :name arguments) args)
293289 {:keys [messages]} (f.mcp/get-prompt! prompt args-vals @db*)]
294290 (prompt-messages! messages false chat-ctx)))
295291
Original file line number Diff line number Diff line change 77(defn single-text-content [text & [error]]
88 {:error (boolean error)
99 :contents [{:type :text
10- :content text}]})
10+ :text text}]})
1111
1212(defn workspace-roots-strs [db]
1313 (->> (:workspace-folders db)
Original file line number Diff line number Diff line change 33 [clojure.test :refer [deftest is testing]]
44 [eca.features.chat :as f.chat]
55 [eca.features.tools :as f.tools]
6+ [eca.features.tools.mcp :as f.mcp]
67 [eca.llm-api :as llm-api]
78 [eca.test-helper :as h]
89 [matcher-combinators.matchers :as m]
@@ -245,3 +246,23 @@ for allowed directories and then list files"
245246 {:role :assistant :content {:type :text :text " /foo/bar" }}
246247 {:role :system :content {:state :finished :type :progress }}]}
247248 (h/messages ))))))
249+
250+ (deftest send-mcp-prompt-test
251+ (testing " Argument mapping for send-mcp-prompt! should map arg values to prompt argument names"
252+ (let [test-arguments [{:name " foo" } {:name " bar" }]
253+ prompt-args (atom nil )
254+ test-chat-ctx {:db* (atom {})}
255+ invoked? (atom nil )]
256+ (with-redefs [f.mcp/all-prompts (fn [_]
257+ [{:name " awesome-prompt" :arguments test-arguments}])
258+ f.mcp/get-prompt! (fn [_ args-map _]
259+ (reset! prompt-args args-map)
260+ {:messages [{:role :user :content " test" }]})
261+ f.chat/prompt-messages! (fn [messages _reason? ctx] (reset! invoked? [messages ctx]))]
262+ (#'f.chat/send-mcp-prompt! {:prompt " awesome-prompt" :args [42 " yo" ]} test-chat-ctx)
263+ (is (match?
264+ @prompt-args
265+ {" foo" 42 " bar" " yo" }))
266+ (is (match?
267+ @invoked?
268+ [[{:role :user :content " test" }] test-chat-ctx]))))))
You can’t perform that action at this time.
0 commit comments