Conversation
…Query Add maxDistance field to Vector class (default 2.0, validated 0.0-2.0) replacing the hardcoded DISTANCE_THRESHOLD constant. Each vector in a multi-vector query can now specify its own distance threshold for VECTOR_RANGE. Also changes the range query join operator from "|" to "AND" to match upstream Python behavior. Port of redis-vl-python commit 61f0f41.
Add ChatRole enum (USER, ASSISTANT, SYSTEM, TOOL) as single source of truth for valid message roles. The deprecated "llm" role is still accepted with a warning for backward compatibility. Update BaseMessageHistory.validateRoles() to use ChatRole. Add count() and count(sessionTag) methods to MessageHistory and SemanticMessageHistory using CountQuery, allowing callers to get the number of stored messages without fetching them all. Port of redis-vl-python commits 23ecc77 and e7301a2.
Add human-readable toString() implementations to SearchIndex, SemanticCache, LangCacheSemanticCache, SemanticRouter, MessageHistory, and SemanticMessageHistory. Each displays key identifying fields (name, prefix, storage type, thresholds, etc.) without exposing sensitive data. Port of redis-vl-python commit e285fed.
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
core/src/main/java/com/redis/vl/extensions/messagehistory/MessageHistory.java
Show resolved
Hide resolved
Add integration tests matching Python redis-vl test coverage: - MessageHistoryCountIntegrationTest: count() for both standard and semantic message history (store, count, clear, session scoping) - MultiVectorQueryMaxDistanceIntegrationTest: per-vector max_distance filtering with parametrized thresholds, monotonicity, and distance verification against real Redis - Fix MultiVectorQueryIntegrationTest assertion for AND join
Move identical count()/count(sessionTag) implementations from MessageHistory and SemanticMessageHistory into the base class. Subclasses now provide getSearchIndex() and getDefaultSessionFilter() accessors instead of duplicating the query logic.
Replace %.1f format specifier with %s to avoid truncating user-provided maxDistance values. Previously, maxDistance(0.01) would produce "VECTOR_RANGE 0.0" (matching nothing) and maxDistance(0.05) would produce "VECTOR_RANGE 0.1" (doubling the intended radius). Add unit test verifying sub-decimal precision is preserved.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| "@%s:[VECTOR_RANGE %.1f $vector_%d]=>{$YIELD_DISTANCE_AS: distance_%d}", | ||
| v.getFieldName(), DISTANCE_THRESHOLD, i, i); | ||
| "@%s:[VECTOR_RANGE %s $vector_%d]=>{$YIELD_DISTANCE_AS: distance_%d}", | ||
| v.getFieldName(), v.getMaxDistance(), i, i); |
There was a problem hiding this comment.
Scientific notation in query string for small maxDistance
Medium Severity
Using %s to format the double maxDistance into the Redis query string calls Double.toString(), which produces scientific notation (e.g., "5.0E-4") for values below 0.001. Since the validation allows any value in [0.0, 2.0], a user setting maxDistance(0.0005) would generate a VECTOR_RANGE 5.0E-4 query fragment that Redis likely cannot parse, causing a query failure. The previous code used %.1f which always produced plain decimal output. A format like BigDecimal.valueOf(...).toPlainString() would preserve precision without risking scientific notation.


Catch-up with recent redis-vl-python changes to maintain feature parity.
upstream. (Python commit 61f0f41)
"llm" role. Add count()/count(sessionTag) to MessageHistory and SemanticMessageHistory using CountQuery. (Python commits 23ecc77, e7301a2)
e285fed)
Note
Medium Risk
Changes multi-vector search query construction (per-vector
maxDistanceandAND-joined range clauses), which can alter result sets and performance. Also adjusts message-history role validation and adds new counting APIs, which may affect callers relying on previous role strings or behavior.Overview
Catches up to recent redis-vl-python parity by changing multi-vector aggregation queries to use per-vector
maxDistance(validated 0.0–2.0) instead of a hardcoded threshold, and by joiningVECTOR_RANGEclauses withANDrather than|.Adds a
ChatRoleenum for message-history role validation (accepting deprecatedllmwith a warning) and introducescount()/count(sessionTag)on message histories viaCountQuery.Adds human-readable
toString()implementations for several public classes (SearchIndex,SemanticCache,LangCacheSemanticCache,SemanticRouter,MessageHistory,SemanticMessageHistory) with new unit/integration coverage fortoString, role validation, message counts, and max-distance behavior.Written by Cursor Bugbot for commit b983a9c. This will update automatically on new commits. Configure here.