Skip to content

ThinkLife v0.7.35

Latest

Choose a tag to compare

@jagguvarma15 jagguvarma15 released this 01 Jan 01:36

ThinkLife v0.7.35 (Pre-release)

Release Date: December 2025
Platform: ThinkLife - AI Integration Platform
Build: 9eca96c


Major Features & Enhancements

Multi-Agent Orchestration System

Brain/Cortex Architecture: Centralized AI orchestration system for managing multiple agents with consistent safety, context management, and execution patterns.

  • CortexFlow: Central nervous system coordinating all agent requests through two-phase execution (Planning → Execution)
  • Plugin-Based Agents: Lightweight agent plugins define specifications; Cortex handles all processing
  • Reasoning Engine: LLM-powered planner that optimizes execution specs with three strategies:
    • Direct (fast, uses specs as-is)
    • Reasoned (smart, LLM optimization)
    • Adaptive (balanced, confidence-based decision)
  • Workflow Engine: LangGraph-based state machine for standardized execution across all agents
  • Provider Registry: Dynamic multi-provider support (OpenAI, Anthropic, Gemini) with automatic failover

Confidence Scoring & Validation System

Intelligent Response Quality Control: Every AI response receives a confidence score (0.0-1.0) with automatic retry for low-quality responses.

  • Two-Stage Scoring:
    • Rule-Based Validation (30%): Length checks, word count, error pattern detection
    • LLM-Based Validation (70%): Relevance, helpfulness, accuracy, completeness (0-100 points)
  • Acceptance Threshold: 0.75 minimum confidence required for response acceptance
  • Agentic Retry Loop: Automatic regeneration with feedback for responses below threshold (max 5 attempts)
  • Reasoning Validation: Pre-execution validation of reasoning engine output with confidence checks
  • Context-Aware Fallbacks: Agent-level handling of low confidence responses with empathetic alternatives

Agent Expansion Framework

Future Agents Under Construction: Infrastructure for specialized AI agents beyond Zoe.

  • Storytelling Agent: Interactive narrative experiences for healing through creative expression
  • FAQ Agent: Intelligent question-answering for Think Round programs and resources
  • Onboarding Agent: Personalized guidance for new interns exploring healing spaces
  • Consistent Architecture: All agents use same trauma-informed, safety-first approach with varying purposes

Technical Architecture

Backend Infrastructure

Core Systems

  • FastAPI: High-performance async API with automatic OpenAPI documentation
  • Python 3.9+: Core backend with asyncio for concurrent request handling
  • CortexFlow: Singleton orchestrator managing agent lifecycle and execution
  • WorkflowEngine: LangGraph-based state machine with conditional routing and validation loops

AI Provider Integration

  • OpenAI GPT-4o-mini: Primary language model for natural conversation
  • Google Gemini: Migrated to new google-genai package (v1.47.0) from deprecated google.generativeai
  • Provider Registry: Dynamic provider loading with validation and health checks
  • Tool Registry: MCP tool integration with availability checking
  • Data Source Registry: Vector DB, conversation history, and context management

Security & Guardrails

  • SessionManager: Unified session tracking with token-based validation
  • SecurityManager: Authentication, rate limiting, content filtering
  • Keycloak Integration: Enterprise authentication with role-based access control (RBAC)
  • Middleware: Custom authentication middleware with JWT token handling

Frontend Architecture

Core Stack

  • Next.js 15: React framework with App Router, TypeScript, and Turbopack
  • Node.js 24.x: Runtime environment (auto-upgraded from 22.x via engines config)
  • Framer Motion: Animation library for smooth transitions and avatar expressions
  • Tailwind CSS: Utility-first responsive design system
  • Keycloak-js: Client-side authentication with PKCE flow

TypeScript Improvements

  • Type Safety Fixes: Resolved Keycloak type inference issues in context providers
  • Explicit Type Imports: Added import type for better type checking
  • Type Assertions: Proper narrowing for nullable Keycloak instances

Evaluation & Observability

Monitoring Systems

  • Langfuse Integration: Full execution tracing for debugging and analytics (v3.7.0+)
  • Cost Estimators: Pre-execution cost prediction for provider requests
  • Latency Estimators: Response time estimation with historical statistics
  • Confidence Tracking: Per-response confidence scores logged in metadata

Validation & Quality Control

Response Validation Pipeline

Stage 1: Rule-Based Checks (30% weight)

  • Minimum length: 10 characters
  • Minimum word count: 3 words
  • Error pattern detection: Refusals, apologies, limitations
  • Base confidence: 0.5 for passing all checks

Stage 2: LLM Validation (70% weight)

  • Relevance: 0-25 points
  • Helpfulness: 0-25 points
  • Accuracy: 0-25 points
  • Completeness: 0-25 points
  • Normalized to 0.0-1.0 scale

Stage 3: Final Decision
final_confidence = (rule_based_score × 0.3) + (llm_score × 0.7)Retry Mechanism

  • Confidence < 0.75: Inject validation feedback and retry (max 5 attempts)
  • Max attempts reached: Replace with fallback message
  • Brain returns response with confidence score to agents
  • Agents make final display decision based on confidence

Reasoning Validation

Pre-Execution Checks

  • Plan completeness validation
  • Provider configuration verification
  • Reasoning confidence threshold (minimum 0.3)
  • Spec optimization effectiveness
  • Cost/latency estimate validation

