The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore: update documentation and comments to reflect removal of PromptCacheSegmentMiddleware
Steven Enamakeldcca28543625
diff --git a/crates/openhuman-core/src/agent/prompts/README.md b/crates/openhuman-core/src/agent/prompts/README.mdindex ed40c17ed2..643f2f073e 100644--- a/crates/openhuman-core/src/agent/prompts/README.md+++ b/crates/openhuman-core/src/agent/prompts/README.md@@ -144,8 +144,7 @@ instead of trailing the memory sections.each leading system message its own cacheable segment(`PromptBuilder::push_system_messages`), so a rewritten memory file or a newlyconnected service changes the second segment and leaves the first-byte-identical; `PromptCacheSegmentMiddleware` mirrors that split in the-segment ids it declares. A prefix is reusable only up to the first differing+byte-identical (`system`, `system.1`). A prefix is reusable only up to the first differingbyte, so a volatile section rendered early invalidates every stable bytebehind it. Two consequences are visible in this module: `DateTimeSection`renders only the clock *rules* and is `Stable` (the live timestamp rides thediff --git a/crates/openhuman-core/src/agent/tinyagents/prompt_cache_golden_tests.rs b/crates/openhuman-core/src/agent/tinyagents/prompt_cache_golden_tests.rsindex 7c49d64322..6ed7f419eb 100644--- a/crates/openhuman-core/src/agent/tinyagents/prompt_cache_golden_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/prompt_cache_golden_tests.rs@@ -8,9 +8,10 @@//! Provider adapters are pure functions of that request, so identical requests//! render byte-identical `cache_control` placement.//!-//! The fixture was captured from the host `PromptCacheSegmentMiddleware`-//! before it was deleted in favour of the vendor loop owning the frozen-//! prefix; it must not change. Regenerate (only on a deliberate, reviewed+//! The fixture was captured with the former host+//! `PromptCacheSegmentMiddleware` installed (and the host-side frozen-prefix+//! field set); it was then deleted because the vendor loop already owns the+//! frozen prefix, and the fixture must not change. Regenerate (only on a deliberate, reviewed//! contract change) with `UPDATE_PROMPT_CACHE_GOLDEN=1`.use std::sync::Arc;diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs b/crates/openhuman-core/src/agent/tinyagents/turn_policy.rsindex be7e6009f5..45b7721b70 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs@@ -248,8 +248,8 @@ pub(crate) fn run_policy_for(max_iterations: usize, response_cache_enabled: bool// stable prefix into `provider_options`, and the provider adapters see// `protect_prompt_prefix` and emit explicit `cache_control` breakpoints// where the provider needs them (native Anthropic, OpenRouter relays).- // The stable prefix itself is declared per request by the host- // `PromptCacheSegmentMiddleware`.+ // The stable prefix itself is declared per request by the vendor loop from+ // the session's frozen system prefix (`RunContext::frozen_system_prefix_len`).policy.cache.protect_prompt_prefix = true;// Response caching is gated: it is enabled only for deterministic internal// runs (which additionally attach a `ResponseCache`). Interactive chat turnsdiff --git a/gitbooks/developing/architecture/agent-harness.md b/gitbooks/developing/architecture/agent-harness.mdindex 82b08f0f34..c864fa3a4c 100644--- a/gitbooks/developing/architecture/agent-harness.md+++ b/gitbooks/developing/architecture/agent-harness.md@@ -219,7 +219,7 @@ Keeping the bytes stable is necessary, not sufficient: the provider still has to- **OpenRouter forwards markers to Anthropic and Gemini** but adds none itself; hosted OpenAI rejects unknown content-part fields. The OpenRouter slug (and any endpoint on `openrouter.ai`) enables `OpenAiModel::with_explicit_cache_control`, which marks the last system and last user message; every other Chat Completions endpoint stays unmarked.- **The routing hint is separate from the markers.** The harness derives a `prompt_cache_key` from the declared stable prefix and puts it in `provider_options`, so every turn of a thread, and every sub-agent sharing its system prompt and tool set, routes to the same cache shard on providers that shard (OpenAI's `prompt_cache_key`). Adapters that have no such concept drop it. The managed backend receives it as a top-level body field alongside `thread_id`.-All three hang off `RunPolicy::cache.protect_prompt_prefix`, which the host sets unconditionally, and off the `PromptCacheSegmentMiddleware`, which declares the system prompt and tool catalogue as the cacheable prefix on every request. Until tinyagents began stamping that effective policy onto the outgoing request, both readers consulted `request.cache_policy` alone, always `None` here, so the flag was diagnostic only and no marker or key ever reached the wire. The `[cache]` debug line on every model call now reports whether a key was injected and how many cacheable segments were declared; `cache_read_tokens` on the usage that comes back is the number that proves it worked.+All three hang off `RunPolicy::cache.protect_prompt_prefix`, which the host sets unconditionally, and off the cacheable prefix the tinyagents loop declares on every request from the session's frozen system prefix (system prompt tiers, then the tool catalogue); the host has no middleware of its own for this. Until tinyagents began stamping that effective policy onto the outgoing request, both readers consulted `request.cache_policy` alone, always `None` here, so the flag was diagnostic only and no marker or key ever reached the wire. The `[cache]` debug line on every model call now reports whether a key was injected and how many cacheable segments were declared; `cache_read_tokens` on the usage that comes back is the number that proves it worked.Measure this rather than reasoning about it. `CAPTURE_ALL=1 node scripts/debug/capture-first-inference.mjs` records a whole session's requests, `scripts/debug/run-multi-turn-capture.mjs` drives a multi-turn thread through the production RPC, and `scripts/debug/audit-inference-prefix.mjs` reports the first divergence and attributes it. A single-turn capture cannot see any of these, the question is never what turn 1 costs, it is whether turn 2 can reuse it.