[PR #351] [MERGED] Agent control: wait for a state, and the log of what happened #2511

Closed
opened 2026-11-02 15:56:49 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/351
Author: @ludovic111
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/15/2026
Merged by: @ludovic111

Base: main ← Head: feat/agent-waits


📝 Commits (1)

  • 0892f94 Agent control: wait for a state, and the log of what happened

📊 Changes

9 files changed (+418 additions, -4 deletions)

View changed files

📝 crates/horizon-client/src/bin/horizon-ctl/commands.rs (+7 -0)
📝 crates/horizon-client/src/chat.rs (+3 -0)
📝 crates/horizon-client/src/game.rs (+4 -0)
📝 crates/horizon-client/src/game/agent.rs (+8 -1)
📝 crates/horizon-client/src/game/control.rs (+7 -0)
➕ crates/horizon-client/src/game/events.rs (+338 -0)
📝 crates/horizon-client/src/game/ui_control.rs (+1 -1)
📝 docs/native-client.md (+7 -0)
📝 tools/agent_control_e2e.py (+43 -2)

📄 Description

What. Step 4 of docs/agent-control.md (#321). Stacked on the options PR.

  • wait-for screen NAME|widget ID|loaded|chat TEXT|event KIND [--timeout S] [--since SEQ] replies once the game gets there; a timeout (default 30 s) is {"error": "timed out after 5 s; the screen is playing", "kind": "timeout"}. chat and event count from --since (take last from events before acting) so a fast event can't slip in before the wait
  • events [--since SEQ]: what happened, oldest first, numbered, with the tick: screen (from, to), chat (text), death, respawn, item (item, delta), dimension, world (opened, closed); the newest 256 are kept
  • state is compared once per event loop turn, only under --control; nothing hooks game logic. The chat log counts the messages it received
  • respawn now says when the death screen's button is not active yet (vanilla enables it after 20 ticks) instead of clicking it to no effect
  • horizon-ctl and its MCP gain both; tools/agent_control_e2e.py gains an events scenario (create a world, wait loaded, item, chat, screen, death, respawn, a timeout, then the log)

A streaming subscribe is the next step (listed in the doc); MCP tools reply once, so events is what MCP needs.

How tested.

cargo fmt --all --check: ok
cargo clippy --workspace --all-targets -- -D warnings: ok
cargo test -p horizon-client: 721 passed, 0 failed (at the top of the stack)
tools/parity.py --changed origin/main on the stack top (ui + options + waits, one integration run): 80 harnesses, 80 passed, 0 failed
  (the UI-tree branch alone: 80/80 before its last one-line tweak, then 60/78 of the rerun before the stack run took over)
tools/agent_control_e2e.py on the Mac mini, real game offscreen, CLI and MCP: survival PASS, ui PASS, options PASS, events PASS

Unit tests: game::events::tests (diffs, the numbered ring, parsing).

Needs Ludovic. Nothing.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/351 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/agent-waits` --- ### 📝 Commits (1) - [`0892f94`](https://github.com/horizon-rust/horizon/commit/0892f944c024f5b3d2c8a92e726586fa7e3b949e) Agent control: wait for a state, and the log of what happened ### 📊 Changes **9 files changed** (+418 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/bin/horizon-ctl/commands.rs` (+7 -0) 📝 `crates/horizon-client/src/chat.rs` (+3 -0) 📝 `crates/horizon-client/src/game.rs` (+4 -0) 📝 `crates/horizon-client/src/game/agent.rs` (+8 -1) 📝 `crates/horizon-client/src/game/control.rs` (+7 -0) ➕ `crates/horizon-client/src/game/events.rs` (+338 -0) 📝 `crates/horizon-client/src/game/ui_control.rs` (+1 -1) 📝 `docs/native-client.md` (+7 -0) 📝 `tools/agent_control_e2e.py` (+43 -2) </details> ### 📄 Description **What.** Step 4 of `docs/agent-control.md` (#321). Stacked on the options PR. - `wait-for screen NAME|widget ID|loaded|chat TEXT|event KIND [--timeout S] [--since SEQ]` replies once the game gets there; a timeout (default 30 s) is `{"error": "timed out after 5 s; the screen is playing", "kind": "timeout"}`. `chat` and `event` count from `--since` (take `last` from `events` before acting) so a fast event can't slip in before the wait - `events [--since SEQ]`: what happened, oldest first, numbered, with the tick: `screen` (from, to), `chat` (text), `death`, `respawn`, `item` (item, delta), `dimension`, `world` (opened, closed); the newest 256 are kept - state is compared once per event loop turn, only under `--control`; nothing hooks game logic. The chat log counts the messages it received - `respawn` now says when the death screen's button is not active yet (vanilla enables it after 20 ticks) instead of clicking it to no effect - `horizon-ctl` and its MCP gain both; `tools/agent_control_e2e.py` gains an `events` scenario (create a world, wait loaded, item, chat, screen, death, respawn, a timeout, then the log) A streaming `subscribe` is the next step (listed in the doc); MCP tools reply once, so `events` is what MCP needs. **How tested.** ``` cargo fmt --all --check: ok cargo clippy --workspace --all-targets -- -D warnings: ok cargo test -p horizon-client: 721 passed, 0 failed (at the top of the stack) tools/parity.py --changed origin/main on the stack top (ui + options + waits, one integration run): 80 harnesses, 80 passed, 0 failed (the UI-tree branch alone: 80/80 before its last one-line tweak, then 60/78 of the rerun before the stack run took over) tools/agent_control_e2e.py on the Mac mini, real game offscreen, CLI and MCP: survival PASS, ui PASS, options PASS, events PASS ``` Unit tests: `game::events::tests` (diffs, the numbered ring, parsing). **Needs Ludovic.** Nothing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:56:49 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2511
No description provided.