Skip to content

Commit 22591b1

Browse files
committed
Fix require-approval-fn
1 parent f358412 commit 22591b1

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/eca/features/tools.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@
159159
all-tools))
160160
{:keys [allow ask byDefault]} (get-in config [:toolCall :approval])]
161161
(cond
162-
require-approval-fn
163-
(require-approval-fn args {:db db})
162+
(and require-approval-fn (require-approval-fn args {:db db}))
163+
true
164164

165165
(some #(approval-matches? % server tool-call-name args) ask)
166166
true

test/eca/features/tools_test.clj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
{:name "download" :server "web"}]]
7373
(testing "tool has require-approval-fn which returns true"
7474
(is (true? (f.tools/manual-approval? all-tools "eca_shell" {} {} {}))))
75-
(testing "tool has require-approval-fn which returns false"
76-
(is (false? (f.tools/manual-approval? all-tools "eca_plan" {} {} {}))))
75+
(testing "tool has require-approval-fn which returns false we ignore it"
76+
(is (true? (f.tools/manual-approval? all-tools "eca_plan" {} {} {}))))
7777
(testing "if legacy-manual-approval present, considers it"
7878
(is (true? (f.tools/manual-approval? all-tools "request" {} {} {:toolCall {:manualApproval true}}))))
7979
(testing "if approval config is provided"
@@ -91,7 +91,9 @@
9191
{:toolCall {:approval {:allow {"web__request" {:argsMatchers {"url" [".*foo.*"]}}}}}}))))
9292
(testing "has arg and matches"
9393
(is (false? (f.tools/manual-approval? all-tools "request" {"url" "http://foo.com"} {}
94-
{:toolCall {:approval {:allow {"web__request" {:argsMatchers {"url" [".*foo.*"]}}}}}}))))
94+
{:toolCall {:approval {:allow {"web__request" {:argsMatchers {"url" [".*foo.*"]}}}}}})))
95+
(is (false? (f.tools/manual-approval? all-tools "request" {"url" "foobar"} {}
96+
{:toolCall {:approval {:allow {"web__request" {:argsMatchers {"url" ["foo.*"]}}}}}}))))
9597
(testing "has not that arg"
9698
(is (true? (f.tools/manual-approval? all-tools "request" {"crazy-url" "http://foo.com"} {}
9799
{:toolCall {:approval {:allow {"web__request" {:argsMatchers {"url" [".*foo.*"]}}}}}}))))))

0 commit comments

Comments
 (0)