Add Node.js agent templates and unlock JavaScript in agent builder#3374
Add Node.js agent templates and unlock JavaScript in agent builder#3374mich-elle-luna wants to merge 4 commits into
Conversation
Add conversational and recommendation agent templates using node-redis v4 with Redis Search for vector-based message history and movie indexing. Conversational agent uses hybrid recent+semantic context retrieval, runtime embedding dimension validation, and a clear note on Redis version requirements. Recommendation agent parses genres from MovieLens CSV format into Redis TAGs, validates LLM query params against an explicit allowlist, skips dataset reload if the index is already warm, and filters genres in Redis rather than JS. Fix template URL to use root-relative path so local templates load in dev. Update agent builder to support JavaScript alongside Python. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
dwdougherty
left a comment
There was a problem hiding this comment.
Looks good to me, but I think somebody with more Node.js experience should take a look. I'll add Docs back into the review fray.
|
I got Claude to have a look and he found the following: Agent builder — JavaScript generation reviewFindings from auditing the JavaScript code generated by the agent builder on the Agent builder page. Templates live in static/code/agent-templates/javascript/; the substitution logic is agent-builder.js:529-560. What was checked: syntax of all 6 generated outputs (2 agent types × 3 models), template substitution correctness, Python ↔ JS parity, and runtime behaviour against Redis 8.2.1 (RediSearch + ReJSON loaded) with the OpenAI SDK stubbed. What was not checked: real LLM calls, the Anthropic and Llama3 variants end-to-end, the full MovieLens dataset (used a 5-movie synthetic seed), or non-OpenAI embedding behaviour. Critical — blocks fresh installs1.
|
- Fix deduplication bug: _getRecentMessages now zips Redis keys with json.mGet results so m._key is the actual key, not undefined - Fix recent-window arithmetic: lTrim and lRange now use RECENT_WINDOW * 2 (user + assistant per turn) instead of * 4 - Fix ft.dropIndex error-string match: replaced brittle catch with ft.info existence check to handle Redis 8 error wording - Fix num_docs field name: ft.info returns num_docs not numDocs, so _indexExists was always returning false and reloading data on every start - Fix Llama3 requiring LLM_API_KEY: default to 'no-key-needed' instead of throwing so local Ollama users don't need a dummy value - Hide Anthropic from JS model selector: JS templates use the OpenAI SDK which is not compatible with api.anthropic.com - Fix Jupyter button: always disabled (feature not yet available) - Fix generic JS fallback: use LLM_API_KEY and node-redis v4 socket shape Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix multi-word genre TAG queries: escape spaces as \\ so 'Science Fiction' matches as a single token rather than two separate terms in RediSearch - Fix reindex leaving stale data: use DD flag on ft.dropIndex to delete movie documents along with the index on reload - Fix Anthropic bypass: processModelSelection now checks allowedModels so typing 'anthropic' or 'claude' while on JavaScript is rejected with a clear message rather than generating broken code - Fix context messages out of order: sort combined recent + semantic results by key (which encodes timestamp) before passing to the LLM - Fix trimmed messages never deleted: evict and delete JSON documents for keys that will fall off the recent window before each lTrim call Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix hyphenated genres stripped from TAG query: allow hyphens through the sanitizer and backslash-escape them alongside spaces so Film-Noir matches the stored value instead of becoming FilmNoir - Fix zero minRating silently dropped: use != null instead of truthy check so a minimum rating of 0 is included in the filter query - Fix Llama/Ollama breaking semantic history: add separate embedder client (EMBEDDING_API_KEY / EMBEDDING_API_BASE_URL) that defaults to the LLM values so Ollama users just set EMBEDDING_MODEL=nomic-embed-text with no extra config, matching the pattern used in the RAG templates Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Reviewed by Cursor Bugbot for commit ec2044f. Configure here.
| : null, | ||
| minRating: typeof raw?.minRating === 'number' && raw.minRating >= 0 && raw.minRating <= 10 | ||
| ? raw.minRating | ||
| : null, |
There was a problem hiding this comment.
Movie rating scale mismatch
Medium Severity
The new recommendation template treats average ratings as a 0–10 scale in the LLM prompt, validation, and user-facing output, but avgRating is computed directly from MovieLens ratings_small.csv, where scores are on roughly a 0.5–5 star scale. Parsed minRating values in the 5–10 range (common when the model follows the prompt) produce Redis filters that match no documents, and results are labeled as “/10” even though values are not on that scale.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit ec2044f. Configure here.


Add conversational and recommendation agent templates using node-redis v4 with Redis Search for vector-based message history and movie indexing. Conversational agent uses hybrid recent+semantic context retrieval, runtime embedding dimension validation, and a clear note on Redis version requirements. Recommendation agent parses genres from MovieLens CSV format into Redis TAGs, validates LLM query params against an explicit allowlist, skips dataset reload if the index is already warm, and filters genres in Redis rather than JS. Fix template URL to use root-relative path so local templates load in dev. Update agent builder to support JavaScript alongside Python.
Note
Low Risk
Documentation and static client-side templates only; no server auth or production runtime changes in this repo.
Overview
JavaScript (Node.js) is now a fully supported language in the AI agent builder, alongside Python. Docs list Python and JavaScript as available; Java and C# remain coming soon.
New Node.js templates ship for conversational and recommendation agents:
node-rediswith Redis Search—JSON vector indexes and hybrid recent + semantic context for chat; MovieLens ingest, LLM-parsed filters with allowlisted params, and genre matching via Redis TAGs for recommendations.Agent builder UI/logic treats JavaScript like Python in the wizard, filters model choices to exclude Anthropic for JS (OpenAI SDK only), loads templates via a root-relative
/code/agent-templates/...path, updates the generic JS stub for node-redis v4 env vars, and keeps the Jupyter button disabled for all outputs.Reviewed by Cursor Bugbot for commit ec2044f. Bugbot is set up for automated code reviews on this repo. Configure here.