Skip to content

Commit 18a29be

Browse files
committed
fix(responses): backfill empty chat completion output
1 parent 096e394 commit 18a29be

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

lib/codex_pooler/gateway/openai_compatibility/responses/sse.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ defmodule CodexPooler.Gateway.OpenAICompatibility.Responses.SSE do
7171
end
7272
end
7373

74-
defp maybe_backfill_output(%{"output" => output} = response, _events) when is_list(output),
75-
do: response
74+
defp maybe_backfill_output(%{"output" => output} = response, _events)
75+
when is_list(output) and output != [],
76+
do: response
7677

7778
defp maybe_backfill_output(response, events) do
7879
output_items =

test/codex_pooler_web/controllers/v1/chat_completions_controller_test.exs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,11 @@ defmodule CodexPoolerWeb.V1.ChatCompletionsControllerTest do
154154
{"response.completed",
155155
%{
156156
"type" => "response.completed",
157-
"response" => %{"id" => "resp_chat_delta_collect", "status" => "completed"}
157+
"response" => %{
158+
"id" => "resp_chat_delta_collect",
159+
"status" => "completed",
160+
"output" => []
161+
}
158162
}}
159163
])
160164
)

0 commit comments

Comments
 (0)