Skip to content

Commit ef49a05

Browse files
ArthurHeymanseca
andcommitted
fix: escape backslashes in mock tool call argument paths for Windows
The OpenAI and OpenAI Chat mocks were sending file paths without proper JSON escaping. On Windows, paths contain backslashes that need to be escaped as \\\\ in JSON strings. 🤖 Generated with [eca](https://eca.dev) Co-Authored-By: eca <[email protected]>
1 parent 6c34971 commit ef49a05

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

integration-test/llm_mock/openai.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
(sse-send! ch "response.function_call_arguments.delta"
153153
{:type "response.function_call_arguments.delta"
154154
:item_id "item-1"
155-
:delta (str "h\":\"" (h/project-path->canon-path "resources") "\"}")})
155+
:delta (str "h\":\"" (h/json-escape-path (h/project-path->canon-path "resources")) "\"}")})
156156
;; Complete with the function call present so the client triggers tools
157157
(sse-send! ch "response.completed"
158158
{:type "response.completed"

integration-test/llm_mock/openai_chat.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
(send-sse! ch {:choices [{:delta {:tool_calls [{:index 0
115115
:function {:arguments "{\"pat"}}]}}]})
116116
(send-sse! ch {:choices [{:delta {:tool_calls [{:index 0
117-
:function {:arguments (str "h\":\"" path "\"}")}}]}}]})
117+
:function {:arguments (str "h\":\"" (h/json-escape-path path) "\"}")}}]}}]})
118118
(send-sse! ch {:usage {:prompt_tokens 5 :completion_tokens 30}})
119119
(send-sse! ch {:choices [{:delta {} :finish_reason "tool_calls"}]})
120120
(hk/close ch))

0 commit comments

Comments
 (0)