Skip to content

fix: deep copy formatted_messages to prevent Groq message mutation (#562)#598

Merged
gltanaka merged 2 commits intomainfrom
fix/groq-message-mutation
Feb 24, 2026
Merged

fix: deep copy formatted_messages to prevent Groq message mutation (#562)#598
gltanaka merged 2 commits intomainfrom
fix/groq-message-mutation

Conversation

@gltanaka
Copy link
Contributor

Summary

  • Cherry-picks the fix from PR Groq structured output path mutates shared formatted_messages, corrupting fallback models #562 (Serhan-Asad/pdd) where Groq's structured output workaround mutates shared formatted_messages in-place, corrupting messages for fallback models
  • Adds copy.deepcopy(formatted_messages) before Groq's schema injection so the original messages remain untouched for subsequent model attempts
  • Includes 3 focused regression tests in TestGroqMessageMutation

Test plan

  • pytest -vv tests/test_llm_invoke.py::TestGroqMessageMutation — all 3 new tests pass
  • pytest -vv tests/test_llm_invoke.py — full file passes (231 tests, no regressions)

Closes #562

🤖 Generated with Claude Code

Serhan-Asad and others added 2 commits February 24, 2026 12:14
…utation corrupting fallback models (#562)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nvoke.py (#562)

Replace 770 lines across 2 standalone test files with 3 focused regression
tests (~80 lines) in the existing test_llm_invoke.py, per PR #591 review.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gltanaka gltanaka merged commit 0213ea7 into main Feb 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Groq structured output path mutates shared formatted_messages, corrupting fallback models

2 participants