Skip to content

Desktop: unify shared conversation context and prompt-cache contracts across PTT and chat #9680

Closed

Description

@Git-on-my-level

Problem

PTT and typed chat both derive their state from the canonical conversation journal, but the cross-surface context and cache contracts are incomplete and independently rendered.

Current symptoms include PTT losing direct conversational context after several turns/reconnects and no way to establish whether warm continuations are hitting provider prompt caches.

Evidence

  • desktop/macos/agent/src/runtime/context-snapshot.ts supplies only the most recent 64 conversation_turns; there is no declared older-history handoff or truncation contract.
  • Typed chat applies kernelSystemPolicy(...) plus a kernel snapshot, while PTT embeds the snapshot in its separate realtime system instruction. Equal journal data can therefore receive different semantic guidance.
  • desktop/macos/Backend-Rust/src/routes/chat_completions.rs has typed Anthropic cache breakpoints, but its documented <<<OMI_CACHE_SPLIT_V1>>> client sentinel has no desktop producer.
  • PTT records provider cached-token counts in RealtimeHubSession, but has no cache-plan identity, stable/dynamic instruction boundary, or replacement-session cache lifecycle telemetry.
  • The current deterministic cross-surface smoke covers transport/freshness, not 64/65-turn overflow, fixture-model direct recall, or warm-continuation cache behavior.

Proposed direction

Introduce one kernel-owned ConversationContextPlan that both typed chat and PTT consume. It should declare:

  • canonical conversation ID and retained sequence range;
  • omitted-turn count and an explicit older-history strategy;
  • a surface-neutral semantic policy, with only presentation/tool differences per surface;
  • a provider-safe stable cache prefix fingerprint separated from dynamic history/current input;
  • privacy-safe telemetry fields for plan identity, history range, cache read/write tokens, and PTT physical-session replacement reason.

Do not add content-specific handling for passwords or other user text. Direct recall must be a generic property of canonical conversation context.

Acceptance criteria

  • Typed and PTT construct the same conversation-history plan for a shared conversation.
  • Older-than-window history has explicit summary/retrieval/truncation behavior, with deterministic tests at 63/64/65 turns.
  • Direct-reference fixture tests pass for typed → PTT → typed, PTT → typed, reconnect, and barge-in without memory search.
  • Typed cache construction uses a typed stable/dynamic boundary rather than an unproduced sentinel.
  • PTT session/replacement paths rebuild from the current plan and emit privacy-safe cache-plan telemetry.
  • A fast PR gate validates continuity, cache-boundary stability, and no stale dynamic-context reuse; the named-bundle gauntlet remains the integration check.
  • A dashboard/query establishes warm-continuation cache-hit baseline by surface/provider/model before a cache SLO is set.

Root cause class

The journal is centralized, but semantic prompt policy and cache planning are distributed across the TypeScript kernel, Swift typed chat, Swift realtime voice, and the Rust provider request builder. This needs one typed contract rather than more surface-specific fallbacks.

Activity

  1. Git-on-my-level commented on Jul 14, 2026

    @Git-on-my-level
    MemberAuthor

    Parent/executor issue: #9688 — binds this issue and its siblings into one PR (Swift shadow-state census, bridge-lifecycle fuzzer, contract fixtures, adapter conformance, anti-regrowth guards) with per-child closure criteria. Sequenced after the PTT stability PR (post-#9660) to reuse its kernel-restore seam and fixture conventions.

  2. added a commit that references this issue on Jul 14, 2026
    fff4eef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions