Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

fix: guard against missing choices (#817)

Pranav19262f632f8d
diff --git a/codex-cli/src/utils/responses.ts b/codex-cli/src/utils/responses.ts
index 6a763ebfa0..f0586ba4c4 100644
--- a/codex-cli/src/utils/responses.ts
+++ b/codex-cli/src/utils/responses.ts
@@ -487,7 +487,7 @@ async function* streamResponses(
let isToolCall = false;
for await (const chunk of completion as AsyncIterable<OpenAI.ChatCompletionChunk>) {
// console.error('\nCHUNK: ', JSON.stringify(chunk));
- const choice = chunk.choices[0];
+ const choice = chunk.choices?.[0];
if (!choice) {
continue;
}