|
117 | 117 | thinking-start-tag |
118 | 118 | thinking-end-tag)))) |
119 | 119 |
|
120 | | - (testing "Reason messages - use reasoning_content if present, otherwise tags" |
121 | | - ;; Without :reasoning-content, uses think tags |
| 120 | + (testing "Reason messages - use reasoning_content if :delta-reasoning?, otherwise tags" |
| 121 | + ;; Without :delta-reasoning?, uses think tags |
122 | 122 | (is (match? |
123 | 123 | {:role "assistant" |
124 | 124 | :content [{:type "text" :text "<think>Reasoning...</think>"}]} |
|
128 | 128 | true |
129 | 129 | thinking-start-tag |
130 | 130 | thinking-end-tag))) |
131 | | - ;; With :reasoning-content, uses reasoning_content field |
| 131 | + ;; With :delta-reasoning?, uses reasoning_content field with :text value |
132 | 132 | (is (match? |
133 | 133 | {:role "assistant" |
134 | | - :reasoning_content "opaque"} |
| 134 | + :reasoning_content "Reasoning..."} |
135 | 135 | (#'llm-providers.openai-chat/transform-message |
136 | 136 | {:role "reason" |
137 | 137 | :content {:text "Reasoning..." |
138 | | - :reasoning-content "opaque"}} |
| 138 | + :delta-reasoning? true}} |
139 | 139 | true |
140 | 140 | thinking-start-tag |
141 | 141 | thinking-end-tag)))) |
|
193 | 193 | {:role "assistant" :reasoning_content "Thinking..."}]))))) |
194 | 194 |
|
195 | 195 | (deftest prune-history-test |
196 | | - (testing "Drops reason messages WITH reasoning-content before the last user message (DeepSeek)" |
| 196 | + (testing "Drops reason messages WITH :delta-reasoning? before the last user message (DeepSeek)" |
197 | 197 | (is (match? |
198 | 198 | [{:role "user" :content "Q1"} |
199 | 199 | {:role "assistant" :content "A1"} |
200 | 200 | {:role "user" :content "Q2"} |
201 | | - {:role "reason" :content {:text "r2" :reasoning-content "e2"}} |
| 201 | + {:role "reason" :content {:text "r2" :delta-reasoning? true}} |
202 | 202 | {:role "assistant" :content "A2"}] |
203 | 203 | (#'llm-providers.openai-chat/prune-history |
204 | 204 | [{:role "user" :content "Q1"} |
205 | | - {:role "reason" :content {:text "r1" :reasoning-content "e1"}} |
| 205 | + {:role "reason" :content {:text "r1" :delta-reasoning? true}} |
206 | 206 | {:role "assistant" :content "A1"} |
207 | 207 | {:role "user" :content "Q2"} |
208 | | - {:role "reason" :content {:text "r2" :reasoning-content "e2"}} |
| 208 | + {:role "reason" :content {:text "r2" :delta-reasoning? true}} |
209 | 209 | {:role "assistant" :content "A2"}])))) |
210 | 210 |
|
211 | | - (testing "Preserves reason messages WITHOUT reasoning-content (think-tag based)" |
| 211 | + (testing "Preserves reason messages WITHOUT :delta-reasoning? (think-tag based)" |
212 | 212 | (is (match? |
213 | 213 | [{:role "user" :content "Q1"} |
214 | 214 | {:role "reason" :content {:text "thinking..."}} |
|
249 | 249 | (deftest external-id-test |
250 | 250 | (testing "Tool call with external-id is preserved" |
251 | 251 | (is (match? |
252 | | - {:type :tool-call |
253 | | - :data {:id "call-123" |
254 | | - :type "function" |
255 | | - :function {:name "eca__get_weather" |
256 | | - :arguments "{\"location\":\"Paris\"}"} |
257 | | - :extra_content {:google {:thought_signature "signature-abc-123"}}}} |
| 252 | + {:role "assistant" |
| 253 | + :tool_calls [{:id "call-123" |
| 254 | + :type "function" |
| 255 | + :function {:name "eca__get_weather" |
| 256 | + :arguments "{\"location\":\"Paris\"}"} |
| 257 | + :extra_content {:google {:thought_signature "signature-abc-123"}}}]} |
258 | 258 | (#'llm-providers.openai-chat/transform-message |
259 | 259 | {:role "tool_call" |
260 | 260 | :content {:id "call-123" |
|
373 | 373 | (is (not @on-reason-called?) "on-reason should not be called when :id is nil")))) |
374 | 374 |
|
375 | 375 | (deftest deepseek-non-stream-reasoning-content-test |
376 | | - (testing "response-body->result captures reasoning_content and normalization preserves it" |
| 376 | + (testing "response-body->result captures reasoning_content and normalization uses :text with :delta-reasoning?" |
377 | 377 | (let [body {:usage {:prompt_tokens 5 :completion_tokens 2} |
378 | 378 | :choices [{:message {:content "hi" |
379 | 379 | :reasoning_content "think more"}}]} |
380 | 380 | result (#'llm-providers.openai-chat/response-body->result body (fn [& _])) |
| 381 | + ;; Simulate how chat.clj would store this: :text has the content, :delta-reasoning? is the flag |
381 | 382 | normalized (#'llm-providers.openai-chat/normalize-messages |
382 | 383 | [{:role "user" :content "Q"} |
383 | 384 | {:role "reason" :content {:id "r1" |
384 | | - :reasoning-content (:reasoning-content result)}}] |
| 385 | + :text (:reasoning-content result) |
| 386 | + :delta-reasoning? true}}] |
385 | 387 | true |
386 | 388 | thinking-start-tag |
387 | 389 | thinking-end-tag)] |
|
0 commit comments