Python: Bug fix for Redis TypeError#2411
Merged
eavanvalkenburg merged 1 commit intomicrosoft:mainfrom Nov 24, 2025
Merged
Conversation
victordibia
approved these changes
Nov 24, 2025
Member
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in ChatMessageStoreState.__init__() where a TypeError was raised when messages parameter was None or empty. This occurred when using RedisChatMessageStore with AgentThread.serialize() because Redis stores don't include a messages field in their serialized state.
- Fixed the TypeError by adding an early return after handling None/empty messages
- Added comprehensive test coverage for the None and empty messages scenarios
- Added integration test to verify the fix works with RedisChatMessageStore and AgentThread
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| python/packages/core/agent_framework/_threads.py | Added early return in ChatMessageStoreState.__init__() after handling None/empty messages to prevent TypeError |
| python/packages/core/tests/core/test_threads.py | Added unit tests for None messages, no messages argument, and AgentThreadState with store state without messages field |
| python/packages/redis/tests/test_redis_chat_message_store.py | Added integration test to verify RedisChatMessageStore can be serialized within an AgentThread |
eavanvalkenburg
approved these changes
Nov 24, 2025
arisng
pushed a commit
to arisng/agent-framework
that referenced
this pull request
Feb 2, 2026
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.
Motivation and Context
When using
RedisChatMessageStorefor message storage and callingthread.serialize(), the following error occurs:The bug is in
ChatMessageStoreState.__init__()in_threadswhere in the constructor, the lineif not isinstance(messages, list):always runs, even ifmessagesisNone. WhenRedisChatMessageStore.serialize()returns a dict without a messages field (containing only thread_id, redis_url, etc.), the messages parameter defaults to None, triggering theTypeError.The fix is to add an early return after handling the empty/None case - no further processing is necessary because the incoming messages are
None.Description
Contribution Checklist