Skip to content

Commit 8fa68f0

Browse files
Serhan-Asadclaude
authored andcommitted
fix: deep copy formatted_messages to prevent Groq structured output mutation corrupting fallback models (#562)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4567570 commit 8fa68f0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pdd/llm_invoke.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Corrected code_under_test (llm_invoke.py)
22
# Added optional debugging prints in _select_model_candidates
33

4+
import copy
45
import os
56
import pandas as pd
67
import litellm
@@ -1971,7 +1972,7 @@ def calc_strength(candidate):
19711972
# --- 5. Prepare LiteLLM Arguments ---
19721973
litellm_kwargs: Dict[str, Any] = {
19731974
"model": model_name_litellm,
1974-
"messages": formatted_messages,
1975+
"messages": copy.deepcopy(formatted_messages),
19751976
# Use a local adjustable temperature to allow provider-specific fallbacks
19761977
"temperature": current_temperature,
19771978
# Retry on transient network errors (APIError, TimeoutError, ServiceUnavailableError)

0 commit comments

Comments
 (0)