Skip to content

Agents & Arbiters is a multi-agent AI text adventure game inspired by Zork. I was created to explore and demonstrate multi-agent system with multi-channel state using LangGraph.js.

License

Notifications You must be signed in to change notification settings

guyroyse/agents-n-arbiters

Repository files navigation

Multi-Agent AI Text Adventure Game

Overview

This multi-agent AI text adventure game—inspired by Zork and affectionately called Agents & Arbiters—demonstrates how to implement a multi-agent system with multi-channel state using LangGraph.js. Built on Azure using Static Web Apps, Azure Functions, Azure Managed Redis, and Azure OpenAI, this demo showcases Redis' ability to store workflow state and manage short-term conversation context using Agent Memory Server.

Table of Contents

Demo Objectives

  • Show how to build a multi-agent system with multi-channel state using LangGraph.js.
  • Demonstrate the usage of Azure Managed Redis's JSON and search capabilities to store and query persistent state for AI workflows.
  • Highlight Redis Agent Memory Server as a tool to manage short-term memory for AI workflows.

Setup

Dependencies

For Local Development:

For Azure Deployment:

Configuration

Local Configuration:

Copy .env.example to .env and fill in your OpenAI API key.

cp .env.example .env

If you use Node Version Manager run:

nvm use

Install Node.js dependencies for the top level orchestration project:

npm install

Install Node.js dependencies for the web and api projects:

npm run install:all

Azure Configuration:

No configuration necessary.

Running the Demo

Running Locally:

In one terminal window start the Docker services for Redis, Agent Memory Server, and LiteLLM:

docker compose up

In another terminal window, start the development servers:

npm run dev

This will compile and start the application. Now, just navigate to http://localhost:4280 in your browser and start playing the game.

Running on Azure:

azd up

Navigate to the URL provided by the azd up command in your browser and start playing the game.

Using the Demo

When you launch the game you will be presented with options for a New Game, Load Game, and Load World Template.

If it is your first time running the game you will need to load a world template before you can play. There are some AI-generated templates to choose from in the templates directory in this repository. Click Load World Template and choose one that sounds interesting to you.

Once the template is loaded you can start a new game. Click New Game and give your game a name or keep the randomly generated one. Ask the game 'Where am I?' and it'll tell you. From there, just start typing commands to explore the world.

You can also load a saved game by clicking Load Game and selecting a game from the list. Games are saved automatically as you play. No need to save manually.

You can view the game log by clicking Log in the top right of the game screen. This will show you the underlying workflow and all the LLM calls. Click Terminal to go back to the game.

When you're done playing, just close the window. If you're running locally, your game data will be preserved in Redis. If you're running on Azure, your game data is stored in Azure Managed Redis and will be preserved unless you delete the resources.

Stopping the Demo

Running Locally:

Just hit Ctrl+C in the terminal windows where you ran npm run dev and docker compose up respectively.

Running on Azure:

azd down --purge

Note that this will delete all resources, including the Redis database. All data will be lost.

Slide Decks

📁 Multi-Agent AI Text Adventure Game Slides
Covers goals, the agent workflow and architecture, and key Redis features. Suitable for formal presentations.

📁 Agents & Arbiters Slides
Covers the game design, an introduction to LangGraph.js, patterns of multi-agent workflows, multi-channel annotations, and how Redis fits in. Suitable for usage at a developer conference.

Architecture

Architecture Diagram

The Svelte 5 + Tailwind CSS frontend is hosted on Azure Static Web Apps and sends user requests to a collection of Azure Functions written in TypeScript. These functions use Redis to store game state, Agent Memory Server to manage conversation context, and Azure OpenAI as the LLM provider. The agent workflow itself is implemented using LangGraph.js.

Agent Workflow

The agent workflow shows the router handling the initial user command and routing to the appropriate agents based on the command. The arbiter then reviews the agent responses and makes a final decision on how to proceed. Finally, the committer applies the changes to the game state and the narrator generates the final response.

Custom Annotation

The custom annotation is a key feature of LangGraph.js that allows you to define the structure of the state and how it flows between nodes in the graph. In this example, the custom annotation defines the structure of the game state and how it is updated by each node in the graph.

Known Issues

  • Redis Agent Memory Server is only integrated with the narrator agent. This means that conversation history is not available to other agents in the workflow who might need them. Not a bug, but a limitation of the current implementation. A better approach would be to load the conversation from Agent Memory Server at the start of the workflow and then store it in the custom annotation.
  • There are only a few entity agents implemented—location, fixture, and exit. The game engine is designed to support many more and adding items and NPCs would be a good next step and would drive how to implement player inventory and combat.

Resources

Maintainers

Maintainers:

License

This project is licensed under the MIT License.

About

Agents & Arbiters is a multi-agent AI text adventure game inspired by Zork. I was created to explore and demonstrate multi-agent system with multi-channel state using LangGraph.js.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors