Scripts / Automatic Chapter Summaries (by Lane & zerochansu)

Automatic Chapter Summaries (by Lane & zerochansu)

Keeps long-running stories coherent by saving chapter summaries to a lorebook, keeping recent chapters in story context, and progressively condensing older memory to stay within a token budget.

Both Scope
MIT
Automation & Hooks
1 watcher
1 downloads

Description

The script automatically creates and maintains long-term chapter memory for your stories. Recent chapters can stay directly in NovelAI's story context, while older chapters are summarized into the lorebook and progressively condensed as the story grows.


What Does It Do?

  • Automatic Chapter Summaries - Generates AI summaries for completed chapters
  • Recent Story Buffer - Keeps your newest chapters unsummarized while they are still expected to fit in NovelAI's normal story context
  • Progressive Condensation - Compresses older summary memory as your story grows
  • Change Detection - Detects edits to previously summarized chapters
  • Automatic Regeneration - Can update summaries when their source chapters change
  • History-Aware Tracking - Keeps summary state synchronized across undo/redo and branching edits
  • Trim Anchor Support - Keeps chapter numbering and summary coverage aligned after older story text has been manually trimmed or archived
  • Backup & Recovery - Protects summary state during rebuilds and can recover from interrupted maintenance
  • Manual Controls - Rebuild, regenerate, condense, uncondense, and customize specific ranges
  • Summary Style Controls - Configure narration person, protagonist reference, prompts, and optional post-processing

How It Works

  1. Write your story normally
  2. End chapters using your configured chapter break token, such as ***
  3. Continue writing
  4. The newest chapters remain in the Recent Story Buffer
  5. Once a completed chapter falls behind that buffer, the script automatically creates a durable summary in the Chapter Summaries lorebook
  6. As summary memory grows, older summaries are progressively condensed to stay within the configured token budget

This means the script does not need to summarize a chapter immediately after you finish it.

By default, the newest 7 visible chapters are left as raw story text because they are expected to still be available in NovelAI's context. Summarization begins behind that window.

Set the Recent Story Buffer to 0 if you prefer the traditional behavior of summarizing every completed chapter immediately.


Major Improvements Since v1.7.1

Recent Story Buffer

The script now distinguishes between:

Recent story that NovelAI can still see directly

and

Older story that needs durable summary memory

By default, the newest 7 completed/visible chapters remain unsummarized. Different stories can override the global default independently.

This reduces unnecessary summary generation and avoids spending lorebook tokens repeating story material that is still directly available in context.

Trim Anchor

If you manually remove or archive older story text, you can set a Trim Anchor telling the script which chapter your existing summary memory already covers.

For example, if Chapters 1-20 have been removed from the live story but their summaries remain:

Trim Anchor: 20

The first chapter still visible in the story can continue as Chapter 21 instead of being incorrectly treated as Chapter 1.

Improved Summary Quality

The default summarization prompt now focuses more strongly on durable continuity rather than trying to recount every scene chronologically.

Summaries prioritize things such as:

  • important developments
  • established character or world state
  • lasting consequences
  • unresolved threads
  • information necessary to understand later chapters

Incidental scene detail is given less priority.

Summary Narration Controls

You can choose whether generated summaries use:

  • First person
  • Second person
  • Third person

You can also provide an optional preferred name, title, or pronoun for the protagonist.

Optional Summary Post-Processing

An optional second AI pass can edit generated chapter summaries before they are saved.

This can help:

  • remove incidental detail
  • tighten wording
  • reduce unsupported interpretation
  • improve long-term continuity focus

Because it requires an additional generation, it is disabled by default.

Custom Condensation

In addition to automatic progressive condensation, you can manually choose an exact chapter range and configure:

  • the chapter range
  • maximum output tokens
  • a custom condensation prompt

This makes it possible to deliberately compress a particular part of a long story without changing your global condensation settings.

Improved Progressive Condensation

Older summary memory is progressively compressed instead of relying on a single condensation step.

The script:

  • keeps recent summarized chapters detailed when possible
  • groups older detailed summaries into condensed ranges
  • gradually merges older condensed ranges when more space is needed
  • preserves higher-resolution recent memory for as long as the configured budget allows

Chronological Summary Context

Detailed and condensed summary entries are kept logically chronological when injected into context, even when their physical ordering inside the NovelAI Lorebook UI differs.

Redesigned Dashboard

The Chapter Summaries panel now provides a centralized view of:

  • summary coverage
  • token usage
  • changed chapters
  • failed chapters
  • condensed ranges
  • Recent Story Buffer
  • Trim Anchor
  • rebuild and recovery controls

Advanced maintenance actions are separated from normal everyday controls.


Key Features

Smart Memory Management

Automatic Chapter Summaries is designed around two different forms of story memory:

Recent raw story

  • Preserved directly in NovelAI's story context
  • Controlled by Recent Story Buffer

Older durable memory

  • Stored as chapter summaries
  • Progressively condensed as needed
  • Controlled by the summary token budget

This allows long stories to retain important continuity without summarizing everything immediately.


Progressive Condensation

When summary memory approaches its configured token threshold, the script automatically begins compressing older material.

The default strategy:

  1. Keep recent summarized chapters detailed
  2. Condense older detailed chapters into grouped ranges
  3. Merge the oldest condensed ranges when additional space is needed
  4. Continue until summary memory is back within the configured limit

Condensed ranges can also be manually restored with Uncondense when detailed summaries are needed again.


Change Detection

Fingerprint-based tracking detects when the underlying text of an already summarized chapter changes.

You can choose between:

Automatic

  • Detect changed chapters
  • Regenerate them automatically

Semi-Automatic

  • Detect and notify
  • Let you decide when to regenerate

Changed chapters can also be regenerated manually from the dashboard.


History-Aware Tracking

When enabled, the script tracks chapter-summary state across NovelAI history.

Undoing or redoing across chapter boundaries can restore the corresponding summary state rather than leaving summaries synchronized to the wrong branch.


Rebuild & Recovery

Rebuild All Summaries analyzes the current story and determines which summaries can be reused and which need regeneration.

Before major rebuild operations, the script creates recoverable backups.

If NovelAI is refreshed or interrupted during a rebuild, the script can reconcile the interrupted rebuild state rather than blindly starting over.

Reset Story Tracking is also available for cases where you intentionally want the current document to become the new authoritative starting point.


Configuration Highlights

SettingDefaultDescription
chapter_break_token***Marks chapter boundaries
lorebook_categoryChapter SummariesCategory containing summary memory
max_total_summary_tokens2000Maximum active summary-memory budget
condensation_threshold80%Begin progressive condensation at this percentage
recent_chapters_to_keep3Prefer keeping this many recent summarized chapters detailed
recent_raw_chapter_buffer7Newest visible chapters kept as raw story context before automatic summarization
chapters_per_condensed_group5Preferred size of newly condensed chapter groups
max_rebuild_backups3Number of rebuild bac

Scope Information

Supported:
Both
Recommended:
Account

License & Attribution

License:
MIT
Credits:
Based on Automatic Chapter Summaries (by Lane).