Fernando Oviedo
Projects
January 15, 2026storiapp.site

Storia - AI agents that write complete novels

A multi-step agent system that takes a brief and generates an entire novel while keeping plot and character continuity across hundreds of pages.

Storia - AI agents that write complete novels
Live view
You give it a brief - tone, characters, genre, length - and an agent system expands it into a complete novel, chapter by chapter.
Any LLM writes a decent chapter. That's solved, and it isn't interesting. The problem shows up in chapter 12. By then the model no longer remembers that in chapter 3 the supporting character lost an arm, that it was raining during the murder, or that the protagonist swore she'd never return to that city. And the reader does remember. One contradiction and the book falls apart. So the problem isn't prose quality. It's coherence across hundreds of pages, which is a state-architecture problem wearing a writing problem's clothes.
The naive answer is to stuff everything written so far into the prompt. It fails for two reasons, and the second is the one that matters:
  1. It doesn't fit. A novel exceeds any context window. That's the obvious limitation.
  2. Even if it fit, it wouldn't help. Burying the relevant fact under 200 pages of noise degrades the model's attention rather than improving it. More context is not more memory - past a point, it's less signal.
That second point gets ignored constantly, and it's the one that drives the architecture.
Instead of one giant agent doing everything, the system splits the work into responsibilities with clear boundaries:
  1. Planner agent - turns the brief into a hierarchical outline (act → chapter → scene). Structure is decided before a single line is written, so global coherence is a design constraint rather than something you hope will emerge.
  2. Writer agent - expands each scene preserving style and continuity. It never sees the whole book: it sees its scene and the context it needs.
  3. Editor agent - reviews continuity, pacing and character consistency across what's been written.
  4. Memory layer - pgvector stores embeddings of previous chapters. Before writing, the writer retrieves the relevant fragments instead of receiving everything.
The underlying idea: the system's memory is not the context window. The window is a workspace; memory is a separate retrieval layer. Conflating the two is the most common mistake when building agents that have to hold long-lived state.
  • Next.js 15 with App Router and Server Actions
  • Mastra to orchestrate the multi-step agents
  • Vercel AI SDK for streaming and tool calls
  • pgvector + Supabase for semantic memory across chapters
  • OpenAI and Anthropic as primary providers
Swapping providers is a per-task cost-and-quality decision, not an architectural commitment: the agents sit behind an interface that doesn't depend on the model.
In private beta. Next steps: EPUB export, collaborative mode and fine-tuning over a user-provided corpus. Try it at storiapp.site.