Skip to content

Commit b9f9431

Browse files
committed
Fix args fill on tool call
1 parent 7d11acf commit b9f9431

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/eca/features/chat.clj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
user-prompt message
118118
all-tools (f.tools/all-tools @db* config)
119119
received-msgs* (atom "")
120+
tool-call-args-by-id* (atom {})
120121
add-to-history! (fn [msg]
121122
(swap! db* update-in [:chats chat-id :messages] (fnil conj []) msg))]
122123
(messenger/chat-content-received
@@ -180,6 +181,7 @@
180181
(finish-chat-prompt! chat-id :idle messenger db*))))
181182
:on-prepare-tool-call (fn [{:keys [id name arguments-text]}]
182183
(assert-chat-not-stopped! chat-id db* messenger)
184+
(swap! tool-call-args-by-id* update id str arguments-text)
183185
(messenger/chat-content-received
184186
messenger
185187
{:chat-id chat-id
@@ -188,7 +190,7 @@
188190
:content {:type :toolCallPrepare
189191
:name name
190192
:origin (tool-name->origin name all-tools)
191-
:arguments-text arguments-text
193+
:arguments-text (get @tool-call-args-by-id* id)
192194
:id id
193195
:manual-approval false}}))
194196
:on-tool-called (fn [{:keys [id name arguments] :as tool-call}]
@@ -210,6 +212,7 @@
210212
(reset! received-msgs* ""))
211213
(add-to-history! {:role "tool_call" :content tool-call})
212214
(add-to-history! {:role "tool_call_output" :content (assoc tool-call :output result)})
215+
(swap! tool-call-args-by-id* dissoc id)
213216
(messenger/chat-content-received
214217
messenger
215218
{:chat-id chat-id

0 commit comments

Comments
 (0)