How chartyr/sts2-agent works
STS2 AI Agent is an in-game Slay the Spire 2 companion mod with autonomous play, a configurable overlay, local APIs, and an optional co-op teammate. The player starts auto-play through the overlay; the runtime coordinates turns, obtains game state, requests model decisions, and dispatches game actions. Separate branches provide co-op coordination, live events, and developer access through HTTP/MCP. Relationships are grounded in the README and indexed excerpts; unsampled implementation details are represented conservatively.
Main entry points: AgentRuntime.cs Agent runtime · GameStateService.cs Game state · AgentLoop.cs Auto-play loop · Router.cs API routes
Components 25
Mod and Overlay
- Mod startup
STS2AIAgent/ModEntry.cs - In-game overlay
STS2AIAgent/Ui/AgentOverlayHost.cs - Settings and models
STS2AIAgent/Config/AgentSettings.cs
Gameplay Runtime
- Agent runtime
STS2AIAgent/Agent/AgentRuntime.cs - Auto-play loop
STS2AIAgent/Agent/AgentLoop.cs - Strategy planning
STS2AIAgent/Agent/StrategyPlanner.cs - Session guards
STS2AIAgent/Agent/SessionBudgetGuard.cs - Play history
STS2AIAgent/Agent/PlaySessionStore.cs - Chat completion client
STS2AIAgent/Llm/OpenAiCompatibleClient.cs
Game Integration
- Game bridge
STS2AIAgent/Agent/GameBridge.cs - Game state
STS2AIAgent/Game/GameStateService.cs - Game actions
STS2AIAgent/Game/GameActionService.cs - Game-thread dispatch
STS2AIAgent/Game/GameThread.cs - Screenshot capture
STS2AIAgent/Vision/ScreenshotService.cs
Local Services
- HTTP API
STS2AIAgent/Server/HttpServer.cs - API routes
STS2AIAgent/Server/Router.cs - Game event stream
STS2AIAgent/Server/GameEventService.cs - Native MCP server
STS2AIAgent/Server/NativeMcpServer.cs
Co-op Companion
- Co-op coordination
STS2AIAgent/Multiplayer/DualInstanceCoordinator.cs - Team conversation
STS2AIAgent/Multiplayer/TeamConversation.cs
Other components
- Player
- LLM endpoint
- Slay the Spire 2
- External agent tools
- Companion instance
Connections 33
- Player → In-game overlay: opens and controls
README.md - Mod startup → In-game overlay: initializes
STS2AIAgent/ModEntry.cs - Mod startup → Agent runtime: initializes
STS2AIAgent/ModEntry.cs - Mod startup → HTTP API: starts
STS2AIAgent/ModEntry.cs - In-game overlay → Settings and models: configures
STS2AIAgent/Ui/AgentOverlayHost.Settings.cs - In-game overlay → Agent runtime: controls play
STS2AIAgent/Ui/AgentOverlayHost.Settings.cs - Agent runtime → Auto-play loop: starts turns
STS2AIAgent/Agent/AgentRuntime.cs - Agent runtime → Game bridge: creates
STS2AIAgent/Agent/AgentRuntime.cs - Agent runtime → Play history: stores sessions
STS2AIAgent/Agent/AgentRuntime.cs - Agent runtime → Native MCP server: binds runtime
STS2AIAgent/Agent/AgentRuntime.cs - Auto-play loop → Strategy planning: plans decisions
- Auto-play loop → Session guards: checks limits
- Auto-play loop → Chat completion client: requests decisions
- Settings and models → Chat completion client: configures endpoint
- Chat completion client → LLM endpoint: sends completions
STS2AIAgent/Llm/OpenAiCompatibleClient.cs - Game bridge → Game state: reads state
- Game bridge → Game actions: dispatches actions
- Game state → Slay the Spire 2: observes
STS2AIAgent/Game/GameStateService.cs - Game actions → Slay the Spire 2: executes actions
STS2AIAgent/Game/GameActionService.cs - Game actions → Game-thread dispatch: dispatches game work
STS2AIAgent/Game/GameActionService.cs - Game state → Game-thread dispatch: builds state on
STS2AIAgent/Server/GameEventService.cs - Screenshot capture → Game-thread dispatch: captures on
STS2AIAgent/Vision/ScreenshotService.cs - HTTP API → API routes: routes requests
STS2AIAgent/Server/HttpServer.cs - API routes → Agent runtime: controls agent
STS2AIAgent/Server/Router.cs - API routes → Game state: serves state
STS2AIAgent/Server/Router.cs - API routes → Game actions: dispatches actions
STS2AIAgent/Server/Router.cs - Game event stream → Game state: polls state
STS2AIAgent/Server/GameEventService.cs - External agent tools → HTTP API: uses API
README.md - External agent tools → Native MCP server: connects via MCP
README.md - Agent runtime → Co-op coordination: coordinates launch
STS2AIAgent/Agent/AgentRuntime.cs - Agent runtime → Team conversation: handles team chat
STS2AIAgent/Agent/AgentRuntime.cs - Co-op coordination → Companion instance: launches instance
README.md - Player → Team conversation: sends instructions
README.md