Skip to content
郭立 (leeguoo)

Building a Game Assistance Platform with a Chain of AI Tools: From Manual AI Control to Full Platform Automation

An AI-powered game assistant built for personal use and friends, intended for research and learning. With three computers and six worker slots, this article documents its evolution from hands-on AI operation to platform automation, including multi-device scheduling, lessons in keeping agents alive, a natural-language interface, self-iteration, and pitfalls encountered while coordinating multiple agents.

ON THIS PAGE

This is an AI-powered game assistant built for personal use and friends, intended for research and learning. The game is a survival mobile game: characters gather resources and craft tools, need to eat, require a light source after dark, and start with the entire map covered in fog. I wanted the in-game characters to work on their own: clear all the fog from the map, gather materials, return home to do chores, and enter friends’ worlds to help out, with several devices working together.

First, some context on the scale. In its first two days, the repository accumulated 397 commits, the issue list reached item 82, and there were 130 test files. The platform now runs across three computers with six worker slots. The devices include a headless Android emulator, a physical Android phone, and an iPhone.

This article contains no code and does not explain how to integrate with the game. I will say only this about integration: it connects through the game’s scripting layer to obtain structured game state. The rest focuses on architectural trade-offs and the lessons learned along the way.

1. AI Steps Back from Operator to Developer

On the first day, everything depended on a live Claude Code session. It inspected screenshots to locate coordinates, improvised scripts and injected them into the game, then repeatedly polled character state through the REPL. This worked for one phone, but every step required the model to inspect an image and think through the next action. It was expensive, slow, and impossible to scale across multiple devices.

On the second day, I settled on a direction: remove AI from operations and move to platform automation. The approach had four parts:

  • Any workflow manually validated in a session was immediately turned into a plugin: deterministic code with explicit success and failure criteria, timeouts and retries, and support for offline testing.
  • Scheduling, monitoring, and alerting moved into the platform. Steps requiring human intervention—such as entering verification codes, completing identity verification, or having the room owner approve a request—triggered platform notifications and waited for a person, rather than relying on AI to remain present.
  • Structured game state took priority, with screenshot recognition used only as a fallback.
  • AI handled development and troubleshooting only; it was not part of the runtime path.

Plugins formed the architectural foundation. Capabilities were divided into four types of pluggable components: device-side skills, plugins executed in rotation on each tick of a long-running task, housekeeping plugins, and computer-side worker roles. They shared a common interface: each component had to identify itself, report whether it could currently act, describe what it would do on that tick, and indicate its progress. Components were isolated from one another, so an error in one would not bring down the rest. Failure reasons followed a “short label + details + recommended action” format, allowing both humans and higher-level schedulers to decide what to do next.

The division of labor followed naturally: when the main session encountered a missing capability, it did not stop to implement the fix itself. Instead, it wrote up the requirement clearly and delegated the plugin implementation to a sub-agent. The main workflow continued, and the plugin was integrated once it was returned.

2. A Fleet of Workers Across Three Computers

One worker slot consists of one game account and one device. The three computers are a laptop, a Mac mini at home, and a personal server. All emulators run headlessly—no one watches the screen directly. When needed, I either take a screenshot or view the live feed in the dashboard.

Each computer runs four persistent services: one collects device status, one reports it to the task-scheduling backend, one handles local scheduling, and one supervises the emulators. If a machine restarts or an emulator crashes, the supervisor brings everything back up automatically. The task-scheduling backend runs on Cloudflare Workers, with data stored in D1. The backend does not connect directly to devices. Actions initiated from the dashboard are first placed in a queue; the computer picks them up during its next status report, executes them locally, and returns the results with the following report.

The dashboard's live view uses Durable Objects as a relay. Each worker has its own WebSocket connection, and the browser decodes the stream with WebCodecs. The delay from clicking the screen to seeing the image change is roughly 0.3 to 0.4 seconds. Streaming stops when no one is watching, and idle pages disconnect automatically after 10 minutes.

