Why Long-Form LLM Writing Feels Hard: From Prompts to Cache
Long-form generation with large language models often feels unusable because model tier, context rot, task granularity, and cost compound. This article shows how to turn prompts into versioned skills, compress style into injectable profiles, externalize state in a pipeline, and design stable prefixes for high cache hit rates.
1. “Hard to use” is four problems stacked, not one
After trying LLMs on very long writing tasks, many developers share the same feeling: lightweight models are fast and cheap, but they “drop the thread” on complex structure; flagship models reason better, but they are slow, expensive, and often contradict themselves in long context. That feeling is four independent issues mixed together.
- Model-tier choice. The gap between light and flagship models is not only “how smart.” It is long-range constraint holding and instruction-following stability. Using a light model to polish a chapter is reasonable; using it to maintain a 100k-word world bible will fail.
- Context rot. As context grows, attention on early constraints falls. The model “forgets” character sheets, timelines, and naming rules.
- Task granularity. Treating “write a novel” as one chat instead of a pipeline almost always fails.
- Cost structure. Re-feeding the full bible and history every turn makes token use grow roughly quadratically; the bill collapses before quality does.
The takeaway is direct: the model is not the hard part. Treating a long task as a short conversation is.
2. Turn one-off chats into reusable skills
The first effective step is to upgrade prompts from “chat logs” to artifacts with a contract. A skill is a spec with input/output constraints so an agent loads the same rules on every call instead of relying on humans to paste them again.
name: longform-novel-writerversion: 1.2inputs:- world_bible: ./bible/world.md # world bible, low-frequency changes- style_profile: ./style/profile.json # style profile, very low-frequency changes- state: ./state/progress.json # progress and rolling summary- outline: ./outline/vol01.md # chapter outlineoutputs:- chapter: ./chapters/vol01/ch_012.mdconstraints:max_output_tokens: 8000forbidden: [unregistered characters, unregistered places, timeline reversals]must_keep: [point of view, tense, chapter length band]
This list is valuable in three ways: inputs are explicit so bible files are not omitted; outputs are checkable for automated regression; constraints are versioned—changing rules means changing files, not “memory.”
When you study open-source writing skills, do not copy them wholesale. Extract the control skeleton. Mature skills usually include character cards, pacing control, conflict escalation, and chapter hooks. Abstract those layers, then swap in your domain constraints to get a skill that fits your genre.
3. Style modeling: teach “how you write,” not “how to write”
A high-value practice is to export years of Q&A and long-form corpus into a local knowledge base for style alignment. Do not dump all of it into context. Extract three layers.
- Lexical: high-frequency content words, catchphrases, punctuation habits (short sentences, dash density, and so on).
- Syntactic: average sentence-length distribution, clause nesting depth, paragraph-length variance.
- Structural: openings, argument progression, how you close.
Put the result in a compact JSON so it can actually be injected:
{"avg_sentence_len": 18,"paragraph_len_p50": 3,"tone": "restrained, few adjectives, heavy on logical connectors","openings": ["lead with the conclusion", "lead with a counterexample"],"closings": ["one-line wrap-up", "leave one claim to verify"],"banned": ["vague lyricism", "stacked parallelisms"]}
Pair this with retrieval: for the current chapter topic, retrieve 3–5 most similar past passages as style exemplars, not the full corpus. Exemplars pin a distribution; they are not content sources.
4. A long-form pipeline: state must live outside the model
Generating on the order of 800k words in one project works not because of a single model call, but because state is written to the filesystem. A five-stage pipeline:
- World bible: characters, places, rules, timeline—single source of truth, updated infrequently.
- Volume outline → chapter outline: two-level decomposition; each chapter keeps under ~200 words of goal, conflict, and hook.
- Rolling summary: after every 3–5 chapters, compress to a fixed-length summary and replace the old one.
- Consistency pass: a separate low-temperature call that only checks names, timeline, and power-setting conflicts—no prose generation.
- Regression sampling: every 20 chapters, score one chapter for style to catch long-range drift.
def roll_summary(old_summary, new_chapters, max_chars=1200):merged = old_summary + "\n".join(new_chapters)return llm_call(system="Compress into a fact list of at most %d characters. Keep only character state, timeline, and unresolved conflicts." % max_chars,user=merged,temperature=0.2,)
Cap summary length. Otherwise the rolling summary itself becomes a new source of context pollution.
5. Cache hits: treat ~85% as a design target
High prefix-cache hit rates are not luck; they come from prompt layout. Common prefix caching needs a byte-stable public prefix, so prompts must be partitioned: stable region first, changing region last.
def build_prompt(bible, style, rolling, chapter_outline, draft_text):# Stable prefix: content, order, and no dynamic fieldsprefix = f"[STYLE]\n{style}\n[BIBLE]\n{bible}\n[SUMMARY]\n{rolling}"# Changing suffix: different every chaptersuffix = f"[OUTLINE]\n{chapter_outline}\n[DRAFT]\n{draft_text}"return prefix, suffix
Behaviors that break hits almost always put dynamic content in the prefix:
- timestamps, random IDs, or current username in the stable zone;
- concatenating retrieval results at the front every turn, changing the prefix fingerprint;
- switching model tier or reasoning config mid-run, invalidating the fingerprint;
- “lightly polishing” the stable zone—one character change recomputes everything.
Engineering rule: the stable zone only grows, it is not rewritten; all change is appended. When the world bible changes, accept one cold-start cost instead of constant jitter.
6. Common pitfalls and a debug checklist
- Power creep: no independent check pass; the protagonist becomes omnipotent. Use a rule list that is machine-decidable.
- Chapter length drift: put a length band in constraints and require a self-check after generation; do not rely on the model “remembering.”
- Style regression: if sample scores fall below a threshold, roll back the style-profile version.
- Cost blowups: measure cache hit rate before debating model tier. If hits are below 50%, fix prompt layout first, not a cheaper model.
- Stuffing context: the impulse to “include a bit more to be safe” ends in worse quality and a higher bill.
7. Closing
The difficulty of long-form generation is not single-shot capability. It is reusability, state management, and cost structure. After you settle prompts into contracted skills, compress style into injectable profiles, externalize memory to files, and lock a stable public prefix, choosing a model tier becomes the easy part—light models for volume, flagship models for hard spots, each in its lane.
