Skip to content

Commit cdf9e28

Browse files
committed
Fix config for customTools
1 parent 15ef114 commit cdf9e28

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

docs/configuration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ __The `manualApproval` setting was deprecated and replaced by the `approval` one
160160

161161
## Custom Tools
162162

163-
You can define your own command-line tools that the LLM can use. These are configured via the `custom-tools` key in your `config.json`.
163+
You can define your own command-line tools that the LLM can use. These are configured via the `customTools` key in your `config.json`.
164164

165-
The `custom-tools` value is an object where each key is the name of your tool. Each tool definition has the following properties:
165+
The `customTools` value is an object where each key is the name of your tool. Each tool definition has the following properties:
166166

167167
- `description`: A clear description of what the tool does. This is crucial for the LLM to decide when to use it.
168168
- `command`: An array of strings representing the command and its static arguments.
@@ -176,7 +176,7 @@ Placeholders in the format `{{argument_name}}` within the `command` array will b
176176

177177
```javascript
178178
{
179-
"custom-tools": {
179+
"customTools": {
180180
"web-search": {
181181
"description": "Fetches the content of a URL and returns it in Markdown format.",
182182
"command": ["trafilatura", "--output-format=markdown", "-u", "{{url}}"],

src/eca/config.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@
202202
[:toolCall :approval :ask :ANY :argsMatchers]
203203
[:toolCall :approval :deny]
204204
[:toolCall :approval :deny :ANY :argsMatchers]
205+
[:customTools]
206+
[:customTools :ANY :schema :properties]
205207
[:mcpServers]]}
206208
(deep-merge initialization-config
207209
(when-not pure-config? (config-from-envvar))

src/eca/features/tools/custom.clj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@
2727
"Transforms a single custom tool from the config map into a full tool definition."
2828
[[tool-name tool-config]]
2929
(let [schema (:schema tool-config)]
30-
{(name tool-name)
31-
{:name (name tool-name)
30+
{tool-name
31+
{:name tool-name
3232
:description (:description tool-config)
3333
:parameters {:type "object"
34-
:properties (update-keys (:properties schema) keyword)
35-
:required (mapv keyword (:required schema))}
34+
:properties (:properties schema)
35+
:required (:required schema)}
3636
:handler (build-tool-fn tool-config)}}))
3737

3838
(defn definitions
3939
"Loads all custom tools from the config."
4040
[config]
41-
(->> (get config :custom-tools {})
41+
(->> (get config :customTools {})
4242
(map custom-tool->tool-def)
4343
(apply merge)))

test/eca/features/tools/custom_test.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
(with-redefs [process/sh (fn [command-vec & _]
1818
(is (= ["find" "/tmp" "-name" "*.clj"] command-vec))
1919
{:out "mocked-output" :exit 0})]
20-
(let [config {:custom-tools mock-custom-tools}
20+
(let [config {:customTools mock-custom-tools}
2121
custom-defs (f.tools.custom/definitions config)
2222
custom-tool-def (get custom-defs "file-search")]
2323
(is (some? custom-tool-def) "The custom tool should be loaded.")
@@ -37,7 +37,7 @@
3737
["git" "status"] {:out "On branch main" :exit 0}
3838
["echo" "Hello World"] {:out "Hello World" :exit 0}
3939
(is false "Unexpected command received by mock p/sh")))]
40-
(let [config {:custom-tools mock-custom-tools}
40+
(let [config {:customTools mock-custom-tools}
4141
custom-defs (f.tools.custom/definitions config)
4242
git-status-handler (get-in custom-defs ["git-status" :handler])
4343
echo-handler (get-in custom-defs ["echo-message" :handler])]
@@ -48,7 +48,7 @@
4848

4949
(testing "when the custom tools config is empty or missing"
5050
(testing "with an empty map"
51-
(let [config {:custom-tools {}}
51+
(let [config {:customTools {}}
5252
custom-defs (f.tools.custom/definitions config)]
5353
(is (empty? custom-defs) "No custom tools should be loaded.")))
5454
(testing "with the key missing from the config"

0 commit comments

Comments
 (0)