fix(memory): skip file content parts unsupported by the target model in history replay - #41192
Open
engmohamedsalah wants to merge 2 commits into
Open
Conversation
…in history replay Conversation history rebuilt by TokenBufferMemory re-sent every past attachment as a native prompt content part regardless of what the invoked model supports. On models whose provider does not implement document input (e.g. Qwen served through vLLM), a follow-up turn in the same conversation failed with: 400 Unsupported chat content part type: 'file' Gate each converted history file on the model schema's declared features via AIModelEntity.supports_prompt_content_type() and degrade unsupported parts to a text note so earlier turns keep contributing context without breaking the request. Unresolvable model schemas fall back to the previous send-anywhere behavior. Fixes langgenius#41059
engmohamedsalah
requested review from
QuantumGhost and
laipz8200
as code owners
August 24, 2026 15:36
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.
Fixes #41059
Summary
When a conversation's second turn arrives,
TokenBufferMemoryreplays earlier turns and re-sends every past attachment as a native prompt content part — regardless of what the invoked model actually supports. On models whose provider does not implement document input (e.g. Qwen served via vLLM), the request fails with:This change gates each converted history file part on the model schema's declared features using the existing
AIModelEntity.supports_prompt_content_type()primitive:[Unsupported file type: document]) so earlier turns keep contributing context instead of breaking the requestCurrent-turn files are untouched; this only affects history replay.
Testing
tests/unit_tests/core/memory/test_token_buffer_memory.py:61 passedruff check+ruff format --checkclean