Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

fix: guard against empty choices in OpenAI and AstraFlow LLM providers

Your Namecc62e89152fe
diff --git a/src/llm/providers/astraflow.py b/src/llm/providers/astraflow.py
index ba23517fe..1a5897132 100644
--- a/src/llm/providers/astraflow.py
+++ b/src/llm/providers/astraflow.py
@@ -79,6 +79,8 @@ class _AstraflowBaseProvider(LLMProvider):
params["tools"] = [tool.to_openai_tool() for tool in llm_input.tools]
response = self.client.chat.completions.create(**params)
+ if not response.choices or response.choices[0].message is None:
+ raise ValueError("LLM returned empty or filtered response")
choice = response.choices[0]
tool_calls = None
diff --git a/src/llm/providers/openai.py b/src/llm/providers/openai.py
index e4e7f8951..6b6f070cf 100644
--- a/src/llm/providers/openai.py
+++ b/src/llm/providers/openai.py
@@ -67,9 +67,11 @@ class OpenAIProvider(LLMProvider):
if input.max_tokens:
params["max_tokens"] = input.max_tokens
if input.tools:
- params["tools"] = [tool.to_openai_tool() for tool in input.tools]
+ params["tools"] = [tool.to_openai_tool() for tool in input.tools]
response = self.client.chat.completions.create(**params)
+ if not response.choices or response.choices[0].message is None:
+ raise ValueError("LLM returned empty or filtered response")
choice = response.choices[0]
tool_calls = None