fix(python): scope VLM modality check to the current turn#1132
Closed
Mengsheng Wu (mengshengwu) wants to merge 1 commit into
Closed
fix(python): scope VLM modality check to the current turn#1132Mengsheng Wu (mengshengwu) wants to merge 1 commit into
Mengsheng Wu (mengshengwu) wants to merge 1 commit into
Conversation
The pre-generate guard scanned the full history for image/audio blocks, which broke any second turn of a VLM chat that started with media: the prior turn's block was still present in messages, so generate(images=[]) raised even though the current user turn was text-only. Go CLI / server already extract media only from the last message; align Python with that.
Contributor
Author
|
Superseded by #1130 which fixes the same bug plus a related test ordering issue. Regression tests from this PR have been ported over. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1131
Summary
_messages_have_modalitywalked the full chat history when deciding whether the pre-generate()guard should fire; it now inspects only the last message, matching how the Go CLI / server extract media (only from the current turn).Test plan
_messages_have_modalityreturnsFalsewhen only prior turns hold{type: image}/{type: audio}blocks and the current turn is text-only (newtest_messages_have_modality_ignores_prior_turns)_messages_have_modalitystill fires on the current turn's media block (newtest_messages_have_modality_detects_current_turn)_messages_have_modality([], modality)returnsFalse(newtest_messages_have_modality_empty)pytest bindings/python/tests/unit/test_error_messages.py -q→ 25 passed