|
259 | 259 | {:role "assistant" :reasoning_content "Thinking..."}]))))) |
260 | 260 |
|
261 | 261 | (deftest prune-history-test |
262 | | - (testing "Drops all reason messages before the last user message by default" |
| 262 | + (testing "reasoningHistory \"turn\" drops all reason messages before the last user message" |
263 | 263 | (is (match? |
264 | 264 | [{:role "user" :content "Q1"} |
265 | 265 | {:role "assistant" :content "A1"} |
|
273 | 273 | {:role "user" :content "Q2"} |
274 | 274 | {:role "reason" :content {:text "r2" :delta-reasoning? true}} |
275 | 275 | {:role "assistant" :content "A2"}] |
276 | | - false)))) |
| 276 | + :turn)))) |
277 | 277 |
|
278 | | - (testing "Preserves reason messages (without :delta-reasoning?) before last user message" |
| 278 | + (testing "reasoningHistory \"turn\" also drops think-tag reasoning before last user message" |
279 | 279 | (is (match? |
280 | 280 | [{:role "user" :content "Q1"} |
281 | 281 | {:role "assistant" :content "A1"} |
282 | 282 | {:role "user" :content "Q2"} |
| 283 | + {:role "reason" :content {:text "more thinking..."}} |
283 | 284 | {:role "assistant" :content "A2"}] |
284 | 285 | (#'llm-providers.openai-chat/prune-history |
285 | 286 | [{:role "user" :content "Q1"} |
|
288 | 289 | {:role "user" :content "Q2"} |
289 | 290 | {:role "reason" :content {:text "more thinking..."}} |
290 | 291 | {:role "assistant" :content "A2"}] |
291 | | - false)))) |
| 292 | + :turn)))) |
292 | 293 |
|
293 | | - (testing "Preserves all reasoning when keep-history-reasoning is true (Bedrock)" |
| 294 | + (testing "reasoningHistory \"all\" preserves all reasoning" |
294 | 295 | (is (match? |
295 | 296 | [{:role "user" :content "Q1"} |
296 | 297 | {:role "reason" :content {:text "r1"}} |
|
305 | 306 | {:role "user" :content "Q2"} |
306 | 307 | {:role "reason" :content {:text "r2"}} |
307 | 308 | {:role "assistant" :content "A2"}] |
308 | | - true)))) |
| 309 | + :all)))) |
309 | 310 |
|
310 | | - (testing "No user message leaves list unchanged" |
| 311 | + (testing "reasoningHistory \"off\" removes all reasoning messages" |
| 312 | + (is (match? |
| 313 | + [{:role "user" :content "Q1"} |
| 314 | + {:role "assistant" :content "A1"} |
| 315 | + {:role "user" :content "Q2"} |
| 316 | + {:role "assistant" :content "A2"}] |
| 317 | + (#'llm-providers.openai-chat/prune-history |
| 318 | + [{:role "user" :content "Q1"} |
| 319 | + {:role "reason" :content {:text "r1" :delta-reasoning? true}} |
| 320 | + {:role "assistant" :content "A1"} |
| 321 | + {:role "user" :content "Q2"} |
| 322 | + {:role "reason" :content {:text "r2"}} |
| 323 | + {:role "assistant" :content "A2"}] |
| 324 | + :off)))) |
| 325 | + |
| 326 | + (testing "No user message - reasoningHistory \"turn\" leaves list unchanged" |
311 | 327 | (let [msgs [{:role "assistant" :content "A"} |
312 | 328 | {:role "reason" :content {:text "r"}}]] |
313 | | - (is (= msgs (#'llm-providers.openai-chat/prune-history msgs false)))))) |
| 329 | + (is (= msgs (#'llm-providers.openai-chat/prune-history msgs :turn))))) |
| 330 | + |
| 331 | + (testing "No user message - reasoningHistory \"off\" removes reason" |
| 332 | + (is (match? |
| 333 | + [{:role "assistant" :content "A"}] |
| 334 | + (#'llm-providers.openai-chat/prune-history |
| 335 | + [{:role "assistant" :content "A"} |
| 336 | + {:role "reason" :content {:text "r"}}] |
| 337 | + :off))))) |
314 | 338 |
|
315 | 339 | (deftest valid-message-test |
316 | 340 | (testing "Tool messages are always kept" |
|
0 commit comments