---
issue: 160
title: Update Slide-System Integration
analyzed: 2025-10-22T08:13:56Z
estimated_hours: 6-8
parallelization_factor: 1.5
---

# Parallel Work Analysis: Issue #160

## Overview

Modify slide-system Motia steps to call bot-spawner HTTP API instead of directly spawning Python processes. This completes the service separation by replacing `spawn()` calls with HTTP `fetch()` requests, adding error handling, retry logic, and proper logging.

The work can be parallelized by having different agents work on the two separate bot spawn endpoints simultaneously.

## Parallel Streams

### Stream A: LiveKit Screenshare Bot Integration
**Scope**: Update `bot-spawn-livekit.step.ts` to use HTTP API
**Files**:
- `apps/slide-system/steps/bot-spawn-livekit.step.ts`
**Agent Type**: backend-specialist
**Can Start**: immediately
**Estimated Hours**: 3-4
**Dependencies**: none

**Tasks**:
- Replace `spawn()` calls with HTTP `fetch()` to bot-spawner
- Implement retry logic with exponential backoff (3 attempts)
- Add comprehensive error handling for HTTP failures
- Add request/response logging
- Test locally with voice-demo-ui

### Stream B: Tool Forwarder Bot Integration
**Scope**: Update `tool-forwarder-spawn.step.ts` to use HTTP API
**Files**:
- `apps/slide-system/steps/tool-forwarder-spawn.step.ts`
**Agent Type**: backend-specialist
**Can Start**: immediately
**Estimated Hours**: 3-4
**Dependencies**: none

**Tasks**:
- Replace `spawn()` calls with HTTP `fetch()` to bot-spawner
- Implement same retry logic pattern as Stream A
- Add same error handling pattern as Stream A
- Add request/response logging
- Test locally

### Stream C: Environment Configuration & Deployment
**Scope**: Update Railway environment variables and deploy
**Files**:
- Railway configuration (environment variables)
- Documentation updates
**Agent Type**: fullstack
**Can Start**: after Streams A & B complete
**Estimated Hours**: 1-2
**Dependencies**: Streams A & B

**Tasks**:
- Add `BOT_SPAWNER_URL` environment variable to slide-system
- Update Railway staging environment
- Deploy to staging
- Run end-to-end validation tests
- Document rollback procedure

## Coordination Points

### Shared Patterns
Both streams should use identical patterns for:
- **HTTP client code**: Same fetch() wrapper with timeout
- **Retry logic**: Same exponential backoff (2s, 4s, 8s)
- **Error handling**: Same error classification (503, 400, 500, timeout)
- **Logging format**: Same log message structure for consistency

### Code Reuse Strategy
Create a shared helper function `spawnBotViaHttp()` that both streams can use:
```typescript
// apps/slide-system/utils/bot-spawner-client.ts
export async function spawnBotViaHttp(endpoint: string, payload: any) {
  // Shared retry + error handling logic
}
```

### Sequential Requirements
1. Streams A & B can run in parallel (different files)
2. Stream C starts after A & B complete (needs code deployed)
3. End-to-end testing after Stream C (needs staging deployment)

## Conflict Risk Assessment

**Low Risk**: Streams A & B work on completely separate files with no overlap.

**Coordination Needed**:
- Both streams should follow the same coding patterns (suggest creating shared utility first)
- Both streams need to use the same `BOT_SPAWNER_URL` environment variable name
- Logging format should be consistent for ops team

**No File Conflicts**: Zero risk of merge conflicts since files are completely separate.

## Parallelization Strategy

**Recommended Approach**: Hybrid

**Phase 1 (Parallel)**: Launch Streams A & B simultaneously
- Both work independently on separate files
- Can optionally create shared utility first, then both streams use it
- Estimated wall time: 3-4 hours

**Phase 2 (Sequential)**: Stream C after A & B complete
- Deploy integrated code to staging
- Run end-to-end tests
- Estimated wall time: 1-2 hours

**Total Wall Time**: 4-6 hours (with parallel execution)

## Expected Timeline

**With parallel execution:**
- Wall time: 4-6 hours
- Total work: 7-10 hours
- Efficiency gain: ~40%

**Without parallel execution:**
- Wall time: 7-10 hours

## Notes

**Risk Mitigation:**
- Create shared utility function first to ensure consistency
- Both streams should review each other's code before merge
- Test each endpoint independently before combined testing

**Optimization:**
- If only one engineer available, do Stream A first (higher priority - voice demo)
- Stream B can be done immediately after with copy-paste + minor adjustments
- Pattern will be established by Stream A, making Stream B faster

**Testing Strategy:**
- Stream A: Test with voice-demo-ui locally
- Stream B: Test with tool-forwarder scenarios locally
- Stream C: Full integration testing on Railway staging

**Rollback Plan:**
- Keep old spawn() code commented out for easy rollback
- Document exact steps to revert if bot-spawner fails