Agent Implementations

Zoe AI Companion (Enhanced)

New Capabilities

  • Confidence-Based Responses: Receives confidence scores from Brain, uses context-aware fallbacks for low confidence
  • Brain Integration: Full CortexFlow integration with centralized processing
  • Session Persistence: Enhanced conversation history with confidence metadata
  • Context-Aware Fallbacks: Different responses for emotional support vs informational questions

Existing Features (Maintained)

  • ACE assessment integration with personalized routing
  • Trauma-informed response generation
  • Crisis detection and professional referrals
  • Multi-modal interaction (text and voice)
  • Avatar mode with dynamic expressions

Breaking Changes

Backend

  • Gemini Provider: Migrated from google-generativeai to google-genai package
    • Old import: import google.generativeai as genai
    • New import: from google import genai
    • Action Required: Update dependencies: pip install google-genai

Response Format

  • Confidence Score Added: All Brain responses now include confidence field (0.0-1.0)
  • Validation Metadata: Responses include validation_attempts and confidence_score in metadata
  • Low Confidence Handling: Agents may return different content than Brain generated if confidence < 0.75

Workflow Execution

  • Validation Node Added: New mandatory validation step between provider call and finalization
  • Retry Loop: Responses may take longer due to automatic retry mechanism (up to 5 attempts)
  • Execution Steps: Updated flow includes validate_response in execution steps array

Performance Improvements

Optimization Features

  • Async Validation: Non-blocking validation with concurrent LLM calls
  • Confidence Caching: Validation results stored in state for debugging
  • Smart Retry: Validation feedback incorporated into retry attempts for faster convergence
  • Early Exit: Immediate finalization when confidence threshold met (no unnecessary retries)

Resource Management

  • Provider Pooling: Reuse provider instances for validation calls
  • Token Limits: Validation uses lower token count (200 vs 2000) for efficiency
  • Temperature Control: Validation temperature set to 0.3 for consistent scoring

Configuration Changes

New Environment Variables

Google Gemini (if using)

GEMINI_API_KEY=your_key_here

Keycloak Authentication

NEXT_PUBLIC_KEYCLOAK_URL=http://localhost:8080
NEXT_PUBLIC_KEYCLOAK_REALM=thinklife
NEXT_PUBLIC_KEYCLOAK_CLIENT_ID=thinklife-frontend

Langfuse Observability (optional)

LANGFUSE_PUBLIC_KEY=your_public_key
LANGFUSE_SECRET_KEY=your_secret_key
LANGFUSE_HOST=https://us.cloud.langfuse.com### Default Settings

  • Confidence Threshold: 0.75
  • Max Validation Runs: 5
  • Validation Temperature: 0.3
  • Validation Max Tokens: 200
  • Minimum Reasoning Confidence: 0.3

Documentation Updates

New Documentation

  • CONFIDENCE_SCORING.md: Complete guide to confidence scoring system
  • VALIDATION_LOOP_IMPLEMENTATION.md: Agentic validation loop architecture
  • BRAIN_ARCHITECTURE.md: Updated with validation and confidence scoring
  • WORKFLOW_ENGINE.md: Enhanced with validation node and retry logic
  • CORTEX_REASONING_ARCHITECTURE.md: Reasoning validation details
  • agents/zoe/README.md: Confidence-based response handling

Bug Fixes

Frontend

  • Fixed Keycloak TypeScript type inference error in KeycloakContext
  • Resolved "Property 'onTokenExpired' does not exist on type 'never'" build error
  • Added proper type imports for Keycloak instance

Backend

  • Resolved port conflict handling (automatic cleanup of stale processes)
  • Fixed Google Generative AI deprecation warnings
  • Improved error handling in provider initialization

System Requirements

Backend

  • Python: 3.9+
  • Node.js: 20.0+ (automatically uses 24.x due to engines config)
  • PostgreSQL: 12+ (optional, for production)
  • Memory: 8GB+ RAM recommended

Frontend

  • Node.js: 20.0+
  • Modern browser with ES2020 support
  • WebRTC support for voice features

Dependencies

  • google-genai: 1.47.0+ (replaces google-generativeai)
  • langfuse: 3.7.0+ (optional, for observability)
  • keycloak-js: Latest for authentication

Migration Guide

From v0.4.75 to v0.7.35

Backend Migration

  1. Update dependencies:
    pip uninstall google-generativeai
    pip install google-genai
    2. No code changes required - Gemini provider automatically uses new package

  2. Review confidence scores in responses - agents may now return fallback messages

Frontend Migration

  1. Update Keycloak context if customized (TypeScript fixes applied)
  2. No breaking changes to existing components

Agent Development

  • New agents should use CortexFlow architecture
  • Implement confidence-based response handling in agent services
  • Follow Zoe pattern for Brain integration

Known Issues

  • Validation may add 1-3 seconds latency for responses requiring retries
  • LLM validation requires provider API calls (additional cost)
  • Confidence scores require calibration for optimal threshold tuning

Future Work

  • Adaptive confidence thresholds based on message type
  • Confidence calibration using historical data
  • Multi-model validation ensemble
  • Storytelling, FAQ, and Onboarding agents (in development)

Version: 0.7.35

What's Changed

Full Changelog: v0.1.0...0.7.35