Wire warm context, cold-history boundary, and lazy retrieval #106

Merged
lost-rob0t merged 32 commits from agent/conversation-cold-context into main 2026-08-19 04:13:57 +00:00
lost-rob0t commented 2026-08-18 20:13:00 +00:00 (Migrated from github.com)

What changed

Implements the managed hot/warm/cold conversation path for unbounded sessions.

  • durable transcript remains authoritative and unmodified;
  • existing warm artifacts are automatically loaded/ranked when warm_store/1 is configured;
  • adds a synthetic token-accounted managed_cold_history_boundary context unit when history lies outside the guaranteed hot tail;
  • the boundary tells the planner that older turns may be absent and shows the exact bounded search, slice, and peek forms for recovering them;
  • boundary instructions are projection state only: old user/assistant/tool messages are never rewritten;
  • adds a generic trusted external-context adapter and conversation-backed opaque cold handle;
  • managed turns no longer materialize terms(FullTranscript);
  • public rlm conversation pack/ledger/turn APIs route through rlm_conversation_runtime;
  • automatic warm production/compaction remains explicit and is not triggered under token pressure.

Canonical context contract

complete durable transcript
        |
        +--> bounded rolling hot context
        +--> existing warm artifacts
        +--> synthetic cold-history boundary
        `--> opaque lazy cold-history context
             peek / slice / search
        |
        v
shared hard token budget

Cold-history boundary

When the projected conversation extends beyond min_recent_turns, the managed runtime adds a mandatory, provider-visible boundary that reports the older prefix as outside the guaranteed hot tail and instructs the planner to recover original history before guessing.

Representative operations:

context(input(context), search("query"), Result).
context(input(context), slice(Start, Length), Result).
context(input(context), peek(item(Index)), Result).

The boundary is counted in the normal token ledger and exposed in result metadata as cold_history_boundary. Specialized callers can disable it with cold_history_boundary(false).

Tests

The managed-runtime tests prove:

  • warm context loads without caller-provided context_units/1;
  • managed turns reuse warm context without publishing new warm artifacts;
  • the cold-history boundary is mandatory and token-accounted;
  • the boundary text reaches the planner;
  • original old message refs/content remain unchanged after the turn;
  • the boundary can be explicitly disabled.

The existing cold-context end-to-end test also proves an old turn absent from active attention can be recovered through RLM search.

GitHub Actions on the exact head is authoritative.

## What changed Implements the managed hot/warm/cold conversation path for unbounded sessions. - durable transcript remains authoritative and unmodified; - existing warm artifacts are automatically loaded/ranked when `warm_store/1` is configured; - adds a synthetic token-accounted `managed_cold_history_boundary` context unit when history lies outside the guaranteed hot tail; - the boundary tells the planner that older turns may be absent and shows the exact bounded `search`, `slice`, and `peek` forms for recovering them; - boundary instructions are projection state only: old user/assistant/tool messages are never rewritten; - adds a generic trusted external-context adapter and conversation-backed opaque cold handle; - managed turns no longer materialize `terms(FullTranscript)`; - public `rlm` conversation pack/ledger/turn APIs route through `rlm_conversation_runtime`; - automatic warm production/compaction remains explicit and is not triggered under token pressure. ## Canonical context contract ```text complete durable transcript | +--> bounded rolling hot context +--> existing warm artifacts +--> synthetic cold-history boundary `--> opaque lazy cold-history context peek / slice / search | v shared hard token budget ``` ## Cold-history boundary When the projected conversation extends beyond `min_recent_turns`, the managed runtime adds a mandatory, provider-visible boundary that reports the older prefix as outside the guaranteed hot tail and instructs the planner to recover original history before guessing. Representative operations: ```prolog context(input(context), search("query"), Result). context(input(context), slice(Start, Length), Result). context(input(context), peek(item(Index)), Result). ``` The boundary is counted in the normal token ledger and exposed in result metadata as `cold_history_boundary`. Specialized callers can disable it with `cold_history_boundary(false)`. ## Tests The managed-runtime tests prove: - warm context loads without caller-provided `context_units/1`; - managed turns reuse warm context without publishing new warm artifacts; - the cold-history boundary is mandatory and token-accounted; - the boundary text reaches the planner; - original old message refs/content remain unchanged after the turn; - the boundary can be explicitly disabled. The existing cold-context end-to-end test also proves an old turn absent from active attention can be recovered through RLM search. GitHub Actions on the exact head is authoritative.
Sign in to join this conversation.
No description provided.