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
fix(cache): exclude runtime nudges from stable prefix
Steven Enamakel2b646ce2411b
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/prompt_cache.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/prompt_cache.rsindex c7e55f6fce..6a612c1880 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/prompt_cache.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/prompt_cache.rs@@ -122,11 +122,11 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>// Content-derived, so a guard reading it before dispatch sees a// system-prompt or tool-schema edit; the crate recomputes it from// the final bytes at dispatch.- let system_messages: Vec<&TaMessage> = request- .messages- .iter()- .filter(|m| matches!(m, TaMessage::System(_)))- .collect();+ // Steering nudges and other runtime notes may be System messages+ // after the first user turn. They belong to the changing history,+ // not to the cacheable leading system tiers declared above.+ let system_messages: Vec<&TaMessage> =+ request.messages.iter().take(leading_system).collect();request.prompt_fingerprint = Some(stable_prefix_fingerprint(&serde_json::json!({"system": system_messages,"tools": &request.tools,diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rsindex b82d1271be..17d1f7cc8f 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rs@@ -260,6 +260,37 @@ async fn prompt_cache_segments_are_stable_across_a_threads_turns() {assert!(turn_one.prompt_fingerprint.is_some());}+#[tokio::test]+async fn prompt_cache_segments_ignore_system_nudges_after_the_user_turn() {+ let mw = PromptCacheSegmentMiddleware;+ let tools = vec![ToolSchema::new(+ "shell",+ "run a command",+ json!({"type": "object"}),+ )];+ let prefix = vec![+ TaMessage::system("stable"),+ TaMessage::system("context"),+ TaMessage::user("work on this"),+ ];+ let mut before = ModelRequest::new(prefix.clone()).with_tools(tools.clone());+ let mut after = ModelRequest::new(+ prefix+ .into_iter()+ .chain([TaMessage::system(+ "[no progress since step 4] change strategy",+ )])+ .collect(),+ )+ .with_tools(tools);++ mw.before_model(&mut ctx(), &(), &mut before).await.unwrap();+ mw.before_model(&mut ctx(), &(), &mut after).await.unwrap();++ assert_eq!(before.cache_segments, after.cache_segments);+ assert_eq!(before.prompt_fingerprint, after.prompt_fingerprint);+}+#[tokio::test]async fn prompt_cache_segments_name_each_system_tier_and_skip_tools_under_a_text_dialect() {// Two leading system messages (stable+context, then volatile) are twodiff --git a/vendor/tinyagents b/vendor/tinyagentsindex 93c3582db6..09e0ac9955 160000--- a/vendor/tinyagents+++ b/vendor/tinyagents@@ -1 +1 @@-Subproject commit 93c3582db6a4869f4e019e52ebec209913502172+Subproject commit 09e0ac9955fcb0599adaf628a07b85208d01cd30