Skip to content

Commit 3f1c855

Browse files
ericdalloeca-agent
andcommitted
Fix stale tool-call atom causing spurious retries on OpenAI responses
Clear tool-call-by-item-id* entries before the recursive base-responses-request! call, not after. The shared atom retained stale entries that the next response.completed fallback path would pick up, re-executing already-completed tool calls. 🤖 Generated with [eca](https://eca.dev) Co-Authored-By: eca <git@eca.dev>
1 parent 393a98a commit 3f1c855

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/eca/llm_providers/openai.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@
277277
:input-cache-read-tokens input-cache-read-tokens}))
278278
(if (seq tool-calls)
279279
(when-let [{:keys [new-messages tools]} (on-tools-called tool-calls)]
280+
(doseq [tool-call tool-calls]
281+
(swap! tool-call-by-item-id* dissoc (:item-id tool-call)))
280282
(base-responses-request!
281283
{:rid (llm-util/gen-rid)
282284
:body (assoc body
@@ -290,9 +292,7 @@
290292
:extra-headers extra-headers
291293
:auth-type auth-type
292294
:on-error on-error
293-
:on-stream handle-stream})
294-
(doseq [tool-call tool-calls]
295-
(swap! tool-call-by-item-id* dissoc (:item-id tool-call))))
295+
:on-stream handle-stream}))
296296
(on-message-received {:type :finish
297297
:finish-reason (-> data :response :status)})))
298298

0 commit comments

Comments
 (0)