Skip to content

Commit dbd5bfb

Browse files
committed
Fix origin for tool calls
1 parent 7b03fd9 commit dbd5bfb

File tree

6 files changed

+15
-11
lines changed

6 files changed

+15
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- Add support for global rules.
6+
- Fix origin field of tool calls.
67

78
## 0.3.1
89

src/eca/features/chat.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@
195195
:request-id request-id
196196
:role :assistant
197197
:content {:type :toolCallRun
198+
:origin (:origin (first (filter #(= name (:name %)) all-tools)))
198199
:name name
199200
:arguments arguments
200201
:id id

src/eca/features/rules.clj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@
5656
(defn ^:private system-rules []
5757
[{:name "ECA System"
5858
:type :system
59-
:content (str "You are an expert AI coding tool called ECA (Editor Code Assistant)."
60-
"Your behavior is to '<behavior>'."
61-
"The chat is markdown mode.")}])
59+
:content (str "You are an expert AI coding tool called ECA (Editor Code Assistant). "
60+
"Your behavior is to '<behavior>'. "
61+
"The chat is markdown mode. "
62+
"When responding code blocks, pay attention to use valid markdown languages following Github markdown.")}])
6263

6364
(defn all [config roots variables]
6465
(mapv (fn [rule]

src/eca/features/tools.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
(vals (native-definitions db config))))
4040
mcp-tools (f.mcp/all-tools db)]
4141
(concat
42-
(mapv #(assoc % :source :native) native-tools)
43-
(mapv #(assoc % :source :mcp) mcp-tools))))
42+
(mapv #(assoc % :origin :native) native-tools)
43+
(mapv #(assoc % :origin :mcp) mcp-tools))))
4444

4545
(defn call-tool! [^String name ^Map arguments db config]
4646
(logger/info logger-tag (format "Calling tool '%s' with args '%s'" name arguments))

test/eca/features/rules_test.clj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
(testing "system rule replacement"
1414
(let [rules (f.rules/all {} [] vars)
1515
sys-rule (first (filter #(= :system (:type %)) rules))]
16-
(is (= (str "You are an expert AI coding tool called ECA (Editor Code Assistant)."
17-
"Your behavior is to 'MY-BEHAVIOR'."
18-
"The chat is markdown mode.")
16+
(is (= (str "You are an expert AI coding tool called ECA (Editor Code Assistant). "
17+
"Your behavior is to 'MY-BEHAVIOR'. "
18+
"The chat is markdown mode. "
19+
"When responding code blocks, pay attention to use valid markdown languages following Github markdown.")
1920
(:content sys-rule)))))
2021

2122
(testing "absolute config rule"

test/eca/features/tools_test.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
:description "eval code"
1515
:parameters {"type" "object"
1616
:properties {"code" {:type "string"}}}
17-
:source :mcp}])
17+
:origin :mcp}])
1818
(f.tools/all-tools {:mcp-clients {:clojureMCP
1919
{:tools [{:name "eval"
2020
:description "eval code"
@@ -26,7 +26,7 @@
2626
(m/embeds [{:name "eca_list_directory"
2727
:description string?
2828
:parameters some?
29-
:source :native}])
29+
:origin :native}])
3030
(f.tools/all-tools {} {:nativeTools {:filesystem {:enabled true}}}))))
3131
(testing "Do not include disabled native tools"
3232
(is (match?
@@ -37,7 +37,7 @@
3737
(m/embeds [{:name "eca_list_directory"
3838
:description (format "Only in %s" (h/file-path "/path/to/project/foo"))
3939
:parameters some?
40-
:source :native}])
40+
:origin :native}])
4141
(with-redefs [f.tools.filesystem/definitions {"eca_list_directory" {:description "Only in $workspaceRoots"
4242
:parameters {}}}]
4343
(f.tools/all-tools {:workspace-folders [{:name "foo" :uri (h/file-uri "file:///path/to/project/foo")}]}

0 commit comments

Comments
 (0)