Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Preserve hosted web search and image generation in Codex parallel requests without changing Lite routing.

## 0.161.2

- List the new OpenAI `gpt-6-sol`/`gpt-6-luna` models for ChatGPT OAuth accounts by bumping the Codex client version the backend gates on.
Expand Down
4 changes: 3 additions & 1 deletion src/eca/llm_providers/openai.clj
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,9 @@
(case body-projection
:codex-lite (codex-responses-lite-body body)
:codex-parallel (-> body
(update :tools #(filterv function-tool? %))
(update :tools #(filterv (fn [tool]
(or (function-tool? tool)
(#{"web_search" "image_generation"} (:type tool)))) %))
(update :reasoning #(assoc (or % {})
:context "all_turns")))
body))
Expand Down
46 changes: 45 additions & 1 deletion test/eca/llm_providers/openai_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@
(doseq [request @requests*]
(is (false? (:responses-lite? request)))
(is (= "test" (get-in request [:body :instructions])))
(is (= ["function"] (mapv :type (get-in request [:body :tools]))))
(is (= ["function" "web_search" "image_generation"] (mapv :type (get-in request [:body :tools]))))
(is (true? (get-in request [:body :parallel_tool_calls])))
(is (= "all_turns" (get-in request [:body :reasoning :context]))))
(is (= [["function_call" "call-1"]
Expand Down Expand Up @@ -980,6 +980,50 @@
(is (false? (get-in @request* [:body :parallel_tool_calls])))
(is (= "additional_tools" (get-in @request* [:body :input 0 :type]))))))))

(deftest create-response-codex-parallel-native-tools-retry-test
(let [requests* (atom [])
tools-called* (atom 0)
completed {:response {:status "completed" :output []
:usage {:input_tokens 1 :output_tokens 1}}}]
(with-redefs [llm-providers.openai/base-responses-request!
(fn [{:keys [on-stream on-error] :as opts}]
(case (count (swap! requests* conj opts))
1 (on-stream "response.completed"
(assoc-in completed [:response :output]
[{:type "function_call" :id "item-1" :call_id "call-1"
:name "eca__read_file" :arguments "{}"}]))
2 (on-error {:code "server_is_overloaded"})
3 (on-stream "response.completed" completed)))]
(llm-providers.openai/create-response!
(assoc (base-provider-params)
:provider "openai" :auth-type :auth/oauth
:web-search true :image-generation true :reason? true
:extra-payload {:parallel_tool_calls true}
:provider-data {:responses-lite? true :parallel-tool-calls? true
:parallel-tool-calls-without-lite? true
:default-reasoning-effort "low"})
(assoc (base-callbacks
{:on-tools-called (fn [_]
(swap! tools-called* inc)
{:new-messages [] :tools []})})
:retry-request (fn [{:keys [retry-fn attempt replay-safe?]}]
(is (true? replay-safe?))
(retry-fn (inc attempt)))))
(is (= 3 (count @requests*)))
(is (= 1 @tools-called*))
(is (= (mapv :body (rest @requests*))
(repeat 2 (:body (second @requests*)))))
(is (= [["function" "web_search" "image_generation"]
["web_search" "image_generation"]
["web_search" "image_generation"]]
(mapv #(mapv :type (get-in % [:body :tools])) @requests*)))
(doseq [request @requests*]
(is (false? (:responses-lite? request)))
(is (true? (get-in request [:body :parallel_tool_calls])))
(is (= {:effort "low" :summary "auto" :context "all_turns"}
(get-in request [:body :reasoning])))
(is (identical? (:turn-context (first @requests*)) (:turn-context request)))))))

(deftest create-response-codex-request-shapes-test
(testing "API-key requests ignore Codex-only Lite metadata, even for Lite models"
(let [request* (atom nil)]
Expand Down
Loading