[ORCH-109] Agent lifecycle management #244

Closed
opened 2026-02-02 21:08:16 +00:00 by jason.woltje · 0 comments
Owner

Manage agent states through lifecycle (spawning → running → completed/failed/killed).

Acceptance Criteria

  • src/spawner/agent-lifecycle.service.ts implemented
  • State transitions: spawning → running → completed/failed/killed
  • State persisted in Valkey
  • Events emitted on state changes (pub/sub)
  • Agent metadata tracked (startedAt, completedAt, error)
  • State machine enforces valid transitions only
  • Comprehensive unit tests with 100% coverage
  • Service exported from SpawnerModule

Implementation Summary

Created AgentLifecycleService that manages agent state transitions with:

  • Valid state transitions enforced via state machine
  • State persistence in Valkey
  • Pub/sub events on state changes
  • Metadata tracking (startedAt, completedAt, error)
  • 28 comprehensive unit tests with 100% coverage

Files Modified

  • apps/orchestrator/src/spawner/agent-lifecycle.service.ts (created)
  • apps/orchestrator/src/spawner/agent-lifecycle.service.spec.ts (created)
  • apps/orchestrator/src/spawner/spawner.module.ts (updated)
  • apps/orchestrator/src/spawner/index.ts (updated)
  • docs/scratchpads/orch-109-lifecycle.md (created)

Dependencies

  • Depends on: ORCH-105 (agent spawner), ORCH-107 (Valkey), ORCH-108 (task queue)
  • Blocks: ORCH-117 (Killswitch)

Technical Notes

State machine enforces valid transitions only. All state changes are persisted to Valkey and emit pub/sub events for real-time monitoring.

Manage agent states through lifecycle (spawning → running → completed/failed/killed). ## Acceptance Criteria - [x] src/spawner/agent-lifecycle.service.ts implemented - [x] State transitions: spawning → running → completed/failed/killed - [x] State persisted in Valkey - [x] Events emitted on state changes (pub/sub) - [x] Agent metadata tracked (startedAt, completedAt, error) - [x] State machine enforces valid transitions only - [x] Comprehensive unit tests with 100% coverage - [x] Service exported from SpawnerModule ## Implementation Summary Created AgentLifecycleService that manages agent state transitions with: - Valid state transitions enforced via state machine - State persistence in Valkey - Pub/sub events on state changes - Metadata tracking (startedAt, completedAt, error) - 28 comprehensive unit tests with 100% coverage ## Files Modified - apps/orchestrator/src/spawner/agent-lifecycle.service.ts (created) - apps/orchestrator/src/spawner/agent-lifecycle.service.spec.ts (created) - apps/orchestrator/src/spawner/spawner.module.ts (updated) - apps/orchestrator/src/spawner/index.ts (updated) - docs/scratchpads/orch-109-lifecycle.md (created) ## Dependencies - Depends on: ORCH-105 (agent spawner), ORCH-107 (Valkey), ORCH-108 (task queue) - Blocks: ORCH-117 (Killswitch) ## Technical Notes State machine enforces valid transitions only. All state changes are persisted to Valkey and emit pub/sub events for real-time monitoring.
jason.woltje added this to the M6-AgentOrchestration (0.0.6) milestone 2026-02-02 21:08:16 +00:00
jason.woltje added the orchestrator label 2026-02-02 21:08:16 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mosaic/stack#244