|
257 | 257 | (is (= [] |
258 | 258 | (#'llm-providers.openai/normalize-messages |
259 | 259 | [{:role "image_generation_call" :content {:base64 "DDD"}}] |
260 | | - false))))) |
| 260 | + false)))) |
| 261 | + (testing "server web search history artifacts are skipped on replay" |
| 262 | + (is (match? |
| 263 | + [{:role "assistant" |
| 264 | + :content [{:type "output_text" :text "Found the answer."}]}] |
| 265 | + (#'llm-providers.openai/normalize-messages |
| 266 | + [{:role "server_tool_use" |
| 267 | + :content {:id "ws_1" :name "web_search" :input {:query "latest news"}}} |
| 268 | + {:role "server_tool_result" |
| 269 | + :content {:tool-use-id "ws_1" :raw-content nil}} |
| 270 | + {:role "assistant" |
| 271 | + :content [{:type :text :text "Found the answer."}]}] |
| 272 | + true))))) |
261 | 273 |
|
262 | 274 | (defn- base-provider-params [] |
263 | 275 | {:model "gpt-test" |
|
382 | 394 | :output "ok\n"} |
383 | 395 | (first out))))))) |
384 | 396 |
|
385 | | -(deftest ->tools-image-generation-test |
386 | | - (testing "image_generation tool is appended when flag is on and not on codex path" |
| 397 | +(deftest ->tools-built-in-tools-test |
| 398 | + (testing "image_generation tool is appended when flag is on" |
387 | 399 | (is (match? |
388 | 400 | [{:type "image_generation" :output_format "png"}] |
389 | | - (#'llm-providers.openai/->tools [] false true false)))) |
| 401 | + (#'llm-providers.openai/->tools [] false true)))) |
390 | 402 | (testing "image_generation tool is NOT appended when flag is off" |
391 | 403 | (is (= [] |
392 | | - (#'llm-providers.openai/->tools [] false false false)))) |
393 | | - (testing "image_generation tool is NOT appended on codex path even if flag is on" |
394 | | - (is (= [] |
395 | | - (#'llm-providers.openai/->tools [] false true true)))) |
| 404 | + (#'llm-providers.openai/->tools [] false false)))) |
396 | 405 | (testing "image_generation tool sits alongside web_search and function tools" |
397 | 406 | (is (match? |
398 | 407 | [{:type "function" :name "eca__foo"} |
399 | | - {:type "web_search_preview"} |
| 408 | + {:type "web_search"} |
400 | 409 | {:type "image_generation" :output_format "png"}] |
401 | 410 | (#'llm-providers.openai/->tools |
402 | 411 | [{:full-name "eca__foo" :description "d" :parameters {}}] |
403 | | - true true false))))) |
| 412 | + true true))))) |
| 413 | + |
| 414 | +(deftest create-response-oauth-preserves-built-in-tools-test |
| 415 | + (testing "OAuth requests keep web_search and image_generation when capabilities are enabled" |
| 416 | + (let [requests* (atom [])] |
| 417 | + (with-redefs [llm-providers.openai/base-responses-request! |
| 418 | + (fn [{:keys [on-stream] :as opts}] |
| 419 | + (swap! requests* conj opts) |
| 420 | + (on-stream "response.completed" |
| 421 | + {:response {:output [] |
| 422 | + :usage {:input_tokens 0 :output_tokens 0} |
| 423 | + :status "completed"}}))] |
| 424 | + (llm-providers.openai/create-response! |
| 425 | + (assoc (base-provider-params) |
| 426 | + :auth-type :auth/oauth |
| 427 | + :web-search true |
| 428 | + :image-generation true) |
| 429 | + (base-callbacks {})) |
| 430 | + (is (match? [{:type "function"} |
| 431 | + {:type "web_search"} |
| 432 | + {:type "image_generation" :output_format "png"}] |
| 433 | + (get-in (first @requests*) [:body :tools]))))))) |
404 | 434 |
|
405 | 435 | (deftest create-response-image-generation-tool-on-request-test |
406 | 436 | (testing "request body includes image_generation tool when :image-generation is true" |
|
0 commit comments