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(agent): preserve pending nudges across control actions
Steven Enamakelb2fa325dafc7
diff --git a/crates/openhuman-core/src/agent/agent_turn_loop_nudge_tests.rs b/crates/openhuman-core/src/agent/agent_turn_loop_nudge_tests.rsindex 8f790c17f5..bf7a5a7dda 100644--- a/crates/openhuman-core/src/agent/agent_turn_loop_nudge_tests.rs+++ b/crates/openhuman-core/src/agent/agent_turn_loop_nudge_tests.rs@@ -89,10 +89,7 @@ fn call(id: &str, name: &str) -> ChatResponse {}fn nudge_count(messages: &[Message]) -> usize {- messages- .iter()- .filter(|m| matches!(m, Message::System(_)) && m.text() == NUDGE)- .count()+ messages.iter().filter(|m| m.text().contains(NUDGE)).count()}async fn run_turn(@@ -148,7 +145,7 @@ async fn validation_nudge_reaches_the_retry_but_is_not_committed() {assert_eq!(requests.len(), 2, "one failing call, then the retry");assert!(- matches!(requests[1].last(), Some(m @ Message::System(_)) if m.text() == NUDGE),+ requests[1].last().is_some_and(|m| m.text().contains(NUDGE)),"the retry request must end with the nudge, got {:?}",requests[1].last());@@ -193,10 +190,13 @@ async fn a_second_validation_failure_rearms_the_nudge() {.await;assert_eq!(requests.len(), 3);- assert_eq!(requests.iter().map(|r| nudge_count(r)).collect::<Vec<_>>(), [0, 1, 1],- "each failure nudges exactly the request that follows it; a consumed nudge is not carried over");+ assert_eq!(+ requests.iter().map(|r| nudge_count(r)).collect::<Vec<_>>(),+ [0, 1, 1],+ "each failure nudges exactly the request that follows it; a consumed nudge is not carried over"+ );assert!(- matches!(requests[2].last(), Some(m @ Message::System(_)) if m.text() == NUDGE),+ requests[2].last().is_some_and(|m| m.text().contains(NUDGE)),"the re-armed nudge must end the request after the second failure");assert_eq!(diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/nudge_injector.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/nudge_injector.rsindex 76e6c2a762..db74c1cd74 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/nudge_injector.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/nudge_injector.rs@@ -27,6 +27,12 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext> for Pen"pending_nudge_injector"}+ // A prior middleware can request retry/stop control after a failed tool+ // call. The queued correction still has to reach that retry request.+ fn is_observer(&self) -> bool {+ true+ }+async fn before_model(&self,ctx: &mut RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rsindex 3d393a4964..0a1093c1f1 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs@@ -419,6 +419,12 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>"repeated_tool_failure"}+ // Failure accounting and corrective nudges must observe tool outcomes even+ // when an earlier middleware has already requested a control action.+ fn is_observer(&self) -> bool {+ true+ }+async fn before_tool(&self,_ctx: &mut RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,