{"slug": "novelpilot-a-novel-writing-agent-powered-by-gemma-4", "title": "NovelPilot: A Novel Writing Agent Powered by Gemma 4", "summary": "NovelPilot is a web application that uses a multi-agent workflow powered by the Gemma 4 model to help users create short fiction from a simple prompt. The app employs a sequence of specialized AI agents, each responsible for a different part of the writing process, to generate a complete creative package including structured elements like timelines and character cards. It is designed to showcase Gemma 4 as a multi-agent creative reasoning engine rather than a simple text completion tool.", "body_md": "This is a submission for the Gemma 4 Challenge: Build with Gemma 4\nNovelPilot is a web app that helps users create short fiction through a structured multi-agent workflow.\nThe user starts with a simple prompt, such as:\nWrite a melancholic sci-fi mystery set in modern Tokyo. A graduate student who lost his memory investigates a disappearance in a quantum computing lab.\nThen NovelPilot launches a sequence of specialized AI agents:\nEach agent performs a specific part of the writing process.\nThe result is not just a generated story. It is a full creative package:\nNovelPilot is designed to demonstrate Gemma 4 as a multi-agent creative reasoning engine, not just a text completion model.\nLive demo: https://novelpilot.vercel.app\nHow to try it:\nThe Judge Demo works without an API key, so reviewers can test the full experience immediately.\nFor live generation, NovelPilot supports Gemma 4 through a provider abstraction, with OpenRouter as the recommended provider.\nHere is the sample prompt I used to test NovelPilot.\nThe protagonist is Ren Kanzaki, a 24-year-old graduate student working in a quantum computing laboratory. A few days ago, he lost part of his memory. He cannot remember what he was researching, why his professor suddenly disappeared, or why his own name appears in an old experimental log.\nThe story begins on a rainy night in Tokyo. Ren enters the university research building after midnight and finds an old experiment log hidden inside a locked drawer. On the final page, he sees the sentence:\n“Ren Kanzaki will be removed from the observation target as of today.”\nThe story should focus on quiet tension, memory gaps, emotional unease, and the unsettling atmosphere of the laboratory. Avoid flashy action. Let the mystery emerge through scenery, silence, dialogue, and small contradictions.\nMain theme:\nIf memories disappear, can a person still remain the same self?\nMain characters:\n- Ren Kanzaki: A graduate student who lost part of his memory. Calm and intelligent, but emotionally repressed.\n- Mio Shiraishi: Ren’s labmate. She knows something about Ren’s memory loss but refuses to tell him the truth.\n- Professor Kuon: The missing professor. He was researching quantum memory transfer.\n- Associate Professor Kurosaki: The person currently managing the laboratory. He seems helpful, but some of his statements contradict the records.\nTone:\nIntellectual, quiet, melancholic, slightly literary, and mysterious.\nI also exported the generated story as a polished PDF.\nSample output PDF: Download the generated novel PDF\nThis PDF was generated directly from NovelPilot’s finished reader view.\nGitHub repo: https://github.com/dorakingx/novelpilot\nTech stack:\nThe app has two main modes:\nThe provider layer is intentionally isolated in lib/gemma.ts\n, so the model provider can be changed without rewriting the app.\nGemma 4 is the reasoning engine behind the multi-agent writing pipeline.\nNovelPilot uses Gemma 4 for:\nEach agent receives the accumulated story bible and previous structured outputs.\nThis means Gemma 4 is not just generating paragraphs. It acts as the structural memory and reasoning layer for the whole novel creation process.\nThe important design decision was to make every agent return structured data whenever possible. That allows the UI to render the model output as real product features: timelines, cards, reports, trackers, reader views, and exports.\nFor the live version, NovelPilot is designed to use a Gemma 4 model through OpenRouter.\nI chose this approach because the app needs strong reasoning and structured generation across multiple steps. The model must follow JSON schemas, preserve context from earlier agents, and reason about story structure, character consistency, and foreshadowing.\nNovelPilot focuses especially on:\nGemma 4 is a good fit because the project is not only asking the model to write a paragraph. It asks the model to behave as a coordinated writing room.\nMost AI writing tools generate text.\nNovelPilot generates a writing process.\nThe user does not only receive a draft. They see how the story is built:\nPrompt\n↓\nPremise\n↓\nCharacters\n↓\nWorld\n↓\nPlot\n↓\nChapter outline\n↓\nDraft\n↓\nStyle edit\n↓\nContinuity audit\n↓\nPublisher package\n↓\nReader view\n↓\nPDF export\nThis makes the output easier to inspect, revise, and trust.\nOne of my favorite parts is the Foreshadowing Tracker.\nInstead of only writing a draft, NovelPilot tracks story threads like this:\n{\n\"item\": \"The cracked silver watch\",\n\"introducedIn\": \"Chapter 1\",\n\"status\": \"unresolved\",\n\"suggestedPayoff\": \"It reveals the exact time the protagonist's memory was overwritten.\",\n\"payoffChapter\": \"Chapter 3\",\n\"emotionalPurpose\": \"Connects guilt, identity, and lost time.\"\n}\nThis makes the output more useful for writers.\nIt also shows why a structured model workflow matters. The app is not only asking Gemma 4 to write prose. It is asking Gemma 4 to reason about narrative structure.\nThe Continuity Detective checks the generated story for structural problems.\nIt returns issues with:\nExample structure:\n{\n\"category\": \"foreshadowing\",\n\"severity\": \"high\",\n\"issue\": \"The experiment log is introduced as important but has no planned payoff.\",\n\"evidence\": \"The log appears in Chapter 1 and is referenced in the outline, but no chapter resolves its origin.\",\n\"suggestedFix\": \"Reveal in the final chapter that the log was written by an earlier version of the protagonist.\"\n}\nThis was important to me because many AI writing tools can generate plausible fiction, but fewer tools help the user understand whether the story actually holds together.\nAfter all agents finish, NovelPilot automatically transitions into a Completed Novel Reader.\nThe user can read the finished story directly in the browser.\nThey can also go back to the Agent Workspace to inspect:\nThe final reader is not a one-way screen. Users can freely move between the production workflow and the finished novel.\nI also added polished PDF export.\nInstead of relying on the browser’s default print layout, NovelPilot generates a designed A4-style manuscript PDF.\nThe PDF includes:\nThis makes the app feel closer to a complete writing product, not just a demo.\nI wanted the app to feel like an AI creative studio.\nThe flow has three stages:\nThe first screen is focused.\nThe user only sees:\nThis keeps the experience simple.\nAfter generation starts, the app transitions into the agent workspace.\nThis screen shows:\nWhen all agents finish, the app opens the final reading screen.\nThe user can read the story, download a PDF, or go back to review the agent outputs.\nThe core architecture is simple:\napp/page.tsx\nMain app phase control:\nlauncher → workspace → reader\nlib/useStoryProject.ts\nClient-side orchestration of the pipeline\napp/api/generate-agent/route.ts\nRuns one agent per request\nlib/gemma.ts\nProvider abstraction for Gemma 4 / OpenRouter / mock mode\nlib/prompts.ts\nPrompt templates for each writing agent\nlib/agents.ts\nMerges structured agent outputs into the Story Bible\nlib/types.ts\nShared TypeScript types\ncomponents/\nPrompt launcher, agent workspace, reader, trackers, reports, export panels\nThe app uses a state-first architecture because this is a hackathon project. I intentionally avoided authentication, databases, and user accounts so the core experience stays fast and easy to judge.\nHere is the high-level pipeline:\nUser Prompt\n↓\nPremise Architect\n↓\nCharacter Director\n↓\nWorld Builder\n↓\nPlot Strategist\n↓\nChapter Architect\n↓\nProse Writer\n↓\nStyle Editor\n↓\nContinuity Detective\n↓\nPublisher Agent\n↓\nCompleted Novel Reader + PDF Export\nEach step builds on the previous one.\nFor example, the Character Director does not work from the original prompt alone. It receives the premise and theme created by the Premise Architect.\nThe Plot Strategist receives the concept, characters, and worldbuilding.\nThe Continuity Detective receives the story bible, chapter outline, draft, and previous reports.\nThis makes the app feel like an actual production pipeline rather than a single model call.\nThe biggest lesson was that structured outputs are more powerful than plain prose outputs for creative tools.\nA single prose response is hard to inspect.\nBut structured outputs can become:\nI also learned that judge experience matters.\nThat is why I added Run Judge Demo. Reviewers can experience the full product without configuring an API key.\nAnother lesson was that a creative AI product should not end at “generation complete.” It should end with something the user can actually consume. That is why I added the final reader and PDF export.\nThe biggest challenge was balancing autonomy and control.\nIf the app is too automatic, it feels like the user has no creative role.\nIf the app asks for too much input, it stops feeling agentic.\nSo I designed NovelPilot around this principle:\nThe AI agents do the heavy lifting, but the user can always review, regenerate, edit, read, and export.\nAnother challenge was making the final output feel complete. The Completed Novel Reader and PDF export helped turn the generated draft into something closer to a finished product.\nI would like to add:\nNovelPilot is my attempt to make AI fiction generation feel less like a chatbot and more like a writing room.\nThe core idea is simple:\nOne prompt. Nine agents. A complete story pipeline.\nGemma 4 is the reasoning engine behind the process. It plans, writes, edits, tracks foreshadowing, checks continuity, and packages the final story.\nThat is what makes NovelPilot more than a story generator.\nIt is an AI-powered novel production studio.", "url": "https://wpnews.pro/news/novelpilot-a-novel-writing-agent-powered-by-gemma-4", "canonical_source": "https://dev.to/doraking/novelpilot-a-novel-writing-agent-powered-by-gemma-4-5caa", "published_at": "2026-05-23 03:50:06+00:00", "updated_at": "2026-05-23 04:02:03.957350+00:00", "lang": "en", "topics": ["artificial-intelligence", "large-language-models", "developer-tools", "research", "products"], "entities": ["NovelPilot", "Gemma 4", "OpenRouter", "Ren Kanzaki", "Gemma 4 Challenge"], "alternates": {"html": "https://wpnews.pro/news/novelpilot-a-novel-writing-agent-powered-by-gemma-4", "markdown": "https://wpnews.pro/news/novelpilot-a-novel-writing-agent-powered-by-gemma-4.md", "text": "https://wpnews.pro/news/novelpilot-a-novel-writing-agent-powered-by-gemma-4.txt", "jsonld": "https://wpnews.pro/news/novelpilot-a-novel-writing-agent-powered-by-gemma-4.jsonld"}}