Author's Notes — steering for the next few messages

The request, and why it's right

"…two separate fields — one for custom instructions (the ones that apply to the entire RP) and another for what is usually called Author's Notes — a field where you can specify plot directions for the current messages. That field should be closer to the top and easily accessible."

The two fields differ on the axis that actually matters mechanically: injection position. Recency is influence. Custom Instructions lands at the end of the system prompt (PromptContextManager.AppendCustomInstructionsAsync, PromptContextManager.cs:278-311) — far from the newest messages, which is correct for standing rules (style, POV, limits) and weak for steering. "The ambush happens tonight" belongs next to the latest turns, where model attention is. One field can't occupy both positions, so today users abuse Custom Instructions for steering — and then forget to remove the note, leaving "shift the tone to melancholy" applied for the next 200 messages. This isn't a second feature bolted on; it's one field doing two jobs badly, separated:

Custom Instructions Author's Note
Scope The entire RP — standing rules The next few messages — current plot direction
Injection End of system prompt (existing) Adjacent to the newest messages (new)
Lifetime Until changed Expires visibly (decided — see below)
Reuse Preset library (Prompt Presets) None — ephemeral by nature
UI home Who drawer (existing) Beside the message box, "closer to the top" (new)

Not a preset consumer — and that's the point

Author's Notes deliberately gets no preset library, no sharing, no default, no FK. It's ephemeral per-conversation steering text; a saved-notes library would be absurd. This sharpens the Prompt Presets scope rather than complicating it: Custom Instructions becomes cleanly "standing rules worth saving and reusing" (where presets make sense), and the steering use case that never fit the preset model gets its own home. None of the preset design — mutation semantics, moderation, defaults — applies here or needs to change.

Mechanism — second consumer of the tracker injection substrate

The hard part already exists. Trackers built exactly this: IHistoryMessageInjector (Core/Pipeline/Interfaces/) → ContextBuildingStageBase's per-message injector loop → MergeConsecutiveRoles folds the injected user-role OOC block into the adjacent user turn. WebTrackerHistoryInjector is today's only implementation; a WebAuthorNoteInjector is the second consumer (rule of two, satisfied on arrival), placing one OOC block immediately before the newest user message. Fixed depth in v1 — a configurable-depth knob is a later addition if real usage asks for it, not part of the first slice.

Three contract points the external review (2026-07-31) correctly forced, checked against the code:

As built (slice 0) — the three contract points, and what "identifiable" actually cost

All three held. The third one cost more machinery than the sketch implies, and that machinery is now shared, so it's worth stating exactly:

The bug this design nearly shipped — and why the boundary pass guarantees alternation

Worth recording, because the first cut was wrong in a way that only appears in composition and that a whole green test suite missed.

NormalizeForProvider was originally CollapseMarkedRuns: scoped to marked adjacencies, with a fast path that returned early when no message carried a marker. That reads as obviously safe — "no markers, nothing to undo" — and it is wrong, because a stage that deletes a marked message removes the last marker along with it. With trackers on (the default), assembly produces:

… assistant, tracker-OOC(User), author-note(User/AuthorNote), current-turn(User)

The marker-aware merge correctly refuses both folds. The Hybrid prose rebuild then drops the note — and the prompt that remains has no markers at all, so the fast path returned it untouched with tracker-OOC(User) sitting directly against current-turn(User). Anthropic-family models routed through Bedrock/Vertex reject that outright ("roles must alternate… found multiple user roles in a row"), so it would have surfaced as "Hybrid is broken for some users on some models."

