Skip to content

fix multiround chat#4438

Open
CUHKSZzxy wants to merge 3 commits intoInternLM:mainfrom
CUHKSZzxy:fix-multiround-chat
Open

fix multiround chat#4438
CUHKSZzxy wants to merge 3 commits intoInternLM:mainfrom
CUHKSZzxy:fix-multiround-chat

Conversation

@CUHKSZzxy
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings March 20, 2026 12:17
@CUHKSZzxy CUHKSZzxy requested a review from lvhan028 March 20, 2026 12:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to fix multi-round chat handling in the multimodal prompt processor by preventing mutation of the original message payload while parsing multimodal items.

Changes:

  • Stop removing (pop-ing) the multimodal source fields (url / data) when extracting the media source in _parse_multimodal_item.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 112 to 114
item_params = item.get(item_type, {})
data_src = item_params.pop('url', None) or item_params.pop('data', None)
data_src = item_params.get('url', None) or item_params.get('data', None)

Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

Switching from pop() to get() avoids mutating the original message (good for multi-round reuse), but it also changes the parsed output: item_params will now still contain url/data and gets merged into the emitted content item via **item_params. This can unintentionally carry large base64 blobs downstream and may conflict with the reserved 'data' field (if item_params contains a 'data' key it will overwrite the parsed data). Consider making a shallow copy of the params and popping url/data from the copy so the input messages are not mutated while keeping the output schema the same as before.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

@CUHKSZzxy CUHKSZzxy Mar 20, 2026

Choose a reason for hiding this comment

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

Seems correct, item_params = item.get(item_type, {}).copy() is a shallow copy, won't be costly.
We should bring back this copy and pop out the potential long base64 string to avoid passing down in multiple rounds.
cc @lvhan028

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants