Intelligent Document Processing (IDP) & Deep Research Platform powered by the DS-STAR Agent Workflow. Agentloop autonomously interprets, plans, codes, executes, and verifies complex data operations β secured by Supabase JWT authentication.
Agentloop is a multi-agent AI platform built for Intelligent Document Processing. By leveraging the DS-STAR Framework (Data Science - Self-Taught Agent with Reasoning), the platform dynamically analyzes datasets, generates Python code to process them, executes the code in a secure sandbox, and self-verifies the output against user constraints.
DS-STAR+ extends the core loop with a deep research mode that decomposes open-ended queries into parallel sub-questions, runs each as an independent DS-STAR agent, and synthesizes a comprehensive research report.
- Autonomous Agent Loop: Plan β Code β Execute β Verify β Route.
- Deep Research Mode (DS-STAR+): Decompose β Parallelize β Synthesize for open-ended queries.
- Supabase JWT Authentication: Secure sign-up/sign-in; every API call is auth-gated.
- Workspace Management: Organize runs and file uploads into user-owned workspaces with RLS-enforced isolation.
- Secure Sandboxing: Executes AI-generated code in isolated subprocesses (Docker-ready, fully supports
matplotlibdata visualization). - Hardened Orchestration: Fully asynchronous, deadlock-free (
asyncio.Lock) execution loop with dynamic schema metadata injection to prevent hallucination. - Real-Time Streaming: Live agent states and execution artifacts via Server-Sent Events (SSE).
- Persistent Analytics: Run history, metrics, and observability via Supabase PostgreSQL.
- Modern UI: Glassmorphism design on React 19 + Tailwind CSS; workspace selector, auth modal.
flowchart TD
classDef frontend fill:#3b82f6,stroke:#1d4ed8,stroke-width:2px,color:#fff
classDef backend fill:#10b981,stroke:#047857,stroke-width:2px,color:#fff
classDef ai_layer fill:#8b5cf6,stroke:#6d28d9,stroke-width:2px,color:#fff
classDef storage fill:#f59e0b,stroke:#b45309,stroke-width:2px,color:#fff
classDef sandbox fill:#64748b,stroke:#334155,stroke-width:2px,stroke-dasharray: 5 5,color:#fff
classDef auth fill:#ef4444,stroke:#b91c1c,stroke-width:2px,color:#fff
User((User))
subgraph Frontend [React 19 Frontend]
UI[User Interface & Hooks]:::frontend
Auth[AuthContext + AuthModal]:::auth
WS[WorkspaceSelector]:::frontend
end
subgraph Backend_FastAPI [FastAPI Backend]
JWT[JWT Middleware]:::auth
REST_API[REST & SSE Endpoints]:::backend
Orchestrator[DS-STAR Orchestrator]:::backend
subgraph Agent_Loop [AI Control Loop]
FileAnalyzer[File Analyzer]:::ai_layer
Planner[Planner]:::ai_layer
Coder[Coder]:::ai_layer
Verifier[Verifier]:::ai_layer
Router[Router]:::ai_layer
end
Sandbox[[CodeExecutor Sandbox]]:::sandbox
end
subgraph Infrastructure [Data & LLM]
Supabase[(Supabase Auth + DB)]:::storage
LLM[NVIDIA NIM via LangChain]:::ai_layer
end
User --> Auth
Auth --> Supabase
User --> UI
UI -->|REST & SSE + Bearer token| REST_API
REST_API --> JWT
JWT -->|Verified user_id| Orchestrator
Orchestrator --> FileAnalyzer
Orchestrator --> Planner
Planner --> Coder
Coder -.->|Executes Code| Sandbox
Sandbox -.->|Stdout/Artifacts| Verifier
Verifier -->|Evaluates| Router
Router -->|Retry/Refine| Planner
Agent_Loop <-->|Inference| LLM
Orchestrator -->|Metrics & History| Supabase
WS --> Supabase
| Layer | Technology |
|---|---|
| Frontend | React 19, Vite, Tailwind CSS, Lucide React |
| State / Auth | Zustand, @supabase/supabase-js |
| Backend | FastAPI, Python 3.10+, PyJWT, Tenacity, asyncio |
| AI / LLM | LangChain, langchain-nvidia-ai-endpoints (NVIDIA NIM) |
| Execution | Subprocess sandbox (Docker-ready, Data Science env equipped) |
| Database / Auth | Supabase (PostgreSQL + Row-Level Security) |
Agentloop/
βββ backend/
β βββ api/
β β βββ controllers/ # Business logic controllers
β β βββ routes.py # FastAPI router β thin endpoint declarations
β βββ core/ # DS-STAR Orchestrator, Planner, Coder, Verifierβ¦
β βββ db/
β β βββ create_workspaces.sql # Workspaces table + RLS
β β βββ create_uploaded_files.sql # File metadata table + RLS
β β βββ add_workspace_to_uploaded_files.sql # File workspace scoping migration
β β βββ create_agent_runs.sql # Agent runs table + RLS
β β βββ create_reports_schema.sql # Reports + sub_questions tables + RLS
β β βββ create_eval_schema.sql # Evaluation metrics schema
β β βββ add_eval_metrics_fk.sql # Add eval metrics foreign keys
β βββ eval/ # Evaluation framework and metrics
β βββ middleware/
β β βββ auth.py # JWT dependency (get_current_user / get_optional_user)
β β βββ error_handler.py # Global exception handler
β βββ models/ # Pydantic request/response schemas
β βββ services/
β β βββ supabase_service.py # Supabase client + all DB/Storage ops
β βββ tests/
β β βββ test_auth_middleware.py # Unit tests for JWT auth
β β βββ test_code_executor.py
β β βββ test_orchestrator_integration.py
β β βββ test_router_agent.py
β β βββ test_verifier_agent.py
β βββ main.py # FastAPI entry point
β βββ requirements.txt
β βββ .env # Local secrets (git-ignored)
β βββ .env.example # Template β copy to .env
βββ src/
β βββ components/
β β βββ agent/ # AgentProgressPanel, HistoryPanel, AgentSettings
β β βββ shared/
β β β βββ AuthModal.jsx # Login / Sign-Up modal
β β β βββ WorkspaceSelector.jsx # Workspace dropdown
β β β βββ ConfirmDialog.jsx
β β β βββ Toast.jsx
β β βββ upload/
β β βββ FileUploadPanel.jsx # Drag-drop zone with WorkspaceSelector
β βββ contexts/
β β βββ AuthContext.jsx # AuthProvider + useAuth() hook
β βββ hooks/
β β βββ useAgentRun.js # DS-STAR live run state + history
β β βββ useFileUpload.js # File lifecycle: add, upload, process, clear
β βββ lib/
β β βββ supabaseClient.js # Singleton Supabase browser client
β βββ pages/
β β βββ HomePage.jsx # Main layout: Upload | Query | Agent output
β β βββ EvalDashboard.jsx # Evaluation metrics dashboard
β βββ services/
β β βββ api.js # REST API calls (upload, process, clear) + auth headers
β β βββ agentApi.js # SSE streaming client + auth header
β βββ stores/
β β βββ workspaceStore.js # Zustand store for active workspace
β βββ types/
β β βββ index.js # JSDoc typedefs (User, Session, Workspace, AgentRunβ¦)
β βββ App.jsx # Root: AuthProvider + Router
β βββ main.jsx # React DOM entry
βββ public/ # Static assets
βββ .env # Frontend env vars (VITE_SUPABASE_*)
βββ .env.example # Frontend env template
βββ vite.config.js # Dev server + /api proxy β localhost:8000
βββ package.json # Node dependencies
βββ docs/ # Agent architecture documentation
Agentloop uses Supabase JWT authentication end-to-end:
- Frontend:
@supabase/supabase-jsmanages sign-in/sign-up, token refresh, and session persistence. - API calls: Every request stamped with
Authorization: Bearer <access_token>viaauthHeader()helpers inapi.jsandagentApi.js. - Backend:
get_current_userFastAPI dependency decodes and verifies the JWT usingPyJWT+SUPABASE_JWT_SECRET. ReturnsAuthUser(user_id, email, role). - Database: Supabase Row-Level Security policies enforce
auth.uid() = user_idβ users can only access their own rows.
| Method | Path | Auth |
|---|---|---|
POST |
/api/upload |
Optional (anonymous uploads allowed) |
POST |
/api/process |
Optional |
POST |
/api/agent/run |
Optional (user_id stamped when present) |
GET |
/api/agent/runs |
Optional (scoped to user when authenticated) |
GET |
/api/agent/runs/{id} |
Optional |
GET |
/api/workspaces |
Required |
POST |
/api/workspaces |
Required |
Agentloop relies on the DS-STAR Orchestrator pattern:
- File Analyzer: Normalizes incoming unstructured data into context schemas.
- Retriever: Filters large documents using local
sentence-transformers. - Planner: Transforms user intent into a mutable multi-step plan.
- Coder: Translates each plan step into self-contained Python code.
- Code Executor: Runs generated code in an isolated sandbox.
- Debugger: Surgically corrects failing code blocks.
- Verifier & Router: Evaluate output and re-route for retries.
- Finalizer: Converts execution output into clean Markdown insights.
DS-STAR+ extends with:
- SubQuestionGenerator: Decomposes open-ended queries into sub-questions.
- ReportWriter: Synthesizes parallel sub-runs into a research report.
- Node.js 18+
- Python 3.10+
- Supabase project (free tier works)
- NVIDIA NIM API key
git clone <repo-url>
cd Agentloop- Create a project at supabase.com.
- Open the SQL Editor and run these migration files in order:
backend/db/create_workspaces.sql backend/db/create_uploaded_files.sql backend/db/add_workspace_to_uploaded_files.sql backend/db/create_agent_runs.sql backend/db/create_reports_schema.sql backend/db/create_eval_schema.sql backend/db/add_eval_metrics_fk.sql - From Settings β API, collect:
Project URLβSUPABASE_URL/VITE_SUPABASE_URLanon publickey βVITE_SUPABASE_ANON_KEYservice_roleoranonkey βSUPABASE_PUBLISHABLE_KEYJWT Secret(Settings β API β JWT Settings) βSUPABASE_JWT_SECRET
cd backend
python -m venv venv
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate
pip install -r requirements.txt
# Copy template and fill in your keys
cp .env.example .env
# Edit .env: set SUPABASE_URL, SUPABASE_PUBLISHABLE_KEY, SUPABASE_JWT_SECRET, NVIDIA_API_KEY
uvicorn main:app --reload
# API running at http://localhost:8000# From project root
cp .env.example .env # if .env doesn't exist
# Edit .env: set VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY
npm install
npm run dev
# App running at http://localhost:5173Note: The Vite dev server proxies
/api/*βhttp://localhost:8000automatically β no CORS configuration needed during development.
cd backend
python -m pytest tests/ -v| Method | Path | Auth | Description |
|---|---|---|---|
POST |
/api/upload |
Optional | Upload files to session-scoped cache |
POST |
/api/process |
Optional | Build in-memory document context |
POST |
/api/agent/run |
Optional | Start DS-STAR agent run (SSE stream) |
GET |
/api/agent/runs |
Optional | List past runs (scoped to user) |
GET |
/api/agent/runs/{id} |
Optional | Get a single run by ID |
GET |
/api/workspaces |
Required | List authenticated user's workspaces |
POST |
/api/workspaces |
Required | Create a new workspace |
DELETE |
/api/clear |
Optional | Wipe session file cache |
GET |
/api/eval/* |
Public | Evaluation metrics endpoints |
- Fork the repository.
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'feat: add amazing feature' - Push:
git push origin feature/amazing-feature - Open a Pull Request.
MIT License β see LICENSE for details.