Two things generalise out of it:

  1. The invariant a pipeline boundary owes the provider is alternation, not bookkeeping. Any stage that removes a message can re-open an adjacency, so the last pass must assert the property itself rather than trust a proxy for "did anyone defer a merge". NormalizeForProvider now collapses every non-System same-role adjacency (System is excluded — the leading system run is load-bearing for GetMessagesForInlineSystemApi and for prompt caching's static-prefix breakpoint).
  2. Every test had built the note into the one shape that cannot fail — sandwiched between an Assistant and the current User, where deleting it leaves alternation intact. The regression tests now pin the composition explicitly (BeatDirectionStageTests.ProcessAsync_TrackerBlockInFrontOfTheNote_ProseStillAlternatesForTheProvider, both prose paths; CurrentTurnInjectionTests.NormalizeForProvider_UnmarkedButNonAlternating_IsStillFixed), and both were confirmed to fail against the old implementation before the fix landed.

Known residual (not handled, deliberately). The regeneration insert uses FindLastIndex(m => m.Role == User). That is exact for every history shape reachable today: tracker blocks attach only to assistant indices, enhance-prompt interlacing inserts before its message, and enhanceAtEnd runs after the insert. It would place the note slightly late — after the current user turn rather than before it — only if history could end with two consecutive assistant rows (the regeneration path strips just one, leaving a tracker block as the trailing user-role message). No such path was found, and the outcome would be a suboptimal position rather than a broken prompt, since alternation is guaranteed at the boundary regardless. Left unhandled rather than speculatively coded around; if a "continue" feature ever appends a second assistant row, revisit this line.

One rule the build added that the spec didn't name: a single canonical liveness rule, WebConversation.AuthorNoteIsActive (text present, no expiry anchor, countdown not spent). The injector consults it directly; the Context Budget row and the DTO mapper carry documented, textually-identical mirrors of the same expression (their row types are query-shaped projections that can't reach the domain property — each mirror's comment names the canonical source, so a future edit knows to move all three). The prompt and the UI therefore cannot disagree about whether steering is being applied. Both conditions are load-bearing and neither is redundant — a branch inherits a spent countdown without an anchor, and an anchor can be stamped while the count reads zero.

V1 shape

Aspect Lean As built
Storage Nullable columns on the conversation: note text, optional short label (falls back to a truncated excerpt), TTL, the set-time anchor, and the expiry anchor once it fires (see anchor mechanics below). No history table — one active note per conversation As-built, inline on web_conversations (07c_web_conversations_author_note.sql). One refinement: TTL is two columns — author_note_ttl_turns (what the user picked, retained after expiry so a renew preselects the same quick-pick) and author_note_turns_remaining (the live countdown). Inline rather than a conversation_custom_instructions-style side table because the 1,000-char cap makes the row cheap, and it keeps the branch copy a column-list addition and the budget read a plain LENGTH()
Cap ~1,000 chars — it sits in the highest-attention zone; short is a feature, not a limit As-built, 1,000, enforced at the endpoint (friendly 400), in fn_set_conversation_author_note, and as a DB CHECK
Safety The same vector injection-pattern check Custom Instructions runs at save (ConversationsEndpoints.cs:919-927 shape) — this text lands in the prompt As-built — same injection_detection check, same ownership-before-compute ordering, plus the publish-review edit lock its sibling conversation writes carry
Injection Existing injector loop, one OOC block before the newest user message Diverged (as the doc's own contract points predicted): a new first-class slot, not the existing loop. See Mechanism
Expiry TTL in turns (assistant replies), not raw messages — a normal turn appends two messages (NewChatPage.tsx:816-823, messageCount += 2), so "15 messages" would silently mean 7½ exchanges. Quick-picks in the editor (e.g. 5 / 15 / 30 turns / until cleared). Default is a slice-0 call — lean 15 As-built shipped quick-picks 5 / 15 / 30 / until cleared, default 15 (the lean, taken). Revised 2026-08-05 (dev request): the picker is now two modes — "for a number of turns" (free entry, 1–99) or "until cleared" — default still 15
Context Budget Its own small display line (display-only, per the decided Context Budget scope in Prompt Presets) As-built — authorNoteTokens, chars * 2 / 7 like every sibling line, in its own rose segment next to Custom instructions. Reports 0 once the note stops injecting, so the budget and the prompt can't disagree
UI Collapsible row beside the message box — the structural precedent is ComposerEchoesBar.tsx (chat-v2 already has a composer-attached bar). Custom Instructions stays in the Who drawer As-built as AuthorNoteBar in ChatInput's topContent. Note: ComposerEchoesBar was the structural precedent only — it lives in the swipe footer and so exists on touch alone, whereas the note row must render in both layouts
Pause (Not in the original shape — added 2026-08-19 on user request.) An on/off switch on the note itself, so it can be taken out of play without being thrown away As-built, author_note_enabled on the conversation row + a surgical fn_set_conversation_author_note_enabled. See Pause
Live countdown (Not in the original shape — the countdown was only ever refreshed by a conversation load.) As-built 2026-08-19: the turn's terminal SSE frame carries the post-tick note state, so the composer chip and the expiry notice update in place. Closes the follow-up logged in the slice-0 verification record
Branching The branch copies the parent's note state (text, label, remaining TTL) like it copies persona and instructions — and there's no default to re-apply, so the persona carve-out has no analogue to violate As-built. The anchors are deliberately not copied — they are parent message ids, and the branch's messages are fresh rows, so a carried anchor would pin the notice to a slot that isn't in the branch

Expiry — decided: visible, and the chat says so

Decided (dev, 2026-07-31): expiry is visible, user-friendly, and surfaces in the chat itself — an inline notice at the expiry point, e.g. "Author's note expired: prolog", clickable.

The forget-to-clear problem doesn't vanish with the field split — it gets a shorter blast radius and, with this, a visible home:

Anchor mechanics — decided: count-based countdown, id-based anchor, resolved via version group

Decided (dev, 2026-07-31). The two halves use different currencies, on purpose:

Pause — decided: a third state, not a clear

Requested by a user (Raven, 2026-08-19), confirmed in the same thread: "it would be nice if the 'until cleared' option was 'until expired', and you could manually expire it. That way it's still there but inactive in case you want to use it again or need a reminder" → "just some way to disable it without clearing it completely is fine."

Built as an on/off switch on the note, not as a manual-expire. The literal ask — "let me expire it by hand" — would have overloaded expiry, which is a one-way, countdown-owned state with a transcript anchor and its own inline notice. Manually firing it would mean stamping an expiry anchor at a message that didn't consume anything, and un-firing it would mean deciding what the countdown resets to. A separate boolean keeps both states honest, and matches what the follow-up actually asked for ("some way to disable it").

The rules that make pause different from clear:

The countdown had to become live first

The same report carried a second half: "there is some weird behavior with the turns option if you set it after the fact. Both if you change from 'until cleared', or if it expires and you set a new number of turns. It no longer advances turns."

The countdown was advancing correctly server-side the whole time — pinned now by Tick_AfterSwitchingAnUntilClearedNoteToATurnCount_ResumesCountingDown and Tick_AfterRenewingAnExpiredNoteWithANewTurnCount_CountsDownAgain. What never advanced was the display: conversation.authorNote was only ever written by the conversation load and by the note's own save/clear, so the composer chip froze at whatever the last save returned and only caught up on the next page load. Setting a TTL mid-session is exactly when a user stares at that chip, which is why the symptom read as "only when you set it after the fact" — it was the slice-0 follow-up ("the expiry notice appears after a reload") seen from the other end.

Fixed by carrying the post-tick note state on the turn's terminal SSE frame (done / stopped), read on the pump side after the tick and patched onto the conversation by the client's shared terminal handler. Best-effort, like the tick itself — a failed read logs a Warning and leaves the client's current state alone rather than failing a stream over a chip.

Relationship to sibling docs

Open questions

Suggested slicing

One small slice, independent of Prompt Presets — could ship before or after preset slice 1. Storage columns + injector + save endpoint with cap/injection-check + composer row + expiry state + the virtual notice row + Context Budget line. The only shared-component work is the inline chat notice, extracted as shared from day one per the rule of two (retention warnings are the visible second consumer).

Acceptance Criteria

The feature is not done until every box below is verified ✅ against the running product.

User use cases — satisfiable + accessible (verify by driving the UI, not the code):

Behavior:

Invariants that must stay true (carve-outs — the spec'd-free/exempt paths):

Edges:

Additional invariant discovered during slice 0 (not in the original list, pinned because a bug was caught here):