Skip to main content

Critical Risks (P0)

1. Missing Return Statements in LLMFactory.get_turn_detection()

File: agent-studio-livekit-agent/plugins/llm.py The get_turn_detection() method has conditional branches that construct config objects but lack explicit return statements, resulting in None. Impact: Turn detection silently fails — the agent may not detect when a user has stopped speaking. Fix: Add explicit return statements in both if and else branches.

2. Hardcoded Database Credentials in docker-compose.yml

File: agent-studio-backend/docker-compose.yml PostgreSQL credentials are hardcoded rather than injected via environment variables. Fix: Use ${PG_PASSWORD} environment variable interpolation or Docker Secrets.

3. Broad CORS Configuration

File: agent-studio-backend/app/main.py CORS configured with allow_origins=["*"] and allow_credentials=True.
Any domain can make authenticated requests to the API.
Fix: Restrict to specific origins: [settings.FRONTEND_URL, settings.WIDGET_URL]

4. datetime.now() as Default Column Value

Files: Multiple models (user.py, workspace.py, campaign.py, batch_call.py) Using default=datetime.now() (with parentheses) evaluates once at import time — all records share the same timestamp. Fix: Use default=datetime.utcnow (without parentheses) or server_default=func.now()

High Risks (P1)

5. Confusing Table Naming: SIPlogs

The SIP model uses __tablename__ = "logs", conflicting with the intuitive expectation that logs would contain call logs. Fix: Rename table to sip_trunks with a migration.

6. Unused Legacy Files

agent1.py and agent6.py appear to be older versions of agent.py that are no longer referenced. Fix: Archive or delete after confirming they’re unused.

7. Broad Exception Handling

except Exception as e:
    log.error(f"Error: {e}")
    return {"error": str(e)}
Impact: Masks unexpected errors; makes debugging difficult. Fix: Catch specific exception types. Use Sentry or similar error tracking.

8. No Database Connection Pooling Configuration

SQLAlchemy engine created with default pool settings. Pool exhaustion is possible under load. Fix: Configure pool_size, max_overflow, pool_pre_ping=True.

9. Auth Creates Extra DB Session

get_current_user() creates its own SessionLocal() instead of the request-scoped get_db() — two separate connections per request. Fix: Refactor to accept db: Session = Depends(get_db).

Medium Risks (P2)

10. Campaigns Use BackgroundTasks Instead of Celery

Campaigns use FastAPI BackgroundTasks — no retry, no persistence, dies with process. Fix: Migrate to Celery for consistency with batch jobs.

11. Mixed Async/Sync Patterns

Some async def handlers use synchronous DB operations; others have async handlers calling sync services. Fix: Standardize on async with run_in_executor() or fully synchronous handlers.

12. No Rate Limiting on Public Endpoints

/calls/generate-token, /auth/login, /auth/signup have no rate limiting. Fix: Add rate limiting via slowapi or nginx-level throttling.

13. Knowledge Base Files Stored Locally

Uploaded files are stored in uploads/{agent_id}/ — lost on container restart unless volume mounted. Fix: Migrate to S3 or persistent shared storage.

14. Missing Test Suite

No test files found in the repository.
This is the single biggest risk for ongoing development velocity.
Fix: Implement unit tests for auth flow, agent CRUD, batch dispatch, cost calculation, SIP provisioning.

15. Incomplete Invite Flow

workspaces.py:invite_member() has TODO: real invite flow. If user doesn’t exist, invite is silently ignored. Fix: Implement email-based invite with token verification.

Low Risks (P3)

#RiskEffort
16No pagination for agent listLow
17Inconsistent error response formatMedium
18Multiple DB connections in agent workerMedium
19No API versioning (/v1/ prefix)Medium
20Missing input validation on some endpointsMedium

Summary Table

#RiskSeverityEffortStatus
1Missing return in get_turn_detection()P0LowOpen
2Hardcoded DB credentialsP0LowOpen
3Broad CORSP0LowOpen
4datetime.now() bugP0LowOpen
5SIPlogs table nameP1MediumOpen
6Unused agent filesP1LowOpen
7Broad exception handlingP1HighOpen
8No DB pool configP1LowOpen
9Auth creates extra DB sessionP1MediumOpen
10Campaigns not on CeleryP2MediumOpen
11Mixed async/syncP2HighOpen
12No rate limitingP2LowOpen
13Local file storageP2MediumOpen
14No test suiteP2HighOpen
15Incomplete invite flowP2MediumOpen
16–20Low-priority itemsP3VariousOpen