The scheduler reassesses each worker's role on every tick, using the following priorities from highest to lowest:

  1. Survival: retrieve dropped items, restore health or sanity, and reconnect after disconnection; preempts everything
  2. Commands I send through in-game private messages
  3. Core work: deliver materials and run routes
  4. Emergency restocking of supplies needed for route runs
  5. Account leveling
  6. Gathering materials blocking further leveling
  7. Chores and inventory organization
  8. General restocking
  9. Device testing

The first four tiers count as busy; the rest count as idle. During idle periods, roles rotate based on expected returns, with a minimum runtime for each role to prevent constant switching. Tasks are also divided into short and long jobs: delivering materials takes only a few minutes, while route runs take anywhere from half an hour to several hours. When assigning route runs, the scheduler keeps one worker available for short tasks. Workers already running routes are not interrupted except for survival actions.

Every action follows human-like pacing: accepting a request to enter waits a random 3 to 12 seconds, gathering actions are spaced a fraction of a second apart, and occasional pauses are inserted. There are three pacing profiles, with the middle one used by default. Delays between high-frequency actions overlap with movement, keeping the efficiency loss below 10%.

Running multiple computers introduced two pitfalls. During one route run, each computer had its own scheduler, and each assumed the entire map belonged to it, so three workers followed the same routes. I later changed the task-scheduling backend to divide the map into regions centrally, with the three computers sharing the available worker slots. The other issue was that code merged into the main branch still had not taken effect two hours later because the schedulers had never restarted. There is now a one-click full deployment process that pushes the backend, the local device, and the other two computers in one pass. Persistent processes detect code changes and restart within three minutes at most. Any in-progress step is checkpointed, and the new process resumes that same step using the updated code.

3. Standing Still Is What Gets You Killed

The hardest lesson came from a live run: four employees entered my own world to uncover the entire map. The surface fog reached 100%, but the underground and islands were left unfinished, the fast-travel points were not activated, and the entire team wiped twice along the way.

A chain of failures happened around the first wipe. One employee starved to death in the world because its built-in “eat something” logic treated twigs as food. My own character also died and was revived by another employee. While bringing in a replacement, the employee got stuck on the pre-entry survival-supplies check: the supply station had no food, so it just kept checking in place instead of gathering some itself. Another employee lost its connection and was kicked back to the login screen. The state probe crashed, so the scheduler treated it as offline and returned the entire task to the queue to rebuild the team. At the same time, two AI sessions were both intervening manually, alternating between pauses and forced entry. The state recorded by the scheduler no longer matched what was actually happening on the devices.

The second wipe happened at night. One employee stood still waiting to recover health and was killed. Another waited beside a light source for dawn and eventually died there too. My conclusion from the postmortem was simple: moving normally usually does not get you killed; standing still does.

Changes made afterward:

  • Every form of “waiting” was replaced with moving in circles. Whether waiting to recover health, waiting for light, waiting for dawn, or waiting for someone’s approval, employees never stand still. If a monster approaches, they create distance first.
  • Added a cause-of-death black box that records how far an employee traveled during the 30 seconds before death, making it possible to verify whether it had been standing still again.
  • Added night shifts: one employee is selected across the three computers to return to the host and guard the campfire, while the others uncover fog only within illuminated areas. The restriction is lifted at dawn.
  • Added a health gate before entering someone else’s world. Employees with insufficient health or supplies must replenish them locally first; if they cannot, they are replaced.
  • If everyone on our side dies in the world, the backend selects a full-health employee from any computer to enter and perform a rescue.
  • Replaced file polling for game communication with a persistent channel and event push notifications. Previously, the scheduler would not detect an incident until 15 seconds later. Command round-trip latency dropped from 465 milliseconds to 34 milliseconds, and incidents now reach the scheduler within 13 milliseconds.

There is one more rule: when danger arises in someone else’s world, employees must not leave casually. The host may have gone AFK or fallen asleep, and re-entering would require them to approve the request again. When danger arises, employees retreat to a safe location within the world and recover there. If disconnected, they automatically request to rejoin.

