Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(agent): route stop summaries through tinyagents copy table

Steven Enamakel68f7e39c1d8a
diff --git a/crates/openhuman-core/src/agent/session_host/stop_summary.rs b/crates/openhuman-core/src/agent/session_host/stop_summary.rs
index 62f82ed169..ff8ca92b81 100644
--- a/crates/openhuman-core/src/agent/session_host/stop_summary.rs
+++ b/crates/openhuman-core/src/agent/session_host/stop_summary.rs
@@ -19,7 +19,23 @@
use std::fmt::Write as _;
use super::turn_checkpoint::CheckpointToolResult;
-use tinyagents_harness::turn_stop::TurnStop;
+use tinyagents_harness::turn_stop::{CopyProvider, CopyRequest, TurnStop, TurnStopCopyKey};
+
+struct OpenHumanStopCopy;
+
+impl CopyProvider for OpenHumanStopCopy {
+ fn copy_override(&self, request: &CopyRequest<'_>) -> Option<String> {
+ match request {
+ CopyRequest::TurnStop { key: TurnStopCopyKey::ProviderConfig, .. } => Some(
+ "the configured model or provider rejected the request; check the model and API key in Connections".into(),
+ ),
+ CopyRequest::TurnStop { key: TurnStopCopyKey::MissingConnection, .. } => Some(
+ "a service this needs isn't connected; connect it in Connections, then ask me to try again".into(),
+ ),
+ _ => None,
+ }
+ }
+}
/// Longest error line shown for one tool, in characters.
const ERROR_LINE_CHARS: usize = 120;
@@ -149,8 +165,32 @@ impl StopReasonKind {
}
/// English copy completing "I stopped this turn early because …".
- pub(crate) fn copy(self) -> &'static str {
- crate::inference::failure_copy::stop_summary_copy(self.key())
+ pub(crate) fn copy(self) -> String {
+ // Render through TinyAgents' neutral copy table while preserving the
+ // OpenHuman settings destinations for the two actionable classes.
+ let key = match self {
+ Self::Transient => TurnStopCopyKey::Transient,
+ Self::UncertainSideEffect => TurnStopCopyKey::UncertainSideEffect,
+ Self::Authentication => TurnStopCopyKey::Authentication,
+ Self::Permission => TurnStopCopyKey::Permission,
+ Self::Policy => TurnStopCopyKey::Policy,
+ Self::MissingProgram => TurnStopCopyKey::MissingProgram,
+ Self::NotFound => TurnStopCopyKey::NotFound,
+ Self::InvalidCalls => TurnStopCopyKey::InvalidCalls,
+ Self::Unavailable => TurnStopCopyKey::Unavailable,
+ Self::SiteRefused => TurnStopCopyKey::SiteRefused,
+ Self::RepeatedFailure => TurnStopCopyKey::RepeatedFailure,
+ Self::VariedFailures => TurnStopCopyKey::VariedFailures,
+ Self::RepeatingStep => TurnStopCopyKey::RepeatingStep,
+ Self::OutOfCredits => TurnStopCopyKey::OutOfCredits,
+ Self::ProviderConfig => TurnStopCopyKey::ProviderConfig,
+ Self::MissingConnection => TurnStopCopyKey::MissingConnection,
+ Self::Generic => TurnStopCopyKey::Generic,
+ };
+ tinyagents_harness::turn_stop::render_copy(
+ &OpenHumanStopCopy,
+ &CopyRequest::TurnStop { key, operation: None },
+ )
}
/// Read the kind from a breaker stop note. The notes come from a fixed
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
index f027e861d9..81437377b5 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
@@ -35,9 +35,9 @@ impl CopyProvider for OpenHumanHaltCopy {
use tinyagents_harness::turn_stop::{CopyRequest, TurnStopCopyKey};
match request {
- CopyRequest::ProviderConfig { .. } => Some(
- "Stopping: the configured model/provider rejected the request (e.g. an unknown model, a non-chat/embedding model, a missing credential, or a region block) — retrying will not help. Fix the model or API key in Connections → API keys → LLM. Details:\n".to_owned(),
- ),
+ CopyRequest::ProviderConfig { tool, last_error } => Some(format!(
+ "Stopping: the `{tool}` step failed because the configured model/provider rejected the request (e.g. an unknown model, a non-chat/embedding model, a missing credential, or a region block) — retrying will not help. Fix the model or API key in Connections → API keys → LLM. Details:\n{last_error}"
+ )),
CopyRequest::TurnStop { key: TurnStopCopyKey::ProviderConfig, .. } => Some(
"the configured model or provider rejected the request; check the model and API key in Connections".to_owned(),
),
@@ -88,9 +88,7 @@ fn terminal_inference_halt_summary(kind: TerminalInferenceFailureKind, tool: &st
stop::halt_summary::budget(&OpenHumanHaltCopy, tool, error).summary
}
TerminalInferenceFailureKind::ProviderConfig => {
- let summary = stop::halt_summary::provider_config(&OpenHumanHaltCopy, tool, error).summary;
- // Keep the provider settings destination in OpenHuman's copy.
- summary.replace("Fix the model or API key, then try again.", "Fix the model or API key in Connections → API keys → LLM.")
+ stop::halt_summary::provider_config(&OpenHumanHaltCopy, tool, error).summary
}
}
}
@@ -364,8 +362,8 @@ impl FailureScopePolicy<OpenHumanRunContext> for HostFailurePolicy {
summary: summary.clone(),
cause: Some(tinyagents_harness::no_progress::ClassifiedStopCause {
class: match kind {
- crate::inference::failure_copy::TerminalInferenceFailure::BudgetExhausted => "out_of_credits",
- crate::inference::failure_copy::TerminalInferenceFailure::ProviderConfig => "provider_config",
+ TerminalInferenceFailureKind::BudgetExhausted => "out_of_credits",
+ TerminalInferenceFailureKind::ProviderConfig => "provider_config",
}.to_owned(),
operation: call.name.clone(),
summary,