You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An advanced, multi-agent orchestration engine that transforms raw queries into structured, citation-backed research reports — powered by NVIDIA NIM and OpenRouter LLMs with real-time SSE streaming.
Multi-Agent Orchestration — 7 specialized AI agents work in parallel across a 3-phase pipeline (Intelligence → Retrieval → Synthesis) to produce comprehensive research reports
3 Research Modes — Choose between corpus (AI-knowledge only), deep (moderate web research), or pro (maximum agent capabilities with 8+ sources)
Real-Time SSE Streaming — Live streaming of agent statuses, thinking steps, and report content directly to the UI with zero polling
Intelligent Query Expansion — The Query Intelligence agent classifies intent (coding, research, comparison, explanation, factual, general) and generates subtopics and optimized search terms automatically
Dynamic Report Planning — Generates structured research plans with fixed and dynamic sections, estimated page counts, and per-section agent assignments
Heuristic Query Routing — Pattern-matching fast-path for simple queries (greetings, definitions) that bypasses the AI classifier entirely, saving API costs
Multi-Turn Conversation — Supports conversationHistory context for follow-up queries and iterative research
AI Provider Integration
Dual-Provider Architecture — Primary execution on NVIDIA NIM (high-quality, billed per token) with automatic failover to OpenRouter (free-tier models for resiliency)
Smart Model Routing — Task-aware model selection: reasoning models for analysis, coding models for snippets, fast models for summaries, balanced models for search
3-Tier Fallback Chain — Each agent type has 3 tiers: NVIDIA Primary → NVIDIA Alternate → OpenRouter Free. If Tier 1 fails, Tier 2 fires automatically
Race-Based Fallback — If the primary model is slow (>45s), the fallback model fires concurrently. First to succeed wins via Promise.any()
Free Model Rotation — On OpenRouter 429 rate limits, the system rotates through 5 free models (glm-4.5-air, gemma-4-31b, minimax-m2.5, nemotron-3-super, gpt-oss-120b) automatically
15+ Model Registry — Curated models including Kimi K2 Thinking, DeepSeek V3.2, Qwen 3 Coder 480B, Mistral Large 3, Nemotron 3 Super, Llama 3.3 70B, and more
Document & File Processing
Multi-Format File Parsing — Upload and parse PDF (via pdf.js), DOCX (via Mammoth), CSV (via PapaParse), TXT/MD/JSON (native), and images (via Tesseract.js OCR)
Local Processing — Document parsing runs locally or via WebAssembly (WASM) to minimize data transit and protect privacy
Context Grounding — Uploaded file content is chunked, scored by query relevance, and injected into the agent context pipeline with high priority (up to 70% of token budget)
Smart Chunking — Files are split into 500-word chunks, scored against query terms, and ranked by relevance before inclusion
UI & Export
Glassmorphism UI — Modern, animated interface built with Tailwind CSS 4, Framer Motion, and shadcn/ui components with a matte black metallic theme
Agent Status Panel — Real-time visibility into which agents are running, their assigned models, providers, durations, and fallback status
Thinking Panel — Transparent view of the AI's reasoning process with timestamped thinking steps per phase
Citation Graph — Interactive visualization of source relationships and relevance scores
PDF Export — Generate downloadable A4 PDF reports with cover page, formatted tables, headers/footers, and page numbers via jsPDF + autoTable
Markdown Export — Export reports as clean markdown with proper formatting
TXT Export — Plain text export with markdown stripped
Source Cards — Each source is displayed with title, snippet, domain, and relevance score for easy verification
Reliability & Performance
Retry Logic — 1 retry max with 500ms base delay and 2s cap (exponential backoff) before triggering fallback
Concurrency — Phase 3 agents run in parallel via Promise.all with 200ms stagger to minimize TTFT and avoid rate limit bursts
Graceful Timeouts — Section agents timeout after 150s with a graceful fallback response (no crash). Report agent gets 180s
# 1. Clone the repository
git clone https://github.com/your-username/research-assistant.git
cd research-assistant
# 2. Install dependencies
npm install
# 3. Configure environment variables
cp .env.example .env.local
# Edit .env.local with your API keys (see Environment Variables section)# 4. Start the development server
npm run dev
Type your research query in the search input (e.g., "Compare quantum computing approaches in 2026")
Select a research mode: corpus (fast, no web), deep (moderate), or pro (comprehensive)
Optionally upload files (PDF, DOCX, CSV, or images) for context-grounded research
Watch the agents work in real-time via the Agent Status Panel and Thinking Panel
Export your report as PDF, Markdown, or plain text
Production Build
npm run build
npm start
Environment Variables
Create a .env.local file in the project root:
# ── Required ──────────────────────────────────────────────────────# NVIDIA NIM API Key — Primary LLM provider# Get yours at: https://build.nvidia.com
NVIDIA_API_KEY=nvapi-xxxxxxxxxxxx
# OpenRouter API Key — Fallback LLM provider# Get yours at: https://openrouter.ai
OPENROUTER_API_KEY=sk-or-v1-xxxxxxxxxxxx
# ── Optional ──────────────────────────────────────────────────────# Application base URL (default: http://localhost:3000)
NEXT_PUBLIC_APP_URL=http://localhost:3000
Security Note: Never commit .env.local to version control. The .gitignore is pre-configured to exclude all .env* files. If you accidentally expose a key, revoke it immediately.
Configuration
Research Modes
Mode
Max Sources
Search Provider
Description
Best For
corpus
0
None
Fast report using pure AI knowledge. No web search.
Quick overviews, offline research
deep
4
NVIDIA + OpenRouter fallback
Moderate web research combined with AI analysis.
Balanced speed and depth
pro
8
NVIDIA + OpenRouter fallback
Comprehensive deep research using maximum agent capabilities.
Thorough reports, academic research
Token Limits
Parameter
Limit
Description
Context Window
131,072
Maximum input context across all agents
Max Response
32,768
Maximum output tokens per response
Per-Agent Cap
16,384
Token budget per individual agent
Report Agent
32,768
Dedicated budget for final report synthesis
Words-to-Token Ratio
1.3
Conversion factor for token estimation
Retry Configuration
Parameter
Value
Description
Max Retries
1
Single retry before fallback trigger
Base Delay
500ms
Initial retry delay (exponential backoff)
Max Delay
2,000ms
Maximum retry backoff cap
Timeout Configuration
Component
Timeout
Description
Primary Model
90,000ms (90s)
Per-model timeout for standard agents
Fallback Race
45,000ms (45s)
Time before fallback fires concurrently
Report Agent
180,000ms (180s)
Extended timeout for 5-6 page synthesis
Section Agent
150,000ms (150s)
Graceful timeout with fallback content
NVIDIA Provider
90,000ms (90s)
HTTP request timeout
OpenRouter Provider
90,000ms (90s)
HTTP request timeout
Token Governance
ResAgent enforces strict token budgets to ensure report density without sacrificing analytical depth:
Rule
Limit
Purpose
System Context
32,768 Tokens
Maximum context passed to any agent
Max Report
16,384 Tokens
Report synthesis output budget
Per-Agent Cap
8,192 Tokens
Individual agent output budget
File Context
70% of token limit
Maximum allocation for uploaded file content
Web Context
30% of token limit
Maximum allocation for web search results
Tokens are managed at the orchestrator level. Each agent receives its budget in the AgentContext and must stay within limits. The report agent gets the largest allocation for final synthesis.
Error Handling & Classification
flowchart TD
E["Error Occurred"] --> C["classifyError()"]
C --> K{"Error Kind?"}
K -->|"429"| RL["rate_limit<br/>retryable: true<br/>→ Try next tier"]
K -->|"401/403"| AU["auth<br/>retryable: false<br/>→ Check API key"]
K -->|"fetch failed"| NW["network<br/>retryable: true<br/>→ Retry or next tier"]
K -->|"502/503/504"| PD["provider_down<br/>retryable: true<br/>→ Next provider"]
K -->|"context length"| TE["token_exceeded<br/>retryable: false<br/>→ Shorter query"]
K -->|"invalid json"| PE["parse_error<br/>retryable: true<br/>→ Retry"]
K -->|"other"| UN["unknown<br/>retryable: false<br/>→ User notification"]
RL --> UF["userFacingMessage()"]
AU --> UF
NW --> UF
PD --> UF
TE --> UF
PE --> UF
UN --> UF
UF --> UI["Display to User"]
style E fill:#1e1e2e,stroke:#f38ba8,color:#cdd6f4
style C fill:#1e1e2e,stroke:#f9e2af,color:#cdd6f4
style UF fill:#1e1e2e,stroke:#a6e3a1,color:#cdd6f4
Loading
Error Types
Kind
Retryable
User Message
rate_limit
Yes
"Too many requests — retrying with a different provider..."
auth
No
"API key is missing or invalid. Please check your configuration."
network
Yes
"Could not connect to the service. Check your internet connection."
provider_down
Yes
"The AI provider is temporarily down. Trying an alternative..."
token_exceeded
No
"The query is too complex. Try a shorter or simpler question."
parse_error
Yes
"Failed to process the response. Trying again..."
unknown
No
"Something went wrong. Please try again."
Design System
Theme: Matte Black & White (Metallic Finish)
Token
Value
Usage
--background
#0C0C0C
Page background
--foreground
#F5F5F5
Primary text
--card
rgba(255, 255, 255, 0.04)
Card surfaces
--primary
#FFFFFF
Primary actions, headings
--secondary
#A0A0A0
Secondary text, muted elements
--muted
rgba(255, 255, 255, 0.06)
Muted surfaces
--border
rgba(255, 255, 255, 0.12)
Borders (brushed steel)
--destructive
#EF4444
Error states
--glow
rgba(255, 255, 255, 0.6)
Glow effects
--glass
rgba(12, 12, 12, 0.9)
Glassmorphism background
--glass-border
rgba(255, 255, 255, 0.1)
Glass border
CSS Utilities
Class
Description
.glass
Glassmorphism effect with backdrop blur
.glass-card
Gradient glass card with subtle border
.glass-strong
Stronger glass effect for overlays
.metallic
Metallic surface gradient
.text-gradient
White-to-silver metallic text gradient
.border-shine
Animated border shine effect
.primary-glow
White glow shadow
.streak-1/2/3
Decorative light streaks
Typography
Element
Responsive Sizes
h1
text-3xl → md:text-5xl → lg:text-6xl
h2
text-2xl → md:text-3xl → lg:text-4xl
h3
text-xl → md:text-2xl
Fonts
Variable
Usage
--font-sans (Inter)
Body text
--font-mono (Geist Mono)
Code blocks
--font-heading (Playfair)
Headings
API Reference
POST /api/research
Initiates a research session. Supports both SSE streaming and JSON response modes.
Request Body:
{
query: string;// Research query (required)
mode: "corpus"|"deep"|"pro";// Research mode (default: "deep")
workflowMode?: "chat"|"planning"|"research";
model?: string;// Override model selection
stream?: boolean;// Enable SSE streaming (default: true)
files?: FileContext[];// Uploaded files for context
conversationHistory?: LLMMessage[];// Multi-turn conversation context
disabledAgents?: AgentName[];// Agents to skip
userId?: string;// User ID for memory/caching
conversationId?: string;// Conversation ID for persistence}
FileContext Type:
interfaceFileContext{fileName: string;// Original filenamefileType: string;// MIME typecontent: string;// Extracted text content}