Spaces:
Paused
Paused
π Bug Fixes - autonomousRouter.ts & MCPIntegration.ts
Date: 2025-11-24
Status: β
Fixed
Bug 1: Race Condition in setWebSocketServer() β
FIXED
Issue:
setWebSocketServer()function checkedif (agent)butagentwas declared AFTER the function- If
setWebSocketServer()was called beforeinitAutonomousAgent(), the check would always fail - Agent would be created with
nullwsServer
Fix:
- Moved
agentdeclaration BEFOREsetWebSocketServer()function - Now the check works correctly regardless of initialization order
- Agent will receive wsServer when it's set, even if set before initialization
Location: apps/backend/src/mcp/autonomousRouter.ts:20-37
Bug 2: Inconsistent stmt.all() Usage β
VERIFIED CORRECT
Issue:
- Line 198:
stmt.all(limit)- passes single parameter - Line 230:
stmt.all()- no parameters - Pattern inconsistent with other codebase usage
Analysis:
- After reviewing codebase,
stmt.all(limit)is correct for sqlite3 - The database interface shows
all: (...params)accepts variadic parameters - Single parameter
stmt.all(limit)works correctly - No changes needed - code is correct
Location: apps/backend/src/mcp/autonomousRouter.ts:198, 230
Bug 3: operation Parameter Not Used in MCP Routing β
FIXED
Issue:
query()function acceptsopparameter but never uses it- Routing only uses
toolName, so different operations are indistinguishable - All operations on same tool route identically
Fix:
- Added
operation: opto payload when routing throughmcpRegistry.route() - MCP tool handlers can now access
payload.operationto distinguish operations - Enables proper operation-based routing
Location: apps/backend/src/mcp/autonomous/MCPIntegration.ts:48-58
Testing
β
Build passes
β
No linting errors
β
Race condition fixed
β
Operation parameter included in routing
Status: β All bugs fixed and verified