{"slug": "ghostwriter-ai-what-if-the-ai-storyteller-remembers-every-mistake-you-make", "title": "Ghostwriter AI: What if the AI Storyteller Remembers Every Mistake You Make?", "summary": "A developer built Ghostwriter AI, an open-source interactive gothic horror storytelling generator that maintains a persistent memory ledger of player choices, clues and wounds so the narrative engine tracks consequences across a session. The full-stack app pairs a React 19/TypeScript frontend with a Python FastAPI backend that calls Google's open-weight Gemma models through the Gemini API, and ships with 13 automated Pytest tests. It was submitted to the DEV.to Hacktoberfest Week 4 2026 \"Ghost in the Machine\" challenge.", "body_md": "*This is a submission for the [Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine](https://dev.to/challenges/hacktoberfest-week4-2026-10-26)*\n\n**Ghostwriter AI — Every Choice Leaves a Scar** is an interactive, unscripted gothic horror storytelling generator designed to give players genuine narrative agency while confronting them with the indelible consequences of their decisions.\n\nTraditional text adventures rely on static, pre-written decision branches: choose option A or B to jump to passage 12 or 13. Conversely, modern conversational AI chatbots often suffer from narrative amnesia, abrupt tonal drift, or cheerful assistant personas that completely dissolve suspense.\n\nIn gothic folklore, a haunting is an unresolved echo of past trauma trapped inside an environment. In **Ghostwriter AI**, the *\"Ghost\"* is the persistent memory ledger trapped within the machine. \n\nThe machine does not just generate words—**it holds a grudge**. As you explore eerie domains (from the decaying halls of Blackwood Manor to abandoned sanitariums and cursed hamlets), the engine continuously tracks your discovered clues, psychological wounds, unprompted actions, and fateful decisions. Every choice leaves an irreversible scar on the narrative ledger, culminating in a climactic autopsy ending (*Escape*, *Survival with a cost*, *Tragic ending*, *Supernatural revelation*, or *Hidden ending*).\n\nThe application features a dark gothic aesthetic inspired by classic horror literature:\n\n`#0a0a0c`), dynamic vignette, subtle SVG noise film grain, and restrained blood-red accents.`[1]`, `[2]`, `[3]`) or type freeform custom actions (e.g., \n**An unscripted interactive horror-story generator where the machine remembers your decisions, powered by Google's open-weight Gemma model via the Gemini API.**\n\nBuilt for the **DEV.to Hacktoberfest Week 4 2026** Challenge: *\"Ghost in the Machine\"*.\n\nTraditional text adventures and branching narrative games rely on pre-written decision trees. If you choose Door A, you get pre-baked Paragraph 12; if you choose Door B, you get pre-baked Paragraph 13. While predictable, this approach limits player agency and quickly loses tension once branches are discovered.\n\nOn the other hand, unstructured conversational AI chatbots lack memory discipline: they frequently suffer from tone drift, forget past decisions within a few turns, and lack pacing or stakes.\n\n**Ghostwriter AI** bridges this gap\nIt acts as an intelligent, literary storyteller that weaves genuine gothic horror. Every choice you select—or custom unscripted action you…\n\nDirect Repository Link: [https://github.com/Harshitagarwal113/GhostWriter-AI](https://github.com/Harshitagarwal113/GhostWriter-AI)\n\nGhostwriter AI is built as a decoupled, high-performance full-stack web application designed for deterministic state management and zero-leak AI inference.\n\n```\nGhostWriter AI/\n├── frontend/                 # React 19 + TypeScript + Tailwind CSS + Vite\n│   ├── src/\n│   │   ├── components/       # AtmosphericBackground, StoryChoices, DarknessLedger, etc.\n│   │   ├── pages/            # LandingPage, StorySetupPage, StoryPlayerPage, EndingPage\n│   │   ├── hooks/            # useStorySession, useApiHealth\n│   │   ├── services/api.ts   # Centralized Fetch API client with timeouts & retry logic\n│   │   └── types/story.ts    # Type-safe TypeScript contracts\n├── backend/                  # Python 3.14 + FastAPI + Pydantic v2 + google-genai\n│   ├── app/\n│   │   ├── api/routes.py     # /api/health, /api/story/start, /api/story/advance\n│   │   ├── services/         # gemma_client.py, story_engine.py, story_memory.py\n│   │   ├── prompts/          # storyteller.py (gothic system instructions & templates)\n│   │   └── main.py           # FastAPI server with CORS & error handlers\n│   └── tests/                # 13 automated Pytest unit and integration tests\n└── README.md\n```\n\n`gemma-4-26b-a4b-it` default, `gemma-4-31b-it` high-reasoning alternative).`google-genai`) and the Gemini API delivery endpoint.` gemma_client.py` strips fences, isolates JSON object boundaries, and executes a bounded single-retry fallback to guarantee valid structured schemas without redundant token consumption.\nOpen innovation and open-weight models like **Gemma** are transformative for interactive fiction and creative AI development:\n\nThis application was developed, tested, and integrated with the assistance of agentic pair-programming workflows:\n\n```\nConversation ID: acff272d-74b8-48dc-9bf7-171b332d47c4\nTooling: DevRelay Gateway, Google Gen AI Python SDK, Browser Subagent Verification\n```\n\nDuring our live test of the *Haunted Mansion* scenario, the protagonist Eleanor encountered a weeping portrait over an ancient hearth. Instead of taking a pre-generated choice, we tested the custom action input:\n\n**Player Action**: *\"Press your fingertips against the peeling wallpaper near the hearth to feel for drafts.\"*\n\nGemma didn't give a canned response. It adapted to her exact touch:\n\n*\"Eleanor's fingers brush against the desiccated, floral patterns of the wallpaper... beneath the layer of decay, her touch finds the unmistakable, sharp edge of a recessed latch, cold as a tombstone. A hollow, rhythmic tremor shudders through the wall—vibrating like a biological pulse.\"*\n\nWhen she manipulated the latch in the final scene, the climax landed with true chills:\n\n*\"There is a wet, sickening sound—the sound of a suture tearing through muscle. The wall does not swing on hinges; it peels back like a heavy, weeping eyelid... Eleanor discovers that Blackwood Manor is not a house, but a predatory, sentient organism.\"*\n\nThe memory ledger immediately updated her status to **\"Sensory assimilation\"** and **\"Fatal entrapment\"**, sealing her fate in *\"The Eternal Pulse\"* ending. That was the moment the project truly came alive: the machine wasn't just predicting the next token—it was remembering her curiosity and turning it into her undoing.", "url": "https://wpnews.pro/news/ghostwriter-ai-what-if-the-ai-storyteller-remembers-every-mistake-you-make", "canonical_source": "https://dev.to/harshit_agarwal/ghostwriter-ai-what-if-the-ai-storyteller-remembers-every-mistake-you-make-h41", "published_at": "2026-10-28 07:04:10+00:00", "updated_at": "2026-10-28 07:11:22.315588+00:00", "lang": "en", "topics": ["generative-ai", "large-language-models", "ai-agents", "ai-tools", "developer-tools"], "entities": ["Ghostwriter AI", "Google", "Gemma", "Gemini API", "FastAPI", "React", "DEV.to", "Hacktoberfest"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/ghostwriter-ai-what-if-the-ai-storyteller-remembers-every-mistake-you-make", "markdown": "https://wpnews.pro/news/ghostwriter-ai-what-if-the-ai-storyteller-remembers-every-mistake-you-make.md", "text": "https://wpnews.pro/news/ghostwriter-ai-what-if-the-ai-storyteller-remembers-every-mistake-you-make.txt", "jsonld": "https://wpnews.pro/news/ghostwriter-ai-what-if-the-ai-storyteller-remembers-every-mistake-you-make.jsonld"}}