98 VITTO SUPER AGENT REBUILD

Documentation for Sessions

Session 98: Vitto Super-Agent Separation & Rebuild

Overview

Rebuilt Vitto from a 2119-line god-class embedded inside backend-ai-api into a standalone super-agent API (backend-vitto-api) running on port 3003 with its own Mind database, provider-agnostic LLM abstraction, and 4-phase workflow.

Problem

The old VittoOrchestratorService was a monolithic class that:

Solution

Part A: Decouple from backend-ai-api

Files modified:

Key insight: Only 3 files outside vitto/ referenced it. The entire agentic process (HandoffService, AgentService, NativeWsGateway, HandoffTimeoutService, MCP Gateway) has zero Vitto dependencies.

Part B: New Standalone backend-vitto-api

Architecture (7 modules, ~40 files, ~5,100 lines):

Module Purpose
Engine Task queue, 4-phase workflow (ANALYZE->PLAN->EXECUTE->VERIFY), SSE events
Mind Own MongoDB (vitto-mind) — execution traces, strategy memory, agent performance, user patterns
LLM Provider-agnostic — BaseLLMProvider + Claude/OpenAI/Gemini + ProviderFactory with fallback chains
Tools 10 tools: read_file, write_file, run_command, http_request, create_handoff, check_handoff_status, recall_memory, search_decisions, query_docs, task_complete
Strategy RequestClassifier, CostGuard (25 iter/100K tokens/5min), QualityGate
Connectivity HTTP clients to all 3 backends + WebSocket for handoff events + native notifications
Prompts Template loading with {{variable}} interpolation, .prompt.md files per phase

Part C: Deployment Readiness

Cleanup

Key Design Decisions

  1. Standalone API (port 3003) — Process isolation, independent scaling, own database
  2. Own Mind database (vitto-mind MongoDB) — Execution traces, strategy memory, agent performance. Platform shared knowledge stays in backend-ai-api accessed via HTTP.
  3. Provider-agnostic LLM — Switch via VITTO_LLM_PROVIDER=claude|openai|gemini. ProviderFactory with health checks and fallback chains.
  4. 4-phase workflow — Adopted from gmodules1's PhaseExecutor: ANALYZE classifies, PLAN creates steps, EXECUTE runs tool-use agentic loop, VERIFY validates output quality.
  5. Full data access — HTTP clients to all 3 backends (api:3000, ai-api:3001, docs-api:3002). Same Bearer token auth pattern.
  6. No auto-claiming — Unlike old Vitto, new one doesn't auto-claim handoffs. Tasks are submitted directly or assigned explicitly.

Running

# Development
yarn serve:backend-vitto

# All backends including Vitto
yarn serve:all-backends

# Direct NX
npx nx serve backend-vitto-api

Port Reference

Service Port Health Endpoint
backend-api 3000 /api/health
backend-ai-api 3001 /ai-api/health
backend-docs-api 3002 /docs-api/health
backend-vitto-api 3003 /vitto-api/health

Environment Variables

VITTO_API_PORT=3003
VITTO_MONGODB_URI=mongodb://localhost:27017/vitto-mind
VITTO_LLM_PROVIDER=claude
VITTO_LLM_MODEL=claude-sonnet-4-20250514
VITTO_MAX_CONCURRENT=3
VITTO_MAX_ITERATIONS=25
VITTO_MAX_TOKENS=100000
VITTO_TASK_TIMEOUT_MS=300000

Files Created/Modified

New files (~40):

Modified files:

Deleted files (cleanup):

Next Steps