This postmortem also established acceptance criteria for the next run: the host must receive a join request within 30 seconds of initiating the process; no employee may starve to death; someone must attempt a rescue within two minutes after the host dies; disconnected employees must automatically return to the world within three minutes; and the entire process must require no manual session intervention.

4. Natural-Language Interface: Deterministic Parsing with AI as a Fallback

AI is not used at runtime, with one exception: the natural-language interface. I can privately message any employee in the game, or @ the bot in a WeChat group, using ordinary language such as “I need five pieces of wood,” “Help me tidy up my house,” or “Status.”

These messages first go through deterministic parsing. Numbers can be written as either Arabic or Chinese numerals. Items are matched exactly against official names and common aliases in the shared catalog, which contains 2,841 items. If no exact match is found, the system searches for candidates and replies, “Did you mean Wood ×5? Reply 1 to confirm.”

Only messages that the rules cannot recognize are passed to the large language model. The model is invoked through the Codex gateway using an OpenAI-compatible API, with the client implemented following Cherry’s approach. The model only performs translation: it converts natural language into a fixed set of tool calls for looking up items, registering purchase requests, checking status, checking inventory, and asking clarifying questions. In the game channel, the employees’ existing commands are also available. The constraints are strict:

  • The item must exist in the catalog, and the quantity must be a number that appeared in the original message. Otherwise, the tool returns an error and requires the model to ask a clarifying question.
  • Any purchase request registered by the model requires the other party to reply 1 for confirmation. Actions that cause an employee to leave a friend’s world, such as returning home or stopping, also require confirmation.
  • Responses may only use data returned by tools.
  • If the model fails or times out, the system falls back to a fixed prompt explaining how the user can phrase the request.

Every invocation is logged, including the original message, tool calls, dispatched commands, response, latency, and token usage, all of which can be viewed in the admin console. I also periodically run a review script that lists private messages where employees replied “I don’t understand” or failed to execute a command, then add synonymous phrases based on how I normally speak. “Invite me” and “Help me tidy up my house” initially both received “I don’t understand” responses; this is how support for them was added.

5. The Closed Loop of Self-Improvement

Whenever I encounter a problem, I add it to an issue list using the format “symptom, cause, optimization, status.” I delegate the fix to a sub-agent, which makes the changes in an isolated worktree. Once the tests pass, the changes are merged into the main branch and the worktree is deleted.

Later, I realized that fixes were constantly being merged, yet all I saw was “pending verification on physical devices.” So I redefined what “done” means: merged into the main branch, deployed to every device with one click, and successfully verified in a drill session. A fix is not complete until all three steps are done.

In a drill session, an employee account plays the host and triggers scenario-based incidents in its own world: a normal session, an empty supply station, the host dying midway through, an employee losing their connection, two people applying simultaneously, or the scheduler restarting. Other employees join and work through the official process. Acceptance criteria are evaluated automatically by the program, and the report is stored in the admin console. Drills immediately yield to real tasks and run automatically once a day during idle periods.

You also need data first. Every employee records a trajectory point every two seconds, along with the current phase, fog-clearing progress, deaths, and revivals. The admin console can replay these trajectories and generate grid-based heatmaps showing traversal counts. If the same grid cell is crossed an unusual number of times, it is automatically flagged as a problematic area. Before changing route planning or zone partitioning, I first consult the replays and analytics.

I am currently automating this entire loop: aggregating issues from the issue list, event logs, and drill reports; deduplicating, scoring, and prioritizing them into a backlog; assigning them to development sessions for fixes; opening pull requests; having Codex review them; running tests; and, once they pass the gate, merging, deploying, and rechecking the changes before generating a daily report.

6. How Multiple Agents Collaborate

Several Claude Code sessions work on this project simultaneously, along with Codex. Most of the problems we encountered came from coordination.

