E
Back to projects
Prototype notesAgents for Narrative

Branching Storykeeper Agent

A script-driven AI game master that follows player choices through a branching story.

Branching Storykeeper Agent system architecture diagram
Branching Storykeeper Agent system architecture diagram

My friends and I built this script-driven AI game master. It follows player choices through a branching story while keeping track of the underlying script structure.

How it works

We first break the script into scenes and plots. During a session, the runtime tracks where the player is and decides when an action should move the story onto another branch.

Each response pulls from the active plot alongside relevant details retrieved from the script, while state updates carry the consequences forward into later turns.

Design notes

If a player betrays an ally they were supposed to protect, the immediate reaction from the game master might read well. By the next scene, though, the story can easily continue as if nothing happened. That kind of break in continuity is what this project is about.

Keeping the conversation in context gives the model something to refer back to, yet the runtime still has to decide whether a betrayal actually changes the next branch. We use explicit story state to handle those decisions in the system rather than leaving everything up to the next generated response.

The open question is how much structure to give a scene. With too little structure, a player's choices can fade away between turns. With too much, the player has very little room to find their own path.

System diagram

Script preparation happens separately from running the game. Preparation turns the source material into a hierarchy of scenes and plots, setting up the background knowledge for retrieval.

During play, the runtime checks each player input against the current story state, gathers context for the response, and handles game mechanics before saving state updates for the next turn.

Demo screen

The first screen shows the setup before a session, where players choose a table and create an investigator before entering the case.

Branching Storykeeper Agent demo screen

The second screen shows a session in progress, with the game master responding to the player based on the current narrative state.

Branching Storykeeper Agent in-session demo screen

Open questions

How much can a player change before the story needs a branch the author never wrote?

Which consequences need to last beyond the current scene?