Skip to content

Commit 5c7874f

Browse files
committed
Fix args streaming for toolCallPrepare
1 parent aa281a3 commit 5c7874f

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
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 args streaming in toolCallPrepare to not repeat the args. https://github.com/editor-code-assistant/eca-nvim/issues/28
6+
57
## 0.29.0
68

79
- Add editor tools to retrieve information like diagnostics. #56

docs/protocol.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,8 @@ interface UsageContent {
547547

548548
/**
549549
* Tool call that LLM is preparing to execute.
550+
* This will be sent multiple times for same tool id for each time LLM outputs
551+
* a part of the arg, so clients should append the arguments to UI.
550552
*/
551553
interface ToolCallPrepareContent {
552554
type: 'toolCallPrepare';
@@ -587,7 +589,7 @@ interface ToolCallPrepareContent {
587589
}
588590

589591
/**
590-
* Tool call final request that LLM may trigger.
592+
* Tool call final request that LLM may trigger, sent once per id.
591593
*/
592594
interface ToolCallRunContent {
593595
type: 'toolCallRun';
@@ -628,7 +630,7 @@ interface ToolCallRunContent {
628630
}
629631

630632
/**
631-
* Tool call result that LLM trigerred and was executed already.
633+
* Tool call result that LLM trigerred and was executed already, sent once per id.
632634
*/
633635
interface ToolCalledContent {
634636
type: 'toolCalled';
@@ -683,6 +685,9 @@ interface ToolCalledContent {
683685
details?: ToolCallDetails;
684686
}
685687

688+
/**
689+
* Tool call rejected, sent once per id.
690+
*/
686691
interface ToolCallRejected {
687692
type: 'toolCallRejected';
688693

src/eca/features/chat.clj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@
116116
all-tools (f.tools/all-tools behavior @db* config)
117117
received-msgs* (atom "")
118118
received-thinking* (atom "")
119-
tool-call-by-id* (atom {:args {}})
120119
add-to-history! (fn [msg]
121120
(swap! db* update-in [:chats chat-id :messages] (fnil conj []) msg))]
122121

@@ -165,13 +164,12 @@
165164
(finish-chat-prompt! :idle chat-ctx))))
166165
:on-prepare-tool-call (fn [{:keys [id name arguments-text]}]
167166
(assert-chat-not-stopped! chat-ctx)
168-
(swap! tool-call-by-id* update-in [id :args] str arguments-text)
169167
(send-content! chat-ctx :assistant
170168
(assoc-some
171169
{:type :toolCallPrepare
172170
:name name
173171
:origin (tool-name->origin name all-tools)
174-
:arguments-text (get-in @tool-call-by-id* [id :args])
172+
:arguments-text arguments-text
175173
:id id
176174
:manual-approval (f.tools/manual-approval? name config)}
177175
:summary (f.tools/tool-call-summary all-tools name nil))))
@@ -248,8 +246,7 @@
248246
:reason :user
249247
:id id}
250248
:details details
251-
:summary summary))))
252-
(swap! tool-call-by-id* dissoc id)))))]
249+
:summary summary))))))))]
253250
;; Wait all tool calls to complete before returning
254251
(run! deref calls)
255252
(send-content! chat-ctx :system {:type :progress :state :running :text "Generating"})

0 commit comments

Comments
 (0)