NovelPilot: A Novel Writing Agent Powered by Gemma 4 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. This is a submission for the Gemma 4 Challenge: Build with Gemma 4 NovelPilot is a web app that helps users create short fiction through a structured multi-agent workflow. The user starts with a simple prompt, such as: Write a melancholic sci-fi mystery set in modern Tokyo. A graduate student who lost his memory investigates a disappearance in a quantum computing lab. Then NovelPilot launches a sequence of specialized AI agents: Each agent performs a specific part of the writing process. The result is not just a generated story. It is a full creative package: NovelPilot is designed to demonstrate Gemma 4 as a multi-agent creative reasoning engine, not just a text completion model. Live demo: https://novelpilot.vercel.app How to try it: The Judge Demo works without an API key, so reviewers can test the full experience immediately. For live generation, NovelPilot supports Gemma 4 through a provider abstraction, with OpenRouter as the recommended provider. Here is the sample prompt I used to test NovelPilot. The 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. The 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: “Ren Kanzaki will be removed from the observation target as of today.” The 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. Main theme: If memories disappear, can a person still remain the same self? Main characters: - Ren Kanzaki: A graduate student who lost part of his memory. Calm and intelligent, but emotionally repressed. - Mio Shiraishi: Ren’s labmate. She knows something about Ren’s memory loss but refuses to tell him the truth. - Professor Kuon: The missing professor. He was researching quantum memory transfer. - Associate Professor Kurosaki: The person currently managing the laboratory. He seems helpful, but some of his statements contradict the records. Tone: Intellectual, quiet, melancholic, slightly literary, and mysterious. I also exported the generated story as a polished PDF. Sample output PDF: Download the generated novel PDF This PDF was generated directly from NovelPilot’s finished reader view. GitHub repo: https://github.com/dorakingx/novelpilot Tech stack: The app has two main modes: The provider layer is intentionally isolated in lib/gemma.ts , so the model provider can be changed without rewriting the app. Gemma 4 is the reasoning engine behind the multi-agent writing pipeline. NovelPilot uses Gemma 4 for: Each agent receives the accumulated story bible and previous structured outputs. This means Gemma 4 is not just generating paragraphs. It acts as the structural memory and reasoning layer for the whole novel creation process. The 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. For the live version, NovelPilot is designed to use a Gemma 4 model through OpenRouter. I 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. NovelPilot focuses especially on: Gemma 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. Most AI writing tools generate text. NovelPilot generates a writing process. The user does not only receive a draft. They see how the story is built: Prompt ↓ Premise ↓ Characters ↓ World ↓ Plot ↓ Chapter outline ↓ Draft ↓ Style edit ↓ Continuity audit ↓ Publisher package ↓ Reader view ↓ PDF export This makes the output easier to inspect, revise, and trust. One of my favorite parts is the Foreshadowing Tracker. Instead of only writing a draft, NovelPilot tracks story threads like this: { "item": "The cracked silver watch", "introducedIn": "Chapter 1", "status": "unresolved", "suggestedPayoff": "It reveals the exact time the protagonist's memory was overwritten.", "payoffChapter": "Chapter 3", "emotionalPurpose": "Connects guilt, identity, and lost time." } This makes the output more useful for writers. It 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. The Continuity Detective checks the generated story for structural problems. It returns issues with: Example structure: { "category": "foreshadowing", "severity": "high", "issue": "The experiment log is introduced as important but has no planned payoff.", "evidence": "The log appears in Chapter 1 and is referenced in the outline, but no chapter resolves its origin.", "suggestedFix": "Reveal in the final chapter that the log was written by an earlier version of the protagonist." } This 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. After all agents finish, NovelPilot automatically transitions into a Completed Novel Reader. The user can read the finished story directly in the browser. They can also go back to the Agent Workspace to inspect: The final reader is not a one-way screen. Users can freely move between the production workflow and the finished novel. I also added polished PDF export. Instead of relying on the browser’s default print layout, NovelPilot generates a designed A4-style manuscript PDF. The PDF includes: This makes the app feel closer to a complete writing product, not just a demo. I wanted the app to feel like an AI creative studio. The flow has three stages: The first screen is focused. The user only sees: This keeps the experience simple. After generation starts, the app transitions into the agent workspace. This screen shows: When all agents finish, the app opens the final reading screen. The user can read the story, download a PDF, or go back to review the agent outputs. The core architecture is simple: app/page.tsx Main app phase control: launcher → workspace → reader lib/useStoryProject.ts Client-side orchestration of the pipeline app/api/generate-agent/route.ts Runs one agent per request lib/gemma.ts Provider abstraction for Gemma 4 / OpenRouter / mock mode lib/prompts.ts Prompt templates for each writing agent lib/agents.ts Merges structured agent outputs into the Story Bible lib/types.ts Shared TypeScript types components/ Prompt launcher, agent workspace, reader, trackers, reports, export panels The 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. Here is the high-level pipeline: User Prompt ↓ Premise Architect ↓ Character Director ↓ World Builder ↓ Plot Strategist ↓ Chapter Architect ↓ Prose Writer ↓ Style Editor ↓ Continuity Detective ↓ Publisher Agent ↓ Completed Novel Reader + PDF Export Each step builds on the previous one. For example, the Character Director does not work from the original prompt alone. It receives the premise and theme created by the Premise Architect. The Plot Strategist receives the concept, characters, and worldbuilding. The Continuity Detective receives the story bible, chapter outline, draft, and previous reports. This makes the app feel like an actual production pipeline rather than a single model call. The biggest lesson was that structured outputs are more powerful than plain prose outputs for creative tools. A single prose response is hard to inspect. But structured outputs can become: I also learned that judge experience matters. That is why I added Run Judge Demo. Reviewers can experience the full product without configuring an API key. Another 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. The biggest challenge was balancing autonomy and control. If the app is too automatic, it feels like the user has no creative role. If the app asks for too much input, it stops feeling agentic. So I designed NovelPilot around this principle: The AI agents do the heavy lifting, but the user can always review, regenerate, edit, read, and export. Another 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. I would like to add: NovelPilot is my attempt to make AI fiction generation feel less like a chatbot and more like a writing room. The core idea is simple: One prompt. Nine agents. A complete story pipeline. Gemma 4 is the reasoning engine behind the process. It plans, writes, edits, tracks foreshadowing, checks continuity, and packages the final story. That is what makes NovelPilot more than a story generator. It is an AI-powered novel production studio.