Skip to content
Open
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
7 changes: 7 additions & 0 deletions pipelinerl/async_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ async def llm_async_generate(

assert response_data is not None, "response_data is None"

# A malformed or error response (e.g. an HTTP 200 carrying an error body, or an empty payload)
# can lack "choices"; treat it as retryable instead of crashing the actor loop with a KeyError.
if not response_data.get("choices"):
raise RetryableAbortedCompletionError(
f"Completion response for prompt {prompt.id} is missing 'choices': {response_data}"
)

try:
content = response_data["choices"][0]["message"]["content"]
raw_tool_calls = response_data["choices"][0]["message"].get("tool_calls", [])
Expand Down