**Date:** 2026-05-15
**Session:** ses_1d42640c8ffe7J2uRRGcGHXgbe
**Model:** kimi-for-coding/k2p6
**Status:** Draft — updated with source-code analysis
---
The current preprompt system causes:
1. **Massive duplication** — the same conversation appears 2-3 times in different formats
2. **Stale status markers** carried forward as "Latest" even after resolved
3. **Attention drift** — model cannot distinguish resolved bootstrap context from live message
4. **Context bloat** approaching 200K reload threshold faster than necessary
This directly caused a self-contradiction bug: the model stated a fact, then immediately offered to investigate that same fact.
---
The injection logic lives in dispatch-acp-HFOhX_U-.js (buildPersistentChatInjectedPrompt, line 966).
**Path A — Continuous session** (shouldInjectPersistentChatPrompt() returns false):
• Turn metadata
• `## Recent Perpetual Log Excerpt` (last **6** log entries)
• Current user message
**Path B — Reload / new backend session** (shouldInjectPersistentChatPrompt() returns true):
• Turn metadata
• `## Rolling Continuity Summary` (full `continuity-summary.txt`)
- Which itself contains: "Current thread" summary + **30** log entries
• `## Recent Perpetual Log Excerpt` (last **6** log entries **again**)
• Current user message
**Result:** On reload, the model sees the conversation **twice**: 30 entries inside the continuity summary + 6 more in the separate section. This is the duplication.
---
**For continuous sessions:**
• **Not needed at all** or **max 2 entries**
• The ACP backend already holds the full conversation in its context window
• The only purpose is catching immediate follow-ups ("so did you check?")
• **Current:** 6 entries. **Proposed:** 0-2 entries.
**For reloads:**
• **This is the compaction** — it's the only conversation history the model receives
• **Need more than 10** — current system injects 30 inside continuity summary + 6 separate
• **Proposed:** 20-25 entries as the single source of truth
• Remove the 30-entry duplicate inside continuity-summary
The continuity summary should be **state/memory only**, not conversation transcript.
**Remove from rebuildPersistentChatContinuitySummary() (JS, line 931):**
• `Recent log excerpt:` block (lines 940-943)
• Keep only: `Current thread / pending next action:` (latest user request, assistant status, actionable notes)
**Remove from render_summary() (Python memory script, lines 452-458):**
• `Recent conversation excerpt:` block
**Keep in continuity-summary:**
• Active decisions and guardrails
• Pending threads / open topics
• Timer status
• Model capability notes
In summarizePersistentChatCurrentThread() (JS, line 908):
• `Latest assistant status` should be the **immediately preceding turn only**
• Do not carry "ACP_TURN_FAILED" forward once the session has reloaded
• Add a "resolved" tag or drop the field if the error is historical
In buildPersistentChatInjectedPrompt() (JS, line 966):
• Add explicit markers between bootstrap context and live message
• Current: `[Persistent-chat authoritative state...]` then dumped text
• Proposed: clear `--- BOOTSTRAP CONTEXT (already resolved) ---` vs `--- LIVE TURN ---`
---
• [ ] `rebuildPersistentChatContinuitySummary()`: Remove `Recent log excerpt` block
• [ ] `buildPersistentChatInjectedPrompt()`:
- If continuous session: reduce readPersistentChatLogEntries(6) → readPersistentChatLogEntries(2) or skip entirely
- If reload: increase to 20-25 entries
- Add visual separator between bootstrap and live message
• [ ] `summarizePersistentChatCurrentThread()`: Fix stale status forwarding
• [ ] `render_summary()`: Remove `Recent conversation excerpt` section
• [ ] `render_decision_state()`: Compress to one-line format
• [ ] Verify `PERSISTENT_CHAT_CONTINUITY_PATH` is still read correctly after format change
• [ ] Test reload path: ensure 20-25 log entries are accessible on fresh session
---
| Component | Path |
|---|---|
| JS runtime patch | /home/gleb/openclaw-tools/patches/openclaw-runtime/dispatch-acp-HFOhX_U-.js |
| Python memory script | /home/gleb/openclaw-tools/scripts/persistent-chat-memory |
| Live JS (needs re-patch) | /home/openclaw/.local/npm-global/lib/node_modules/openclaw/dist/dispatch-acp-HFOhX_U-.js |
| Continuity summary output | /home/openclaw/workspace/state/persistent-chat/continuity-summary.txt |
| Preprompt debug output | /home/openclaw/workspace/state/persistent-chat/last-injected-preprompt.txt |
---
• **Context quality over token price**: The goal is reducing reloads at 200K, not saving API dollars
• **One fact, one location**: Conversation history lives in the per-turn recent log; decisions live in continuity summary
• **Continuous sessions need almost no log injection**: ACP already remembers
• **Reloads need generous log injection**: Because ACP remembers nothing; this is the compaction
• **Stale status is worse than no status**: An old error marked "Latest" causes the model to re-debug resolved issues
---
• `/home/openclaw/workspace/state/persistent-chat/reasoning-tuning-proposals.md` — broader reasoning-tuning ideas (proposals #1–5)
• This document focuses specifically on **Proposal #4: Bootstrap Context Hardening**
---
*Append implementation notes or test results below.*