Agent2Game Open Protocol
Same characters. Smarter choices.
Game AI has always been written by people. A2G lets it ask a model which move to make next. Your code still runs the game.
Using a coding agent? Hand it llms-full.txt or the prompt below.
AI has always been part of games
Section titled “AI has always been part of games”Every enemy that ever chased, hid or flanked a player ran on decisions a person designed. Each generation of game AI kept that person in charge and gave characters a better way to choose:
- 1980: Pac-Man’s four ghosts each follow their own targeting rule, so one chases and another cuts you off.
- 1998 to 2005: squads that take cover and flank, behavior trees in Halo 2, goal planners in F.E.A.R.
- Now: a model weighs the whole situation and picks one of the moves designers built, inside the rules the game enforces.
A2G is that next step, made open and engine-neutral. It does not generate art, voices or dialogue, and it does not replace the people who make games. Designers still decide what a character can do, programmers still decide what happens, and the original AI is still there as the native AI that takes over on any failure.
Hand it to your coding agent
Paste this into Claude Code, Codex or Cursor in your game's project. It uses an SDK when your engine has one and writes a client by the rules when it does not.
Read https://agent2game.org/llms-full.txt, the Agent2Game (A2G) protocol 0.1. Then integrate A2G into this game. 1. Identify the engine, the language and where the game logic runs (player's device, browser or a game server). If an A2G SDK exists for the language (see Implementations), use it. 2. If there is no SDK, write a small client in the game's language that follows the specification and the rules in https://agent2game.org/guides/integrate/#no-sdk-for-your-engine: keep it game-agnostic and separate from game code; never block a game-loop step (frame, tick or turn) on the network; validate every decision (epoch, legal_actions, ttl_ms); fall back to the game's existing AI on any error, timeout or FALLBACK; send reports with decision_id and telemetry (about once per second, or after every turn in turn-based games); validate messages in tests against https://agent2game.org/schema/0.1/a2g.schema.json. 3. The game's existing decision logic (FSM, rules, utility AI, even its own model calls) is its native AI. Keep it unchanged as the default and the fallback; A2G only chooses between actions the game already has. Change the game as little as possible: an adapter module and the fewest hook lines, no changes to rules, balance, content or UI. 4. Judge soberly where A2G is worth it (https://agent2game.org/guides/integrate/#where-a2g-helps). List every decision the native AI makes and pick only those where A2G can add real, measurable value: random or fixed-priority choices, strategic choices that ignore the situation, behaviour designers find hard to tune or vary. Leave precise geometry, aiming, path-finding, per-frame micro-decisions and whatever the native AI already does well to the game. Do not add AI for its own sake. Say plainly where A2G adds nothing, and if it adds nothing to this game, say so and stop. 5. Propose a manifest for the chosen decisions only, from the game's real entities: what each can observe and the actions it already has. Prefer enums and fractions; never include personal data. 6. Write the adapter (observe, legal_actions, execute) and hook the entities. 7. Connect to an A2G decision service (https://agent2game.org/guides/integrate/#decision-service): check http://127.0.0.1:8787/health; if none is running, start the reference service from its Docker image (ask me for the provider key, never put it in the repo). Do not write your own service or console. Without Docker or a key, test against a stub that follows the specification. Put the client where the game logic runs: on the game server for server-authoritative games. Never put provider API keys in the game or in a browser bundle. 8. If the game has an authenticated admin area, propose an "A2G" entry that serves the Agent2Game Console through a server-side proxy instead of rebuilding it. 9. Keep the integration in sync with the game (https://agent2game.org/guides/integrate/#keep-it-in-sync): derive the manifest's actions and enums from the game's own constants or test that they match; add a test that runs the game for a while with the SDK's strict drift checks on (or validates every observation and legal action against the manifest); and add a rule to this repository's AGENTS.md or CLAUDE.md that changing entities, actions or observed fields means updating the A2G manifest and adapter and running those tests. 10. Before changing existing game logic, show me: each decision point with your verdict (A2G or native, and why), how you will measure A2G against the native AI (for example matches or seeded runs compared side by side), the plan and the manifest.
How it works
Section titled “How it works”observe · legal_actions · executeHTTP · JSON
- Validates against the manifest
- Keeps per-entity memory
- Holds provider keys
- Agent2Game Console
provider API
Reference: OpenAI Decisions
- Describe the game once. A manifest lists the world, entity types, what each entity observes and which actions exist.
- Ask for decisions. The game sends observations for a batch of entities and the actions legal right now. The service asks a model to pick one per entity.
- Validate and execute. The game checks each choice and performs it through its own code, or runs its native AI if there is no valid, fresh decision.
- Report back. The game reports how each decision ended, which becomes the entity’s memory for its next decision.
- Learn and ship (proposed). Decisions from playtests train a small local policy. The shipped game runs it offline, with no service and no per-decision cost.
Why A2G
Section titled “Why A2G”Your game stays in charge
Movement, physics, damage and rules stay in the game. The model only picks from actions the game offered.
Native AI is the safety net
Timeouts, invalid replies and stale decisions hand control back to the original behaviour. The game never breaks.
Any decision model
OpenAI Decisions, TypeSafe Jev, open models such as Kev, or a small policy trained on your own playtests.
Built for real games
Levels, characters, squads, events and a shared cache keep cost tied to decisions, not to the size of the world.
Game-agnostic
The service knows a game only through its manifest: 2D or 3D, enemies, allies, crowds or vehicles.
Secure by design
Typed choices, no keys in builds, session tokens and signed join tokens. See the security model.
Questions developers ask
Section titled “Questions developers ask”My game has no internet connection. Why would I need this?
Use the model while you build, not while players play. During development the model decides and every decision is logged; from that log A2G trains a small local policy that ships inside the game and runs offline, with no service, no keys and no per-decision cost. (Proposed, not implemented yet.) Today, losing the network only means the game runs its original AI. More: Local policy.
Will network latency make my game lag?
No frame ever waits for a model. Requests are asynchronous; an entity without a fresh decision simply keeps running its native AI until one arrives. Decisions are for intent ("flank", "retreat"), made every few seconds, while aiming, steering and animation stay frame-level native code. More: Modes and fallback.
What does it cost, and who pays?
Typed-decision models charge for input only. One fight with six enemies is about $0.10 to $0.24 per hour of play; 40 hours of playtesting is a few dollars. Cost scales with the number of decisions, not the size of the world, and events, groups, the cache and a shipped local policy cut it further, down to zero at runtime. Players never hold a key. More: Cost.
What if the model picks something stupid or breaks the rules?
It cannot break the rules. The model only picks one of the actions the game offered right now; the game validates the choice and executes it through its own code. An invalid, late or refused answer is dropped and native AI takes over. Every decision and its outcome is logged, so you can trace what a character did and why it fell back.
We balanced our AI by hand. Will a model make it unpredictable?
You decide how much it decides. Drive only the entities and moments that benefit from judgment (a boss, a squad, a director) and keep the rest native. Designers write the actions, their descriptions and character profiles, so the model plays inside the design. AI control is opt-in, and native stays the default.
Is this generative AI? Does it replace designers, writers or artists?
No. A2G generates no art, voices, music or dialogue. It picks one move from a list people built, the way behavior trees and planners did before it. Designers still decide what a character can do and programmers still decide what happens. The goal is better behavior from the content you already made.
How much work is an integration? Do I rewrite my AI?
No rewrite. You keep your state machine or behavior tree as the fallback and add a manifest plus a thin adapter: what an entity sees, which actions are legal now, and how to run each one. In the Lango example that is one adapter file and two calls in each enemy script. More: Integrate a game.
My engine is not Godot (Unity, Unreal or something else).
The protocol is plain JSON over HTTP, engine- and language-neutral, for 2D and 3D. There are SDKs for Godot and for JS/TS (browser and Node, including game servers); Unity and Unreal SDKs are on the roadmap, and you can talk to the service without an SDK. More: JS/TS SDK.
Does player data go to an AI provider?
Only what your manifest declares and your adapter sends: game state such as positions, health and nearby objects. No accounts, chat or personal data are needed. The provider key stays in the decision service, never in the build, and you can run an open model on your own hardware instead. More: Security.
Am I locked into one AI vendor?
No. The protocol names no model. The reference service supports OpenAI Decisions and TypeSafe Jev today; open Jev-compatible models such as Kev can run locally. Switching providers is service configuration, not game code. More: Decision providers.
All questions, grouped by topic →
Explore
Section titled “Explore”Protocol version 0.1 is a draft; breaking changes are expected. Follow it on GitHub.