Skip to content

DEV: add Knowledge Assistant (RAG) agent type to agent builder#3376

Open
mich-elle-luna wants to merge 8 commits into
mainfrom
agent-builder-rag
Open

DEV: add Knowledge Assistant (RAG) agent type to agent builder#3376
mich-elle-luna wants to merge 8 commits into
mainfrom
agent-builder-rag

Conversation

@mich-elle-luna

@mich-elle-luna mich-elle-luna commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Adds a third agent type — Knowledge Assistant — to the interactive agent builder, alongside the existing Recommendation Engine and Conversational Assistant. Includes Python and Node.js templates with Redis-native hybrid retrieval, semantic caching, session memory, and citations.

  • Python template: single redis-py client (decode_responses=False), redisvl for index creation only, FT.SEARCH hybrid query with vector-only fallback, load_directory() helper, idempotent sample doc ingestion
  • Node.js template: node-redis v4, same hybrid search pattern, loadDirectory() helper, ft.info() guard to skip re-ingestion on restart
  • agent-builder.js: adds rag type to CONFIG, enables JavaScript alongside Python, fixes root-relative template URL, adds third suggestion chip
  • agent-builder.html: adds Knowledge Assistant chip to initial message
  • _index.md: updated to mention three agent types and JS support

Note

Low Risk
Changes are additive docs/static assets and example templates; no production auth or data-path changes in the docs site itself.

Overview
Adds a third Knowledge Assistant option to the interactive agent builder (docs, initial suggestion chip, and CONFIG in agent-builder.js), so users can generate RAG-style agents alongside recommendation and conversational types.

New Python and Node.js rag_agent templates implement document chunking/ingestion, RediSearch hybrid retrieval (text filter + KNN with vector fallback), TTL semantic cache, Redis List session history, and cited answers. Startup only seeds sample docs when the doc index is empty.

The builder wires rag through the flow (default name KnowledgeAssistant, chip icons, longest-keyword matching for phrases like “knowledge assistant”) and sets window.AGENT_TEMPLATE_BASE via Hugo relURL so template fetches work under subdirectory deployments.

Reviewed by Cursor Bugbot for commit 97edce9. Bugbot is set up for automated code reviews on this repo. Configure here.

Adds a third agent type — Knowledge Assistant — to the interactive agent
builder, alongside the existing Recommendation Engine and Conversational
Assistant. Includes Python and Node.js templates with Redis-native hybrid
retrieval, semantic caching, session memory, and citations.

- Python template: single redis-py client (decode_responses=False), redisvl
  for index creation only, FT.SEARCH hybrid query with vector-only fallback,
  load_directory() helper, idempotent sample doc ingestion
- Node.js template: node-redis v4, same hybrid search pattern, loadDirectory()
  helper, ft.info() guard to skip re-ingestion on restart
- agent-builder.js: adds rag type to CONFIG, enables JavaScript alongside
  Python, fixes root-relative template URL, adds third suggestion chip
- agent-builder.html: adds Knowledge Assistant chip to initial message
- _index.md: updated to mention three agent types and JS support

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mich-elle-luna mich-elle-luna requested a review from a team May 27, 2026 21:44
@github-actions

Copy link
Copy Markdown
Contributor

@jit-ci

jit-ci Bot commented May 27, 2026

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

Comment thread static/code/agent-templates/python/rag_agent.py Outdated

@dwdougherty dwdougherty left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The complete example isn't displayed and it isn't downloadable or available for cut-and-paste. This kind of rings a bell - like we had this problem once before during initial development. 🤷🏻‍♂️

@dwdougherty dwdougherty requested a review from a team May 28, 2026 14:27
Hardcoded /code/agent-templates/ broke on staging when the site is
served from a subdirectory. Hugo's relURL now injects the correct base
path as window.AGENT_TEMPLATE_BASE so the XHR resolves relative to
wherever the site is deployed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@dwdougherty dwdougherty left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The RAG example looks to be complete for both Python and JavaScript. But the other two show incomplete JavaScript code. I'm seeing these kinds of errors in the Chrome debugger's console:

Template file not found: /docs/staging/agent-builder-rag/code/agent-templates/javascript/recommendation_agent.js (404)

So what the JavaScript is showing is the default code that lives somewhere (in the static/js/agent-builder.js file maybe?).

@mich-elle-luna

Copy link
Copy Markdown
Collaborator Author

ah thanks, those are the new templates that are in my other PR I think

- Fix semantic cache never firing: _check_cache now reads response,
  citations, and distance directly from the FT result doc instead of
  routing through _decode_doc which discarded those fields
- Add separate embedder client (EMBEDDING_API_KEY / EMBEDDING_API_BASE_URL)
  so chat completions and embeddings can use different providers; defaults
  to the LLM values so OpenAI and Ollama users need no extra config;
  Anthropic users can point embeddings at any OpenAI-compatible endpoint

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread static/js/agent-builder.js
require('dotenv').config() was missing, causing LLM_API_KEY to not
be found when running with a .env file. Also adds dotenv to the
install dependencies comment.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Jun 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Comment thread static/code/agent-templates/python/rag_agent.py Outdated
@mich-elle-luna mich-elle-luna requested a review from a team June 16, 2026 23:05
@mich-elle-luna

Copy link
Copy Markdown
Collaborator Author

I tested both of these locally to make sure they work as well.

@andy-stark-redis

Copy link
Copy Markdown
Contributor

@mich-elle-luna Visually OK as far as I can tell. Still a couple of Bugbot issues, though, and the Claude-Codex shuffle is worth a go, if you haven't already done it.

FT.INFO returns bytes keys when decode_responses=False, so
index_info.get('num_docs') always returned None and the guard
treated the index as empty on every startup. Fall back to the
bytes key so re-ingestion is correctly skipped.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread static/code/agent-templates/javascript/rag_agent.js Outdated
node-redis returns num_docs (snake_case), not numDocs. Fall back to
both keys and guard against NaN so sample docs are never skipped on
a genuinely empty index.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@dwdougherty dwdougherty left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Everything looks good in the staged preview. Approved.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 using default effort and found 2 potential issues.

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.

Reviewed by Cursor Bugbot for commit 35b3308. Configure here.

Comment thread static/js/agent-builder.js
Comment thread static/code/agent-templates/javascript/rag_agent.js Outdated
@jit-ci

jit-ci Bot commented Jun 25, 2026

Copy link
Copy Markdown

❌ Jit Scanner failed - Our team is investigating

Jit Scanner failed - Our team has been notified and is working to resolve the issue. Please contact support if you have any questions.


💡 Need to bypass this check? Comment @sera bypass to override.

- agent-builder.js: prefer longest matching keyword across all agent
  types so 'knowledge assistant' routes to rag instead of conversational
  (which matched first via the shorter 'assistant' keyword)
- rag_agent.js: guard JSON.parse in _checkCache with try/catch so a
  corrupted cache entry returns an empty citations array instead of
  throwing and breaking the query path

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

4 participants