AI Agents SDE Task Viewer
      • Context
      • Plan
      • Prd
  1. Home
  2. AgentSDE
  3. agent-core
  4. gh-439
  5. plan
  6. plan.md
plan.md(3.2 KB)· Apr 12, 2026· 2 min read
  • Summary
  • Files
  • Steps
  • Verification
  • Risks

Plan: AW-3 — Add Redis (BullMQ) to agent-core#

Summary#

Add Redis connectivity via ioredis and BullMQ queue infrastructure to agent-core, registering phase-invoke and phase-result queues and surfacing Redis health in the /health endpoint. This is the shared foundation blocking AW-4, AW-5, AW-7, and AW-9.

Files#

FileActionDescription
package.jsonmodifyAdd @nestjs/bullmq, bullmq, ioredis dependencies
src/config/config.schema.tsmodifyAdd REDIS_HOST (string, default localhost) and REDIS_PORT (number, default 6379) to Joi schema
src/app.module.tsmodifyRegister BullModule.forRootAsync() with config-driven connection, register phase-invoke and phase-result queues
src/health/health.service.tsmodifyInject Redis client (ioredis), add ping() check, return redis field in health response
src/health/health.controller.tsmodifyUpdate return type to include redis field
src/health/health.module.tsmodifyProvide the Redis IORedis client via a custom factory provider
src/health/health.controller.spec.tsmodifyUpdate test to mock Redis health and assert new response shape
src/health/health.service.spec.tscreateUnit test for HealthService covering connected and disconnected Redis states
.envmodifyAppend REDIS_HOST=localhost and REDIS_PORT=6379

Steps#

  1. Install @nestjs/bullmq, bullmq, and ioredis via npm install.
  2. Add REDIS_HOST and REDIS_PORT to configValidationSchema in src/config/config.schema.ts (after EXCLUDED_REPOS, line ~22).
  3. Append REDIS_HOST=localhost and REDIS_PORT=6379 to .env.
  4. Import BullModule from @nestjs/bullmq in src/app.module.ts. Add BullModule.forRootAsync() with ConfigService injection (reading REDIS_HOST and REDIS_PORT) after AppConfigModule. Register phase-invoke and phase-result queues via BullModule.registerQueue().
  5. Create a custom Redis provider in src/health/health.module.ts using ioredis (new Redis({ host, port }) from ConfigService), inject it into HealthService.
  6. Update HealthService.getHealth() to call redis.ping(), return { status, uptime, redis } where redis is "connected" or "disconnected".
  7. Update HealthController return type to match the new response shape.
  8. Update existing health.controller.spec.ts and create health.service.spec.ts — mock Redis client, test connected/disconnected paths.
  9. Run npm run build, npm run test, npm run lint to verify.

Verification#

  • npm run build compiles cleanly with zero errors.
  • npm run test passes with no regressions; new health specs pass.
  • npm run lint reports zero warnings.

Risks#

  • BullMQ startup failure blocks boot: Redis unavailable at startup should cause a hard failure (fail fast). Verify BullModule.forRootAsync() propagates connection errors to NestJS bootstrap — if it silently swallows, add an onModuleInit Redis ping guard.
  • ioredis dual usage: Both BullMQ (internal) and HealthService (explicit) use ioredis. Use a separate Redis instance for health checks to avoid coupling health probes to BullMQ's internal connection lifecycle.
ContextPrd