Lessons from Tangtang Writing’s state-machine and ledger architecture
A developer describes the LLM writing application 糖糖写作 as a three-layer system combining an eight-stage state machine, 26 stage-specific rule cards, and four structured memory ledgers for characters, facts, foreshadowing, and summaries. The report documents fixes for unrestricted ledger writes, lossy model-generated summaries, vector-retrieval errors, budget trimming, and state-machine deadlocks. In internal tests using DeepSeek V4.1 Flash, the application advanced through 260 chapters with an approximately 8% revision rate, though the developer says the results have not been independently reproduced.
The report provides concrete design patterns and failure modes for building long-form, multi-stage LLM applications, while clearly presenting its performance figures as unreplicated internal results.
一、先说结论:三个决定是对的,两个是纯踩坑
| 决定 | 判断 | 理由 |
|---|---|---|
| 流程做成显式状态机 | ✅ 对的 | 不然你根本不知道"现在该干嘛" |
| 记忆做成结构化台账 | ✅ 对的 | 上下文是容量,台账才是记忆力 |
| 规则按环节加载 | ✅ 对的 | 一次性注入会被自己稀释 |
| 台账让模型自由写 | ❌ 已经改掉 | 废稿会污染长期记忆,且是静默污染 |
| 摘要让模型自己概括 | ❌ 已经改掉 | 有损压缩 + 链式引用 = 误差复利 |
下面把"为什么"讲清楚。
二、架构长什么样(三层)
┌──────────────────────────────────────────┐
│ 控制层:8 环节状态机 │
│ C14 → DEEPEN → SEED → PLAN → OUTLINE → │
│ DRAFT → REVIEW → FINAL │
│ 职责:知道"现在第几步"、上一环缺字段不放行 │
├──────────────────────────────────────────┤
│ 约束层:26 张规则卡(按环节加载) │
│ 职责:告诉模型"这一步该怎么想" │
├──────────────────────────────────────────┤
│ 记忆层:四本台账(人物/事实/伏笔/摘要) │
│ 职责:让程序记住模型记不住的东西 │
└──────────────────────────────────────────┘