Skip to content

Commit 7d11acf

Browse files
committed
Fix arguments text when preparing tool call
1 parent fd02ef5 commit 7d11acf

File tree

7 files changed

+13
-11
lines changed

7 files changed

+13
-11
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Fix arguments test when preparing tool call.
6+
57
## 0.4.0
68

79
- Add support for global rules.

docs/protocol.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ interface ToolCallPrepareContent {
517517
/*
518518
* Argument text of this tool call
519519
*/
520-
argumentText: string;
520+
argumentsText: string;
521521

522522
/**
523523
* Whether this call requires manual approval from the user.
@@ -546,7 +546,7 @@ interface ToolCallRunContent {
546546
/*
547547
* Arguments of this tool call
548548
*/
549-
arguments: string[];
549+
arguments: {[key: string]: string};
550550

551551
/**
552552
* Whether this call requires manual approval from the user.

src/eca/features/chat.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
:finish (do
179179
(add-to-history! {:role "assistant" :content @received-msgs*})
180180
(finish-chat-prompt! chat-id :idle messenger db*))))
181-
:on-prepare-tool-call (fn [{:keys [id name argument]}]
181+
:on-prepare-tool-call (fn [{:keys [id name arguments-text]}]
182182
(assert-chat-not-stopped! chat-id db* messenger)
183183
(messenger/chat-content-received
184184
messenger
@@ -188,7 +188,7 @@
188188
:content {:type :toolCallPrepare
189189
:name name
190190
:origin (tool-name->origin name all-tools)
191-
:argumentText argument
191+
:arguments-text arguments-text
192192
:id id
193193
:manual-approval false}}))
194194
:on-tool-called (fn [{:keys [id name arguments] :as tool-call}]

src/eca/llm_providers/anthropic.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"tool_use" (do
105105
(on-prepare-tool-call {:name (-> data :content_block :name)
106106
:id (-> data :content_block :id)
107-
:argumentsText ""})
107+
:arguments-text ""})
108108
(swap! content-block* assoc (:index data) (:content_block data)))
109109

110110
nil)
@@ -116,7 +116,7 @@
116116
content-block (get @content-block* (:index data))]
117117
(on-prepare-tool-call {:name (:name content-block)
118118
:id (:id content-block)
119-
:argumentsText text}))
119+
:arguments-text text}))
120120
"citations_delta" (case (-> data :delta :citation :type)
121121
"web_search_result_location" (on-message-received
122122
{:type :url

src/eca/llm_providers/ollama.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
tool-call {:id call-id
9797
:name (:name function)
9898
:arguments (:arguments function)}]
99-
(on-prepare-tool-call (assoc tool-call :argumentsText ""))
99+
(on-prepare-tool-call (assoc tool-call :arguments-text ""))
100100
(swap! tool-calls* assoc rid tool-call))
101101

102102
done_reason

src/eca/llm_providers/openai.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"response.function_call_arguments.delta" (let [call (get @mcp-call-by-item-id* (:item_id data))]
8686
(on-prepare-tool-call {:id (:id call)
8787
:name (:name call)
88-
:argumentsText (:delta data)}))
88+
:arguments-text (:delta data)}))
8989

9090
"response.output_item.done"
9191
(case (:type (:item data))
@@ -124,7 +124,7 @@
124124
(swap! mcp-call-by-item-id* assoc item-id {:name name :id call-id})
125125
(on-prepare-tool-call {:id (-> data :item :call_id)
126126
:name (-> data :item :name)
127-
:argumentsText (-> data :item :arguments)}))
127+
:arguments-text (-> data :item :arguments)}))
128128
nil)
129129

130130
;; done

test/eca/features/chat_test.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ for allowed directories and then list files"
212212
(on-first-response-received {:type :text :text "Ok,"})
213213
(on-message-received {:type :text :text "Ok,"})
214214
(on-message-received {:type :text :text " working on it"})
215-
(on-prepare-tool-call {:id "call-1" :name "list_allowed_directories" :argumentsText ""})
215+
(on-prepare-tool-call {:id "call-1" :name "list_allowed_directories" :arguments-text ""})
216216
(on-tool-called {:id "call-1" :name "list_allowed_directories" :arguments {}})
217217
(on-message-received {:type :text :text "I can see: \n"})
218218
(on-message-received {:type :text :text "/foo/bar"})
@@ -237,7 +237,7 @@ for allowed directories and then list files"
237237
{:role :system :content {:type :progress :state :running :text "Generating"}}
238238
{:role :assistant :content {:type :text :text "Ok,"}}
239239
{:role :assistant :content {:type :text :text " working on it"}}
240-
{:role :assistant :content {:type :toolCallPrepare :id "call-1" :name "list_allowed_directories" :argumentText nil :manual-approval false}}
240+
{:role :assistant :content {:type :toolCallPrepare :id "call-1" :name "list_allowed_directories" :arguments-text "" :manual-approval false}}
241241
{:role :assistant :content {:type :toolCallRun :id "call-1" :name "list_allowed_directories" :arguments {} :manual-approval false}}
242242
{:role :assistant :content {:type :toolCalled :id "call-1" :name "list_allowed_directories" :arguments {} :outputs [{:content "Allowed directories: /foo/bar" :error false :type :text}]}}
243243
{:role :assistant :content {:type :text :text "I can see: \n"}}

0 commit comments

Comments
 (0)