Skip to content

Bsb/py catch up#24

Merged
bsbodden merged 6 commits intomainfrom
bsb/py-catch-up
Mar 16, 2026
Merged

Bsb/py catch up#24
bsbodden merged 6 commits intomainfrom
bsb/py-catch-up

Conversation

@bsbodden
Copy link
Collaborator

@bsbodden bsbodden commented Mar 16, 2026

Catch-up with recent redis-vl-python changes to maintain feature parity.

  • Configurable max_distance in MultiVectorQuery — Replace hardcoded DISTANCE_THRESHOLD=2.0 with per-Vector maxDistance field (validated 0.0–2.0). Changes range query join from | to AND to match
    upstream. (Python commit 61f0f41)
  • ChatRole enum and count() for message history — Add ChatRole enum (USER, ASSISTANT, SYSTEM, TOOL) as single source of truth for role validation, with backward-compatible acceptance of deprecated
    "llm" role. Add count()/count(sessionTag) to MessageHistory and SemanticMessageHistory using CountQuery. (Python commits 23ecc77, e7301a2)
  • toString() on core public classes — Add human-readable toString() to SearchIndex, SemanticCache, LangCacheSemanticCache, SemanticRouter, MessageHistory, and SemanticMessageHistory. (Python commit
    e285fed)

Note

Medium Risk
Changes multi-vector search query construction (per-vector maxDistance and AND-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 joining VECTOR_RANGE clauses with AND rather than |.

Adds a ChatRole enum for message-history role validation (accepting deprecated llm with a warning) and introduces count()/count(sessionTag) on message histories via CountQuery.

Adds human-readable toString() implementations for several public classes (SearchIndex, SemanticCache, LangCacheSemanticCache, SemanticRouter, MessageHistory, SemanticMessageHistory) with new unit/integration coverage for toString, role validation, message counts, and max-distance behavior.

Written by Cursor Bugbot for commit b983a9c. This will update automatically on new commits. Configure here.

…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-ci
Copy link

jit-ci bot commented Mar 16, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@bsbodden bsbodden self-assigned this Mar 16, 2026
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.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

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);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

@bsbodden bsbodden merged commit 0abb748 into main Mar 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant