Introduction¶
The philosophy behind DeepSeek Harness (DSH) is “everything is a plugin,” where each plugin solves a specific problem for the Agent in a particular scenario. In a game context, the Agent needs the ability to read UI state and execute discrete actions in order to make decisions in rule-based games. The dsh-sts2 plugin provides a set of tools for the DSH Agent targeting Slay the Spire 2, communicating with the STS2 AI Agent mod via a local HTTP API—no screen capture or pixel guessing required.
What Is This¶
dsh-sts2 is a DSH plugin maintained by OrdinaryTu, categorized under “Workflow.” It provides a suite of tools that allow the Agent to read game state (combat, map, rewards, shop, etc.) and perform actions (play cards, make choices, interact, etc.), along with a quick-fight module and a persistent background auto-play runner.
The plugin works through the STS2 AI Agent’s local HTTP API. It does not take screenshots or guess pixels—all actions are based on data fields exposed by the mod.
Core Features¶
The plugin provides the following tools:
sts2_launch: Launches the game and waits for the mod API to be ready. Prefers Steam (appid 2868840); falls back to launching the exe directly if that fails. If the game is already running, it simply waits for the API.sts2_status: Checks mod health, game version, current screen, save profile, and available actions.sts2_state: Retrieves the full state, including screen / session / available_actions / combat / map / reward / event / shop / rest, etc.sts2_brief: A compact view containing only screen, turn, available actions, hand, enemy intent/threat, and map/reward options—ideal for reducing context over multiple consecutive turns.sts2_act: Executes a single action. The parameter is a JSON object, e.g.,play_card,end_turn,choose_map_node,claim_reward,choose_event_option,use_potion, etc.sts2_autofight: Quick combat. Automatically fights regular mobs for up to N turns (default 8): kills if a lethal hit is possible, blocks when in danger, and applies Demon Form / Vulnerable when safe. Stops when encountering a reward / event / screen change.sts2_runner_start: Starts the persistent background runner, which directly loops through combat / rewards / map / events / rest / shop / chest / card selection. Automatically restarts on failure; plays up to 4 runs.sts2_runner_status: Checks the runner heartbeat, including the status file, current screen/floor/HP, and recent logs.sts2_runner_stop: Stops the runner by writing a stop marker and terminating the process.sts2_guide: Action quick-reference and basic strategy tips.
Version Requirements¶
| Game | Mod |
|---|---|
| v0.111.x (current machine) | STS2 AI Agent v0.18.0 |
| v0.113.0+ (Dread & Blitz) | v0.19.x |
v0.19.x references MegaCrit.Sts2.Core.Nodes.Screens.Blitz.NBlitzScreen in the game; v0.111.1 does not have this type, so /state will return 500. Do not upgrade the mod before upgrading the game.
Game-Side Installation¶
- Download
sts2-ai-agent-v0.18.0-windows.zip. - Copy the three files from the
mod/folder in the archive to the game directory:
E:\SteamLibrary\steamapps\common\Slay the Spire 2\mods\
STS2AIAgent.dll
STS2AIAgent.pck
mod_id.json
- Launch the game from Steam. Installation is successful when the following two lines appear in the log:
[STS2AIAgent] Ready on http://127.0.0.1:8081/
--- RUNNING MODDED! --- Loaded 1 mods
If the port is occupied, it will increment from 8080 upward; the plugin automatically scans 8080–8090. You can also specify it directly via DSH_STS2_URL.
Plugin Installation¶
Local Directory (Current Machine)¶
Directory: E:\smallDSH\伴侣\sts2-plugin. Enable dsh-sts2 in the DSH plugin manager, or:
dsh plugin --profile desktop add E:\smallDSH\伴侣\sts2-plugin
Distribution Package¶
Unpacking dsh-sts2-0.1.0.zip yields a complete plugin directory. Select “Install bundle” in the DSH plugin manager and point it to that directory, or:
dsh plugin --profile desktop add <unpacked directory>
Once installed, simply enable it. The tools will appear in the next session; there is no need to restart the game.
Launching the Game¶
{ "wait_seconds": 120 }
sts2_launch will:
- First check if
SlayTheSpire2.exeis already running; if so, it simply waits for the API; - If not running, launch via
steam://rungameid/2868840from Steam; - If Steam fails to launch it, attempt to directly launch
E:\SteamLibrary\steamapps\common\Slay the Spire 2\SlayTheSpire2.exe; - Poll the mod’s
/healthendpoint every 2 seconds until it is ready or times out.
Current measured performance: Steam launch to mod API ready takes approximately 9 seconds, returning screen: MAIN_MENU. After launching, you still need to use sts2_status / sts2_act to progress—the game will not automatically start a new run.
Configuration¶
| Environment Variable | Default | Description |
|---|---|---|
DSH_STS2_PROFILE |
2 |
Expected save slot number; sts2_act checks this before every action and rejects if mismatched |
DSH_STS2_URL |
Auto | e.g., http://127.0.0.1:8081; if unset, scans 8080–8090 |
DSH_STS2_APPID |
2868840 |
Steam appid used for launching |
DSH_STS2_EXE |
Current Steam library path | Game exe to launch directly if Steam launch fails |
Save Isolation (Important)¶
- By default, only operates on profile2; the main save profile1 has a full backup at
E:\smallDSH\伴侣\backups\sts2-save-20261117. native_profile_idis read before every action; if it is not 2, an error is returned and no writes are performed.- When switching to a different save, explicitly set
DSH_STS2_PROFILE—do not modify code directly. save_and_quitstill exists but will not be called automatically.
Quick Combat¶
For regular mobs, use sts2_autofight instead of asking the model for every card:
{ "max_turns": 6, "stop_hp": 20 }
max_turns: Maximum number of player turns to fight (1–20, default 8)stop_hp: Stop fighting when HP drops below this value and hand back to the model for manual handling (default 0, no threshold)
It uses very basic heuristics: kill if a lethal hit is possible, block if about to die, and apply Demon Form / Burn / Rage when safe, then play cards based on damage and energy. Battles against Bosses, Elites, with very low HP, or requiring potion management should be played manually; it does not use potions and does not read Boss-specific mechanics.
Persistent Runner (Recommended for Background Auto-Play)¶
sts2_runner_start spawns a separate Node process autoplay.mjs that bypasses model turns and directly loops through:
COMBAT → REWARD → MAP → EVENT → REST → SHOP → CHEST → CARD_SELECTION
It automatically restarts on failure: GAME_OVER → Main Menu → Character Selection → Embark—it will not stall on the results screen. Each run picks a character from the available roster and tries not to repeat the previous run’s choice. By default, no time limit, plays up to 4 runs (including the current one at startup); it exits only after 4 runs are completed, 5 consecutive errors, or sts2_runner_stop.
There is also a separate watchdog.mjs external watchdog: if the runner process disappears, it auto-restarts; if the process is alive but the heartbeat has been silent for over 5 minutes, it kills and restarts it; auto-restarts are capped at 6 per hour; autoplay.stop stops the watchdog as well.
Launch ownership: the runner is only auto-started when sts2_launch actually launches the game; games launched manually by the user will not be auto-taken-over. sts2_runner_start refuses by default for user-launched games; pass force: true if you truly want to take over. sts2_runner_stop clears the “launched by us” state.
Game mod toggle: The plugin normally renames mods/STS2AIAgent.dll, .pck, and mod_id.json to .disabled, so manually launching the game won’t load the mod. sts2_launch restores them only right before actually launching, and re-disables them after the game exits. Backups are kept in the plugin’s mod-backup/ directory. The trade-off is that mod files get renamed, and disabling won’t unload the mod while the game is still open.
- Heartbeat:
autoplay-status.json(containsruns_started/max_runs) - Process log:
autoplay.log - Watchdog:
autoplay-watchdog.json/autoplay-watchdog.log - Stop:
sts2_runner_stop, or writeautoplay.stop
Do not let both a goal and the runner drive the same run simultaneously: Stop/complete the goal before starting the runner, or both will fight over actions.
{ "run_id": "current run_id", "max_minutes": 0, "max_runs": 4 }
Usage Tips¶
- At the start of a run, call
sts2_statusfirst to confirm mod status, port, and save profile. - Each turn:
sts2_brieffirst, thensts2_act, thensts2_briefagain after the action. Do not reuse hand card indices from the previous turn—the hand gets reshuffled. - A failed
play_card(409invalid_action/invalid_target) will not blindly retry, to avoid hitting a different card with the same index; re-read the state and decide again. The plugin only retries once (800ms) foraction_in_flightandinvalid_actiononend_turn. - During card order / turn transitions, state may lag by half a beat: if
pendingorstable:falseis returned, wait 0.5–1 second before re-reading—don’t fire requests back-to-back. - The mod’s
instance_role=humanmeans it won’t auto-play; do not enable the mod’s built-in auto-play, or it will conflict with external actions.
Common Errors¶
| Symptom | Cause / Fix |
|---|---|
404 / API not found |
Mod not loaded, or port is not 8081; check logs, or set DSH_STS2_URL |
/state 500 NBlitzScreen |
Mod version too new; on v0.111.1, revert to v0.18.0 |
403 / profile mismatch |
Current save is not profile 2; switch saves, or change DSH_STS2_PROFILE |
409 invalid_target |
Index is stale (buying cards, card selection, hand reshuffle); re-read state |
409 action_in_flight |
Previous action hasn’t finished; wait for it to complete, don’t fire again |
| Energy/hand empty at turn start | State not yet stable; wait 1 second and re-read |
Known Limitations¶
- Windows only + local single-player; the mod’s API is a community implementation with occasional 500s / state desyncs.
- Strict version coupling: after a game update, you must switch to the corresponding mod version, or the API may break entirely.
- No screen capture/OCR; on-screen animations do not enter the state—only fields exposed by the mod.
- No guarantee the Agent will win;
sts2_autofightis heuristic only and may skip blocking to chase damage when HP is very low. - Auto-playing regular mobs while manually handling Bosses/Elites within a run is the current trade-off between speed and stability.
Files¶
| File | Purpose |
|---|---|
index.js |
Port discovery, HTTP client, five tools, state compression, save check |
package.json |
Plugin manifest and DSH bundle declaration |
cordis.patch.yml |
Inserts dsh-sts2 into the profile |
locale/*.json |
Titles and descriptions for the plugin manager |
icon.svg |
Plugin icon |
LICENSE |
MIT |
License¶
MIT
Applicable Scenarios & Notes¶
This plugin runs with the current DSH process’s permissions. Review the source code and license before installation. The plugin is for local single-player use only and does not make network requests or upload data. Ensure the corresponding STS2 AI Agent mod is installed and that the game directory and port are configured according to the documentation before use.
Closing¶
dsh-sts2 gives the DeepSeek Harness Agent control capabilities in Slay the Spire 2, including state reading, action execution, quick combat, and persistent background auto-play. If you need the Agent to make decisions in a rule-based game, refer to the typical usage patterns in the plugin documentation.
- Directory page: https://www.skillhub.cn/plugins/OrdinaryTu/dsh-sts2
- GitHub: https://github.com/OrdinaryTu/dsh-sts2