Skip to content

Add Bot Manager for Bot Lifecycle Coordination#113

Merged
tgrunnagle merged 5 commits into
mainfrom
issue_98_bot_manager_2026-01-26
Jan 27, 2026
Merged

Add Bot Manager for Bot Lifecycle Coordination#113
tgrunnagle merged 5 commits into
mainfrom
issue_98_bot_manager_2026-01-26

Conversation

@tgrunnagle
Copy link
Copy Markdown
Owner

Closes #98

Summary

Implements BotManager, the central coordinator for bot lifecycle management in the Bot Service. This component bridges the REST API layer with bot runners and WebSocket clients, enabling spawning bots into game rooms, loading trained neural network models from the ModelRegistry, and managing multiple concurrent bot instances.

Changes Made

bot2/

  • Added BotManager class in bot/service/bot_manager.py with full lifecycle management:
    • spawn_bot() creates bots and connects them in background tasks
    • destroy_bot() gracefully stops and removes bots
    • get_bot() and list_bots() for status queries
    • list_models() returns available models from registry
    • shutdown() for graceful service termination
  • Added Pydantic models: BotConfig, SpawnBotRequest, SpawnBotResponse, BotInfo
  • Updated bot runner constructors to accept optional client parameter (set later by WebSocketBotClient)
  • Exported new types from bot/service/__init__.py

Implementation Details

  • Bot IDs use human-readable format: bot_{uuid_hex[:12]}
  • Background connection via asyncio.create_task() allows immediate API response while bot connects
  • BotConfig validates that rule-based bots cannot specify model parameters, and neural network bots must provide either model_id or generation
  • Failed background connections are automatically cleaned up from the bot registry

Testing

  • Added 1000+ lines of unit tests covering:
    • Initialization with and without registry
    • Spawning rule-based and neural network bots
    • Model loading by ID and by generation
    • Error handling (missing model, no registry, invalid config)
    • Unique bot ID generation
    • Bot destruction and status queries
    • Graceful shutdown
    • Pydantic model validation
  • Tests use mocking to avoid actual network connections and model loading

@tgrunnagle tgrunnagle merged commit 19cd723 into main Jan 27, 2026
5 checks passed
@tgrunnagle tgrunnagle deleted the issue_98_bot_manager_2026-01-26 branch January 27, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bot Manager

1 participant