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 1 commit 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
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
❌ 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 3bf88f8. Configure here.
| .flatMap((d) => d) | ||
| .filter(Boolean) | ||
| .map((m) => ({ role: m.role, content: m.content, _key: m._key })); | ||
| } |
There was a problem hiding this comment.
Deduplication broken because _key is always undefined
High Severity
In _getRecentMessages, m._key reads from the JSON document retrieved from Redis, but _storeMessage only stores { role, content, session, embedding } — there is no _key field. So m._key is always undefined for every recent message. In _buildContext, the seen set becomes Set([undefined]), meaning no semantic results are ever filtered out. The deduplication between recent and semantic messages is completely non-functional, causing duplicate messages in the LLM context. The keys array from lRange holds the actual Redis keys but is never mapped onto the returned objects.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 3bf88f8. Configure here.
|
|
||
| // Track insertion order for recent-turn retrieval | ||
| await this.redisClient.rPush(RECENT_KEY(this.sessionName), key); | ||
| await this.redisClient.lTrim(RECENT_KEY(this.sessionName), -RECENT_WINDOW * 4, -1); |
There was a problem hiding this comment.
Recent window retrieval ignores RECENT_WINDOW limit
Low Severity
RECENT_WINDOW is 6, described as "always include this many recent turns in context," but lTrim uses RECENT_WINDOW * 4 (keeping 24 items, i.e. 12 turns), and _getRecentMessages fetches all items via lRange(0, -1). The effective recent window is 12 turns — double the stated intent. The multiplier likely needs to be * 2 (user + assistant per turn), and/or retrieval needs to be bounded.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 3bf88f8. Configure here.
| // Check if it's Python (fully supported) | ||
| if (selectedLang === 'python') { | ||
| // Check if it's a fully supported language | ||
| if (selectedLang === 'python' || selectedLang === 'javascript') { |
There was a problem hiding this comment.
Jupyter button misleadingly enabled for JavaScript agents
Low Severity
By adding 'javascript' as a fully supported language, JavaScript + OpenAI users now reach displayGeneratedCode, which only checks formData.llmModel !== 'openai' when deciding whether to enable the Jupyter button. A JavaScript + OpenAI user sees an active "Try in Jupyter" button, but clicking it falls through to a "coming soon" alert since tryInJupyter requires programmingLanguage === 'python'. The button enable/disable logic needs to also gate on the language being Python.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 3bf88f8. Configure here.
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.
|


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, static example code, and client-side wizard/template path changes with no production auth or data-path changes.
Overview
This PR ships Node.js agent templates and treats JavaScript (Node.js) as a first-class language in the interactive agent builder, alongside Python.
New static templates under
static/code/agent-templates/javascript/cover conversational and recommendation agents using node-redis and Redis Search. The conversational sample stores JSON message history with vector embeddings, validates embedding dimensions at runtime, and builds context from recent turns plus semantic KNN. The recommendation sample loads MovieLens-style CSVs, normalizes genres for Redis TAG filters, sanitizes LLM-parsed query params, skips re-import when the index is already populated, and runs genre/rating filters in Redis rather than in application code.static/js/agent-builder.jsnow advances the wizard forjavascript(not only Python), updates “coming soon” copy and fallback chips to offer Python or Node.js, and fixes template loading to a root-relative/code/agent-templates/...path so local dev can fetch templates withoutHUGO_BASEURL.Docs on the agent builder page now state that code can be generated in Python and JavaScript, with Java and C# still listed as coming soon.
Reviewed by Cursor Bugbot for commit 3bf88f8. Bugbot is set up for automated code reviews on this repo. Configure here.