Skip to content

fix(llm): isolate caller file messages - #6968

Open
ump45nose wants to merge 1 commit into
crewAIInc:mainfrom
ump45nose:fix/llm-file-message-isolation
Open

fix(llm): isolate caller file messages#6968
ump45nose wants to merge 1 commit into
crewAIInc:mainfrom
ump45nose:fix/llm-file-message-isolation

Conversation

@ump45nose

Copy link
Copy Markdown

Summary

Copy caller-supplied message dictionaries before LiteLLM file formatting can replace content or remove the files field.

Root cause

The LiteLLM sync and async paths passed the caller's message dictionaries directly to their file-processing helpers, which mutate those dictionaries. Reusing the same message list therefore dropped attachments after the first call.

Validation

  • uv run --with litellm --with anthropic pytest lib/crewai/tests/test_llm.py -k "does_not_mutate_file_messages" -q
  • uv run ruff format --check lib/crewai/src/crewai/llm.py lib/crewai/tests/test_llm.py
  • uv run ruff check lib/crewai/src/crewai/llm.py lib/crewai/tests/test_llm.py

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1233bf09-a678-4fd2-a43e-b8e6dc1a678f

📥 Commits

Reviewing files that changed from the base of the PR and between 28d868c and 3bbcd8d.

📒 Files selected for processing (2)
  • lib/crewai/src/crewai/llm.py
  • lib/crewai/tests/test_llm.py

📝 Walkthrough

Walkthrough

Changes

LLM message copy handling

Layer / File(s) Summary
Copy messages before processing
lib/crewai/src/crewai/llm.py
Synchronous and asynchronous call preparation shallow-copies list-based messages before file processing. String inputs keep their existing conversion behavior.
Validate message preservation
lib/crewai/tests/test_llm.py
Regression tests verify multimodal file conversion without mutation of the caller’s messages in synchronous and asynchronous calls.

Suggested reviewers: lucasgomide

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: isolating caller-supplied file messages in LLM handling.
Description check ✅ Passed The description explains the mutation bug, the synchronous and asynchronous fix, and the validation performed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ump45nose
ump45nose marked this pull request as ready for review August 12, 2026 06:57
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.

1 participant