File tree Expand file tree Collapse file tree 3 files changed +16
-15
lines changed
Expand file tree Collapse file tree 3 files changed +16
-15
lines changed Original file line number Diff line number Diff line change 22
33## Unreleased
44
5+ - Fix custom tools output to return stderr when tool error. #219
6+
57## 0.82.0
68
79- Support nested folder for rules and commands. #220
Original file line number Diff line number Diff line change 3636 err (some-> (:err result) string/trim)
3737 out (some-> (:out result) string/trim)]
3838 (logger/debug logger-tag " custom tool executed:" result)
39- (if (zero? exit)
40- (tools.util/single-text-content out)
41- {:error true
42- :contents (remove nil?
43- (concat [{:type :text
44- :text (str " Exit code " exit)}]
45- (when-not (string/blank? err)
46- [{:type :text
47- :text (str " Stderr:\n " err)}])
48- (when-not (string/blank? out)
49- [{:type :text
50- :text (str " Stdout:\n " out)}])))}))))
39+ {:error (not= 0 exit)
40+ :contents (remove nil?
41+ (concat [(when (not= 0 exit)
42+ {:type :text
43+ :text (str " Exit code " exit)})]
44+ (when-not (string/blank? err)
45+ [{:type :text
46+ :text (str " Stderr:\n " err)}])
47+ (when-not (string/blank? out)
48+ [{:type :text
49+ :text (str " Stdout:\n " out)}])))})))
5150
5251(defn ^:private custom-tool->tool-def
5352 " Transforms a single custom tool from the config map into a full tool definition."
Original file line number Diff line number Diff line change 2121 custom-tool-def (get custom-defs " file-search" )]
2222 (is (some? custom-tool-def) " The custom tool should be loaded." )
2323 (let [result ((:handler custom-tool-def) {" directory" " /tmp" " pattern" " *.clj" } {})]
24- (is (= {:contents [{:text " mocked -output" , :type :text }], :error false } result) " The tool should return the mocked shell output." )))))))
24+ (is (= {:contents [{:text " Stdout: \n mocked -output" , :type :text }], :error false } result) " The tool should return the mocked shell output." )))))))
2525
2626 (testing " when multiple tools are configured"
2727 (let [mock-custom-tools {" git-status"
4242 echo-handler (get-in custom-defs [" echo-message" :handler ])]
4343 (is (some? git-status-handler) " Git status tool should be loaded." )
4444 (is (some? echo-handler) " Echo message tool should be loaded." )
45- (is (= {:contents [{:text " On branch main" , :type :text }], :error false } (git-status-handler {} {})))
46- (is (= {:contents [{:text " Hello World" , :type :text }], :error false } (echo-handler {" message" " Hello World" } {})))))))
45+ (is (= {:contents [{:text " Stdout: \n On branch main" , :type :text }], :error false } (git-status-handler {} {})))
46+ (is (= {:contents [{:text " Stdout: \n Hello World" , :type :text }], :error false } (echo-handler {" message" " Hello World" } {})))))))
4747
4848 (testing " when the custom tools config is empty or missing"
4949 (testing " with an empty map"
You can’t perform that action at this time.
0 commit comments