fix(jcode): keep journal corrections turn-neutral so new turns still count#819
Conversation
…count When a session snapshot ends on a user message, a turn-start is pending as the append-only journal is merged. parse_jcode_messages runs the journal through the same mutable turn-state context as the snapshot, so a journal entry that merely corrects an already-snapshotted assistant id (a replace, whose is_turn_start is overwritten by the snapshot's flag during the merge) consumes that pending turn-start. A subsequent brand-new journal assistant is then never marked is_turn_start, under-counting the session's turn_count by one. Make a journal message that only replaces an already-emitted dedup_key turn-neutral: it no longer advances the turn-state machine (its turn flag is discarded anyway), so the pending turn-start survives for the next new message. The snapshot pass passes `None` and is unchanged. Bumps CACHE_SCHEMA_VERSION 24 -> 25 so caches holding the under-counted turn flags reparse.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Review follow-up: CI's Lint job rejected the manual two-line wrap of the is_replacement binding; the call fits under the 100-col limit, so rustfmt collapses it onto one line. Confidence: high Scope-risk: narrow
# Conflicts: # crates/tokscale-core/src/message_cache.rs
|
Thanks @Nanako0129 — this is a really well-built fix. The issue write-up in #818, the turn-neutral replacement approach, the regression test that genuinely fails pre-fix (I verified: without the fix it panics at |
|
Shipped in v4.0.11, included in the latest v4.1.0 🎉 @Nanako0129 |
When a session snapshot ends on a user message, a turn-start is pending as the append-only journal is merged.
parse_jcode_messagesruns the journal through the same mutable turn-statecontextas the snapshot, so a journal entry that merely corrects an already-snapshotted assistant id (a replace, whoseis_turn_startis overwritten by the snapshot's flag during the merge) consumes that pending turn-start. A subsequent brand-new journal assistant is then never markedis_turn_start, under-counting the session'sturn_countby one.This makes a journal message that only replaces an already-emitted
dedup_keyturn-neutral: it no longer advances the turn-state machine (its turn flag is discarded anyway), so the pending turn-start survives for the next new message. The snapshot pass passesNoneand is unchanged.journal_correction_of_snapshot_message_keeps_pending_turn_startbuilds a snapshot ending on a user message, a journal that first corrects the snapshot assistant and then opens a new turn, and asserts both turns are counted; it fails before the change (the new turn'sis_turn_startis false) and passes after.Bumps
CACHE_SCHEMA_VERSION24 -> 25 so caches holding the under-counted turn flags reparse. (If a sibling schema-touching fix lands first, this needs a trivial rebase to the next number.)Fixes #818
Summary by cubic
Fixes under-counted turn tracking in Jcode sessions by making journal corrections turn-neutral, so a new assistant message after a user still starts a turn. Also bumps cache schema and includes a minor rustfmt cleanup.
Bug Fixes
dedup_keys to detect journal replacements and keep them turn-neutral.journal_correction_of_snapshot_message_keeps_pending_turn_start.Migration
CACHE_SCHEMA_VERSIONto 26 to invalidate caches carrying under-countedis_turn_start.Written for commit b46b13b. Summary will update on new commits.