Repository navigation
0.48.0
Automatic prompt caching and cache diagnostics release (Phase A): adds Cache-Friendly Injection Mode (moving dynamic memories, non-constant lorebooks, and appended cantrip card deltas to user_tail), automatic Anthropic / OpenRouter cache_control breakpoint stamping, a Debug Prefix-Diff ("Cache Buster") detector, and unified Lorebook total_budget enforcement on Map stages and manual Pre-Forward Order slots.
Added
- Cache-Friendly Injection Mode (
UserSettings.cache_friendly_mode, opt-in, default off). Configurable under Settings → Prompt Caching. When enabled:- Dynamic Memory tail injection: persistent
[MEMORY]blocks are sorted deterministically by key and appended to the newestrole == "user"message (user_tail) via shared multimodal-safeappend_user_tail()instead of mutatingmessages[0]. - Non-constant lorebook redirection: non-constant
before_last_messageandin_chat_systemlorebook entries are automatically redirected touser_tailwhileis_constantandsystem_startentries stay pinned at the top of the prompt. - Legacy cantrip delta redirection: appended deltas on
context.character.personality,scenario, andexample_dialogs(when the mutated value starts with its seeded base value) are routed touser_tailinstead of rewritingmessages[0]; full replacements still apply normally.
- Dynamic Memory tail injection: persistent
- Automatic Anthropic / OpenRouter
cache_controlbreakpoints (UserSettings.auto_cache_control, opt-in, default off). Configurable under Settings → Prompt Caching. When enabled and forwarding to Anthropic, OpenRouter, or Claude models, stamps up to 2cache_control: {"type": "ephemeral"}breakpoints (lastsystemmessage + second-to-last non-system message) per failover candidate without mutating_gitv_messages_for_hashor non-Claude endpoints, emitting acache_controlDebug timeline entry. - Debug Prefix-Diff / "Cache Buster" detector (
app/services/cache_diagnostics.py).GET /api/debug/{exchange_id}now computescache_analysisagainst the immediately preceding debug exchange in the same chat: shared prefix token count & stability percentage, first diverging message index/role, culprit pipeline stage attribution, and a plain-English summary surfaced in a Prompt Cache Analysis banner on the Debug page. - Lorebook
total_budgetenforcement on Map stages and manual Pre-Forward Order slots._inject_stage_lorebooks(app/services/map_pipeline.py) and_inject_book_now(app/services/pipeline_order.py) now enforce each lorebook's allocated budget cap (lorebook_budget_chars), matching the default global pass.
Schema
072_user_settings_prompt_caching: addscache_friendly_mode BOOLEAN NOT NULL DEFAULT FALSEandauto_cache_control BOOLEAN NOT NULL DEFAULT FALSEtouser_settings.