perf(checkpoint): eliminate json.dumps fallback by using orjson default handler #112
  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.
  
    
  
    
Description
Fixes #111 - Similar to #109
This PR fixes a bug in
JsonPlusRedisSerializer.dumps()that caused aTypeErrorwhen serializing LangChain message objects (e.g.,HumanMessage,AIMessage,SystemMessage).Changes
dumps()method:Replaced the call to non-existent
super().dumps()withorjson.dumps()usingdefault=self._default, which properly handles LangChain object serialization.loads()method:Enhanced error handling to gracefully fall back to
msgpackand other formats when JSON parsing fails.Introduced
tests/test_jsonplus_serializer_default_handler.pyto validate:dumps()/loads()anddumps_typed()/loads_typed()Root Cause
The previous implementation attempted to call
super().dumps()whenorjson.dumps(obj)raised aTypeError.However, the parent class
JsonPlusSerializerdoes not define adumps()method, so LangChain objects always failed to serialize.Solution
Use the existing
_defaulthandler from the parentJsonPlusSerializerclass withorjson:This leverages the parent class’s LangChain serialization logic while maintaining orjson’s performance benefits.
Testing
pytestAll tests pass, confirming that LangChain message objects now serialize and deserialize correctly.