Adaptive-RAG n8n workflow¶
1. Overview¶
The Adaptive-RAG workflow is checked in as adaptive-rag.workflow.json.
scripts/start-all.sh imports it with --activeState=fromJson, then restarts n8n
so the production webhook is registered. The backend wrapper at
backend_plugins/rag/approaches/n8n.py POSTs {query} to this workflow's webhook
and surfaces the chosen route in the comparison column.
2. Workflow Nodes¶
- Webhook (POST, path
adaptive-rag) — receives{ "query": "..." }. - Classify (HTTP Request →
http://litellm:4000/v1/chat/completions, AuthorizationBearer {{ $env.LITELLM_API_KEY }}— Atlas injects the master key into the n8n container under that name — modelqwen3.6:latest, a name LiteLLM registers, called withtemperature: 0andthink: false— the same top-level thinking suppressionmodels.yamlplumbs for this model, load-bearing inside the node's 60 s timeout): the prompt classifies the question as one word —simple, orcomplexwhen it needs multi-step reasoning or synthesis across sources. Output →route. - Route (Code node) maps
complextoagentic-rag, everything else tovanilla-rag, and builds the backend route URL. - Call Approach (HTTP Request) calls
http://backend:8000/<approach>/v1/chat/completions. - Shape (Code node) builds
{ "answer": <chosen answer text>, "route": <route>, "approach": <approach> }. - Respond to Webhook: return the Shape node's JSON.
The checked-in workflow has "active": true. The backend POSTs to the
production webhook /webhook/adaptive-rag, which n8n registers only for active
workflows. This is why startup imports the workflow and restarts n8n before model
registration.
3. Editing the Workflow¶
If you edit the workflow in the n8n UI, export it back over
adaptive-rag.workflow.json before committing. Keep the top-level id, name,
active, and webhook path stable unless you also update
N8N_ADAPTIVE_WEBHOOK_URL and the startup import logic.
Potential tuning variables live in the workflow JSON rather than Python:
- classifier model;
- classifier prompt;
- simple/complex route mapping;
- backend approach timeout;
- response shaping.