Skip to content

Commit 9cbd222

Browse files
authored
Fix Claude tool use with empty arguments (#171) (#172)
* (llm-provider-collect-streaming-tool-uses): Handle case where Claude returns the empty string for tool use arguments.
1 parent 3e209ee commit 9cbd222

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Diff for: llm-claude.el

+5-3
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,11 @@ DATA is a vector of lists produced by `llm-provider-streaming-media-handler'."
208208
(concat (llm-provider-utils-tool-use-args tool) input)))))
209209
(maphash (lambda (_ tool)
210210
(condition-case nil
211-
(setf (llm-provider-utils-tool-use-args tool)
212-
(json-parse-string (llm-provider-utils-tool-use-args tool)
213-
:object-type 'alist))
211+
(let ((args (llm-provider-utils-tool-use-args tool)))
212+
(setf (llm-provider-utils-tool-use-args tool)
213+
(if (string-empty-p args)
214+
nil
215+
(json-parse-string args :object-type 'alist))))
214216
(error nil))
215217
(push tool result))
216218
tools)

0 commit comments

Comments
 (0)