Sharing the main branch causes agents to step on each other’s toes. Initially, every session worked directly on the main branch, so commits would include other sessions’ changes. As a result, half-finished work was accidentally committed by another session and then loaded into running processes via hot reload. In the first two days alone, 50 commit titles included “in-progress changes from other sessions.” We later switched to one branch and one worktree per task, deleting them after merging back into main. Parallel merges also caused issue-number collisions, with two branches independently claiming the same number.

Sessions talked to each other too much. Sessions used OCS to message and wake one another. Once overused, they spent all their time confirming with each other, reporting status, and claiming tasks instead of making progress. The rule now is not to reply by default and to send a single message only in three situations: asking another session to release a device or file, handing off something the other session must take over, or identifying work that could overwrite each other’s changes. Put everything in one message and do not follow up with questions. Check the staff status table and event logs for the current state.

Whoever takes control of a device is responsible for releasing it. Two sessions manually intervening with the same employee at the same time was one of the causes of the first total failure. Now, whoever initiates a pause or manual operation on a device is responsible for wrapping it up.

Don’t stop to ask. If an action is reversible and confined to the local machine, just do it and report afterward. In-game costs—such as consuming items or deleting and rebuilding a save—are left to the employee and scheduler to weigh. Ask a human only when spending real money, publishing externally, or taking an irreversible action. If information is missing, finish everything that does not depend on it first, then note what is missing in the report.

Record decisions together with their rationale. Every principle goes into memory, including my exact wording at the time, why I made the decision, and the situations in which it should be applied. New sessions can pick up immediately without requiring me to explain everything again.

If an upstream tool falls short, fix it upstream. When a reusable tool I built is missing functionality, I update its upstream repository directly instead of piling compatibility code into the caller.

7. Tools Used

ToolWhat It Does in This Project
Claude Code and subagentsPrimary development tools; whenever a capability is missing, I assign a subagent to build it as a plugin in an isolated worktree
Codex gatewayAn OpenAI-compatible model interface; the fallback for the natural-language entry point
cherryMy own AI assistant; the model client for the natural-language entry point follows its implementation
ocsSends messages and wake-up signals between sessions; used to coordinate devices and handoffs
memory-useLong-term memory across sessions and computers; records principles, lessons learned, and the state of each device
bitwarden-useStores account credentials exclusively in the password vault and retrieves them only when needed; repositories and memory contain pointers only
message-useAutomatically retrieves SMS verification codes when logging into new test accounts
iphone-useDrives native iPhone interfaces and captures screenshots
android-useDrives native Android interfaces, such as login and authorization pages, and records them as replayable workflows
wechat-useProvides a command entry point by @-mentioning the bot in WeChat groups
chrome-useLooks up guides, checks search rankings, and tests my own web pages
Cloudflare Workers, D1, and Durable ObjectsPower the task-scheduling backend, worker monitoring, and real-time screen relay
WeChat Mini Program and guide siteProvide the item catalog and guides, sharing the same item database with the backend
motion-useProduces the companion explainer video for this article

8. Lessons Learned

AI is very good at being the first to navigate an uncharted path. Once it succeeds, immediately turn that path into deterministic code—the runtime should no longer rely on a model inspecting images to make decisions. The natural-language interface is the exception, and even there, the model only translates; execution remains in deterministic code.

Structured state is far more reliable than screenshots. If you can read health and coordinates directly, do not resort to recognizing pixels.

The most dangerous state in an automation system is waiting. Efficiency can be tuned gradually; survival comes first.

Define completion through verification. Merging into the main branch does not count; it is only complete after deployment to every device and passing all acceptance checkpoints in the drill.

For multiple agents working together, isolation is more effective than communication: give each agent an independent worktree, clearly assign device ownership, and have everyone use the same event log. This is much easier than relaying messages back and forth between sessions.

Record lessons together with the reasoning behind them. With the rationale preserved, new sessions can make their own judgments when encountering unfamiliar situations instead of asking a human every time.

More in this category · AI & Agent

next →
How to Use Japan’s Hometown Tax (Furusato Nozei): Pay ¥2,000 and Get Rice and Meat in Return

Comments

Replies are public immediately and may be moderated for policy violations.

Max 1000 characters.