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
refactor(session_host): remove orphaned tool head repair
Steven Enamakele70710771225
diff --git a/crates/openhuman-core/src/agent/session_host/driver.rs b/crates/openhuman-core/src/agent/session_host/driver.rsindex cf8c4b6934..b5892da78f 100644--- a/crates/openhuman-core/src/agent/session_host/driver.rs+++ b/crates/openhuman-core/src/agent/session_host/driver.rs@@ -9,7 +9,6 @@ use crate::agent::tinyagents::SupplementalTrace;use helpers::{append_synthesized_block, driver_cancelled_with_snapshot, driver_error,driver_error_with_snapshot, driver_failure, ensure_snapshot_tools_are_executable,- repair_orphaned_tool_head,};use std::{collections::HashSet, sync::Arc, time::Instant};@@ -84,8 +83,6 @@ impl SessionDriver<OpenHumanRunContext> for OpenHumanSessionDriver {&self,mut request: DriverRequest<OpenHumanRunContext>,) -> Result<DriverOutcome, DriverFailure> {- // Heal an orphaned tool head before reading history.- repair_orphaned_tool_head(&mut request.history);// Use the policy and context prepared for this exact request.let tool_policy = request.run_contextdiff --git a/crates/openhuman-core/src/agent/session_host/driver/helpers.rs b/crates/openhuman-core/src/agent/session_host/driver/helpers.rsindex b3ec05ea05..67a0c8562b 100644--- a/crates/openhuman-core/src/agent/session_host/driver/helpers.rs+++ b/crates/openhuman-core/src/agent/session_host/driver/helpers.rs@@ -1,29 +1,5 @@use super::*;-pub(super) fn system_prefix_len(history: &[Message]) -> usize {- history- .iter()- .take_while(|message| matches!(message, Message::System(_)))- .count()-}--/// Drop `tool` messages that open the history right after the system prefix.-/// Their assistant turn is gone (an old unpaired trim, #6721), and the provider-/// rejects every request that carries them, so the thread can never recover-/// without this. Later system rows (e.g. a steering nudge) are kept.-pub(super) fn repair_orphaned_tool_head(history: &mut Vec<Message>) {- let prefix_len = system_prefix_len(history);- let orphans =- tinyagents_harness::summarization::advance_past_orphan_tools(&history[prefix_len..], 0);- if orphans > 0 {- tracing::warn!(- orphans,- "[session_host::driver] repaired orphaned tool head: dropped {orphans} leading tool message(s)"- );- history.drain(prefix_len..prefix_len + orphans);- }-}-pub(super) fn driver_error(error: impl std::fmt::Display) -> DriverFailure {driver_failure(error)}