PRD-26: System Settings Configuration
Overview
This PRD addresses critical issues with the system settings implementation:
Settings are not being properly saved to database
Settings refresh/reset when page reloads
Many settings shown in UI are not actually used by services
Settings need to be properly wired to services that should use them
Need comprehensive audit of all settings to identify what's real vs UI-only
Current State Analysis
✅ What Works
Settings API - Backend API endpoints exist:
GET /api/system-settings/- List all settingsGET /api/system-settings/by-category- Get by categoryPUT /api/system-settings/{setting_id}- Update single settingPOST /api/system-settings/bulk-update- Bulk updatePOST /api/system-settings/reset-to-defaults- Reset to defaults
Frontend Save Handler -
SystemSettingsTab.tsxcallsbulkUpdateSettings()LLM Settings Usage - Orchestrator LLM settings ARE used:
orchestrator_llm.provider→ Used inllm_provider/manager.pyorchestrator_llm.model→ Used inllm_provider/manager.pyorchestrator_llm.temperature→ Used inllm_provider/manager.py(line 245)orchestrator_llm.max_tokens→ Used inllm_provider/manager.py(line 246)
❌ What's Broken
Settings Not Persisting
Issue: Settings refresh after page reload shows defaults
Root Cause: Likely seed script re-running or settings being overwritten
Solution: Ensure seed script only creates if not exists, never overwrites existing values
Settings Not Used by Services
General Settings:
environment- NOT USED (hardcoded in config.py)log_level- NOT USED (Python logging uses config.py LOG_LEVEL)embedding_model- NOT USED (hardcoded in services)openai_embedding_model- NOT USED (hardcoded in services)deploy_host,deploy_port- NOT USED (no deployment service)nextauth_secret,nextauth_url- PARTIALLY USED (frontend env vars)next_public_api_url- USED (frontend API client)
Orchestrator LLM Settings:
provider,model,temperature,max_tokens- ✅ USEDOther parameters (top_p, frequency_penalty, etc.) - ❌ NOT USED
Performance settings - ❌ NOT USED
Model-specific settings - ❌ NOT USED
CodeGraph Settings:
provider,model- ❌ NOT USED (CodeGraph uses hardcoded OpenAI)embedding_model- ❌ NOT USED (hardcodedtext-embedding-ada-002)Other CodeGraph settings - ❌ NOT USED
Logging Settings:
All logging settings - ❌ NOT USED (Python logging configured in code)
Rate Limiting Settings:
All rate limiting settings - ❌ NOT USED (no rate limiting middleware)
Missing Settings Integration
Services don't read from system settings
Services use hardcoded values or environment variables
No real-time settings reload capability
Requirements
Phase 1: Fix Settings Persistence ✅ CRITICAL
Ensure Settings Save to Database
Verify
bulkUpdateSettings()API works correctlyAdd database transaction logging
Add frontend success/error handling
Add verification: After save, immediately fetch and verify
Fix Seed Script
Seed script should ONLY create settings if they don't exist
Seed script should NEVER overwrite existing values
Seed script should only set
default_value, notvalueif setting exists
Add Settings Validation
Validate settings before saving
Enforce validation rules from
validation_rulesfieldReturn clear error messages
Phase 2: Wire Up LLM Settings ✅ HIGH PRIORITY
Orchestrator LLM Settings
✅ Already working:
provider,model,temperature,max_tokensTODO: Add support for:
top_p,frequency_penalty,presence_penaltymax_context_length(for context window)streaming_enabled(for streaming responses)timeout_seconds(for request timeouts)
CodeGraph LLM Settings
TODO: Update
codegraph_service.pyto use:codegraph.provider(currently uses hardcoded OpenAI)codegraph.model(currently uses hardcoded GPT-3.5-turbo)codegraph.embedding_model(currently uses hardcodedtext-embedding-ada-002)
TODO: Update embedding generation to read from settings
Chatbot LLM Settings
TODO: Chatbot currently defaults to orchestrator settings
OPTIONAL: Add
chatbot.provider,chatbot.modelfor per-service config
Phase 3: Wire Up Other Settings ✅ MEDIUM PRIORITY
General Settings
environment- Wire toconfig.pyENVIRONMENT (used in IS_PRODUCTION checks)log_level- Wire to Python logging (requires runtime log level change)next_public_api_url- ✅ Already used in frontend API clientnextauth_secret,nextauth_url- Used in NextAuth config (if exists)
Embedding Settings
codegraph.embedding_model- Wire to CodeGraph embedding generationrag.embedding_model- Wire to RAG service (create setting if missing)Create unified embedding service that reads from settings
Deployment Settings
DECISION: Remove if not used, or create deployment service
If keeping, wire to deployment automation (if exists)
Phase 4: Implement Missing Features ✅ LOW PRIORITY
Logging Service
DECISION: Do we need a logging service?
If yes, implement logging service that reads from
logging.*settingsIf no, remove logging settings tab
Rate Limiting Service
DECISION: Do we need rate limiting?
If yes, implement FastAPI rate limiting middleware
Read from
rate_limiting.*settingsIf no, remove rate limiting settings tab
API Keys Tab
DECISION: Merge with General settings or keep separate?
Currently duplicates General tab settings
Recommendation: Remove if redundant
Phase 5: Settings Management ✅ ENHANCEMENTS
Real-time Settings Reload
Add API endpoint to reload settings without restart
Add signal handlers for graceful reload
Document which settings require restart
Settings Validation
Frontend validation before save
Backend validation on save
Clear error messages for invalid values
Settings History
Track settings changes (audit log)
Show who changed what and when
Allow rollback to previous values
Settings Import/Export
Export settings to JSON
Import settings from JSON
Useful for environment migrations
Implementation Plan
Step 1: Fix Seed Script ✅
File: orchestrator/seeds/seed_system_settings.py
Changes:
Step 2: Verify Settings Save ✅
Test:
Change a setting in UI
Save
Immediately refresh page
Verify setting persists
Add Debugging:
Add console.log in frontend save handler
Add logging in backend bulk update endpoint
Add verification endpoint: GET
/api/system-settings/verify/{category}/{key}
Step 3: Wire LLM Parameters ✅
File: orchestrator/services/llm_provider/manager.py
Changes:
Step 4: Wire CodeGraph Settings ✅
File: orchestrator/services/codegraph_service.py
Changes:
Step 5: Wire General Settings ✅
File: orchestrator/config.py
Changes:
Step 6: Clean Up Unused Settings ✅
Action Items:
Remove or Wire Up:
Logging Settings Tab - Either implement logging service or remove
Rate Limiting Settings Tab - Either implement rate limiting or remove
API Keys Tab - Merge with General or remove
Document What's Used:
Add comments in seed script showing which settings are active
Add validation rules indicating if setting is used
Add Settings Status Badge:
In UI, show badge: "Active" or "Not Used"
Help users understand which settings matter
Testing Checklist
Settings Persistence
LLM Settings
General Settings
Settings Validation
Success Criteria
✅ Settings Persist: All settings save to database and persist across page refreshes
✅ Settings Used: All settings shown in UI are actually used by services
✅ Clear Documentation: Each setting clearly indicates if it's active or not
✅ Validation Works: Invalid settings show clear error messages
✅ No Redundant Settings: No duplicate settings across tabs
✅ Settings Auditable: Can see when settings were changed and by whom (future)
Files to Modify
Backend
orchestrator/seeds/seed_system_settings.py- Fix seed scriptorchestrator/services/llm_provider/manager.py- Wire up all LLM parametersorchestrator/services/codegraph_service.py- Wire up CodeGraph settingsorchestrator/config.py- Wire up general settingsorchestrator/api/system_settings.py- Add verification endpoint
Frontend
frontend/components/settings/SystemSettingsTab.tsx- Improve save feedbackfrontend/components/settings/GeneralSettingsTab.tsx- Remove unused settings or wire themfrontend/components/settings/OrchestratorLLMSettingsTab.tsx- Wire up all parametersfrontend/components/settings/CodeGraphSettingsTab.tsx- Ensure settings are savedfrontend/components/settings/SystemLoggingSettingsTab.tsx- Remove or implementfrontend/components/settings/APIRateLimitingSettingsTab.tsx- Remove or implementfrontend/components/settings/BackendAPIKeysSettingsTab.tsx- Merge or remove
Migration Strategy
Phase 1 (Week 1): Fix seed script and verify settings save
Phase 2 (Week 1): Wire up all LLM settings
Phase 3 (Week 2): Wire up CodeGraph settings
Phase 4 (Week 2): Wire up general settings
Phase 5 (Week 3): Clean up unused settings tabs
Phase 6 (Week 3): Add validation and error handling
Notes
Critical: Settings must persist across page refreshes
Important: Only show settings that are actually used
Enhancement: Add settings usage indicators in UI
Future: Add settings audit log and rollback capability
Last updated

