mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-27 21:08:00 +00:00
1.6 KiB
1.6 KiB
03.2 — Crate cache layer
Steps
- Prompt-prefix protection: install
PromptCacheGuardMiddlewareinassemble_turn_harness; declare the stable prefix withModelRequest::cache_segments(system prompt + tool schemas asPromptSegments from the prompt builder). RouteCacheLayoutEvents to the event bridge as warnings — replaces the old cache_align warn-log with structured events. SetCachePolicy.protect_prompt_prefix = trueon the turnRunPolicy. - Response cache: attach a
ResponseCacheviaAgentHarness::with_response_cachefor deterministic internal calls (summarizer/triage/subconscious-style runs; NOT interactive chat). Start withInMemoryResponseCache; aStore-backed impl overFileStoreis a follow-up if hit rates justify it. Gate per-request withModelRequest::with_cache_policy. - Assert prompt-prefix stability across turns in a fixture test:
PromptCacheLayout::from_request(...).is_prefix_stable_against(prev)— volatile content (timestamps, memory, steering) must land in the tail. This formalizes the prompt-cache-stability decisions currently embedded in session prompt assembly. - Surface
CacheHit/CacheMisscounts in the cost footer projection.
Deletions
CacheAlignMiddleware's bespoke detector oncePromptCacheGuardMiddleware- layout events cover it (keep OpenHuman's volatile-token vocabulary as test fixtures).
Acceptance
- Prefix-stability fixture green over a 3-turn session with memory injection.
- Response-cache hit serves an identical deterministic request (test with
MockModel::call_count).