Building StoryDaemon: Teaching an AI to Discover Stories

How I built an agentic system that writes novels through emergence rather than planning


The Problem with AI-Generated Fiction

AI story generation works like this: you provide a prompt, they generate text. Want more? Give them another prompt. It is possible to write a story inside a conversation within ChatGPT, or even in a document inside a coding IDE (such as Windsurf or Cursor). However, while the result is often coherent paragraph-to-paragraph, over the longer-term the stories lose coherency. Moreoever, they lack the deeper structure that makes stories satisfying—foreshadowing, character arcs, thematic resonance, narrative momentum.

In my previous project, NovelWriter, I employed a rigid top-down plan from the beginning. The whole story was planned out in advance, so the AI had no agency to change course. This time, I wanted something different. I wanted to see if an AI could discover a story the way a human "pantser" writer does—not by following a rigid outline, but by making decisions in the moment and letting the narrative emerge organically.

The Core Idea: Emergence Over Planning

The philosophy behind StoryDaemon is simple: what if we gave an AI the tools to make decisions about its own story, and then got out of the way?

Instead of generating text directly from prompts, StoryDaemon uses an agentic architecture. The AI doesn't just write—it plans, decides, and remembers. Each "tick" of the system produces one scene, but before writing that scene, the agent considers:

  • What has happened so far?
  • Who are the characters and what do they want?
  • What narrative threads are still unresolved?
  • What would be interesting to explore next?

The AI then makes autonomous decisions about what tools to use: i.e. it needs to create a new character, or search its memory for a detail established fifty scenes ago, or check what unresolved plot threads are dangling.

Only after this planning phase does it actually write prose.

Memory That Evolves

One fundamental challenge is that LLMs have no memory, and so no sense of where the story has been or where it might go. Each generation is essentially stateless. We can build a memory system to aid recall, but it also has to be paired with a planning system to guide the AI toward a coherent narrative. We also need systems to track the state of the story and then to correct course if necessary.

One of the most important aspects of StoryDaemon is its memory system. The AI maintains a persistent understanding of:

  • Characters that grow and change over time
  • Locations with sensory details and atmosphere
  • Relationships between characters that evolve
  • Open loops unresolved narrative threads that create tension and invite resolution

This isn't just a database dump. The system uses semantic search to retrieve relevant context for each scene. If a character walks into a location they visited thirty scenes ago, the AI can recall what happened there and weave in appropriate callbacks.

The Joy of Surprise

What I find most compelling about this approach is the element of genuine surprise. Because the AI is making autonomous decisions based on an evolving story state, even I don't know exactly what will happen next.

I've watched it introduce characters I didn't expect, create plot complications that emerged naturally from earlier decisions, and find thematic connections I hadn't consciously designed. It's not quite like reading a book—I'm too close to the machinery for that—but it's also not like writing one. It's something in between.

What I've Learned

Building StoryDaemon has taught me a few things:

  • Emergence requires memory. Without persistent state, you can't have true emergence—just random variation. The AI needs to know where it's been to make meaningful decisions about where to go.

  • Constraints enable creativity. A completely unconstrained AI produces chaos. But the right constraints—a genre, a tone, a protagonist with clear motivations—create a space where interesting things can happen.

  • Tools matter more than prompts. The quality of AI-generated fiction isn't just about prompt engineering. It's about giving the AI the right capabilities and letting it decide when to use them.

  • Stories want to be told. This sounds mystical, but there's something to it. Once you set up the right conditions—interesting characters, unresolved tensions, a world with texture—stories seem to find their own shape. The AI isn't really "creating" so much as discovering what was always implicit in the setup.

What's Next

StoryDaemon is still evolving. I'm exploring ways to give the AI more sophisticated understanding of narrative structure—tension, pacing, the rhythm of scenes. I'm also interested in how human feedback could guide emergence without constraining it.

But the core insight remains: the best AI-generated stories might not come from better prompts or larger models. They might come from better architectures—systems that can remember, decide, and discover.


StoryDaemon is an open-source project. If you're interested in emergent narrative generation, I'd like to hear from you.