Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions trl/trainer/grpo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ def _tokenize_prompts(self, prompts: list):
for message in prompt:
if isinstance(message["content"], list):
for part in message["content"]:
if isinstance(part, dict) and part.get("type") == "image":
if part["type"] == "image":
prompt_images.append(part["image"])
has_images = True
images.append(prompt_images if prompt_images else None)
Expand Down Expand Up @@ -1442,7 +1442,7 @@ def _get_tool_suffix_ids(self, tool_messages):
for msg in tool_messages:
if isinstance(msg.get("content"), list):
for part in msg["content"]:
if isinstance(part, dict) and part.get("type") == "image":
if part["type"] == "image":

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed fourth instance of the same guard pattern

Low Severity

The PR updates three of the four isinstance(part, dict) and part.get("type") == "image" checks but misses the identical pattern at grpo_trainer.py line 1660 inside the tool-call result handling. This leaves an inconsistency within the same file, violating the project rule that duplicated logic blocks must stay aligned and that not propagating a change across all copies is a bug.

Additional Locations (2)
Fix in Cursor Fix in Web

Triggered by project rule: ../.ai/AGENTS.md

Reviewed by Cursor Bugbot for commit 5775033. Configure here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this one left on purpose? @qgallouedec

tool_images.append(part["image"])

# Normalize string content in tool messages for VLM processors before either path.
Expand Down
2 changes: 1 addition & 1 deletion trl/trainer/rloo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ def _tokenize_prompts(self, prompts: list):
for message in prompt:
if isinstance(message["content"], list):
for part in message["content"]:
if isinstance(part, dict) and part.get("type") == "image":
if part["type"] == "image":
prompt_images.append(part["image"])
has_images = True
images.append(prompt_images if prompt_images else None)
Expand Down
Loading