Skip to content

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

refactor(tinyagents): move copy provider to host module

Steven Enamakel4c49fd30f0a7
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 0bba419089..fcce47a012 100644
--- a/crates/openhuman-core/src/agent/session_host/stop_summary.rs
+++ b/crates/openhuman-core/src/agent/session_host/stop_summary.rs
@@ -172,7 +172,7 @@ impl StopReasonKind {
Self::Generic => TurnStopCopyKey::Generic,
};
tinyagents_harness::turn_stop::render_copy(
- &crate::agent::tinyagents::middleware::repeated_failure::OpenHumanCopyProvider,
+ &crate::agent::tinyagents::host::OpenHumanCopyProvider,
&CopyRequest::TurnStop {
key,
operation: None,
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 a7d4138fc3..584be17c92 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
@@ -16,7 +16,6 @@ use tinyagents_harness::middleware::{
};
use tinyagents_harness::no_progress::FailurePolicy;
use tinyagents_harness::steering::SteeringHandle;
-use tinyagents_harness::turn_stop::CopyProvider;
use tinyagents_hooks::stop::StopLatch;
use tinyagents_hooks::stop::{self, TerminalInferenceFailureKind};
use tinyinference_llm::tool::ToolCall as TaToolCall;
@@ -28,30 +27,6 @@ use crate::util::truncate_with_ellipsis;
use tinyagents_harness::middleware::EphemeralInstructionMiddleware;
use tinyinference_llm::failure::is_recoverable_failure_text as is_recoverable_tool_failure;
-pub(crate) struct OpenHumanCopyProvider;
-
-impl CopyProvider for OpenHumanCopyProvider {
- fn copy_override(
- &self,
- request: &tinyagents_harness::turn_stop::CopyRequest<'_>,
- ) -> Option<String> {
- use tinyagents_harness::turn_stop::{CopyRequest, TurnStopCopyKey};
-
- match request {
- 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(),
- ),
- CopyRequest::TurnStop { key: TurnStopCopyKey::MissingConnection, .. } => Some(
- "a service this needs isn't connected; connect it in Connections, then ask me to try again".to_owned(),
- ),
- _ => None,
- }
- }
-}
-
pub(crate) fn user_actionable_escalation(tool: &str, error: &str) -> Option<String> {
let lower = error.to_lowercase();
let permission_or_scope_failure = lower.contains("[composio:error:insufficient_scope]")
@@ -185,13 +160,23 @@ struct HaltCopy;
impl FailurePolicy for HaltCopy {
fn identical_halt_summary(&self, tool: &str, count: u32, failure_text: &str) -> String {
- stop::halt_summary::retry_exhausted(&OpenHumanCopyProvider, tool, count, failure_text)
+ stop::halt_summary::retry_exhausted(
+ &crate::agent::tinyagents::host::OpenHumanCopyProvider,
+ tool,
+ count,
+ failure_text,
+ )
.summary
}
fn no_progress_halt_summary(&self, consecutive: u32, tool: &str, failure_text: &str) -> String {
- stop::halt_summary::no_progress(&OpenHumanCopyProvider, consecutive, tool, failure_text)
- .summary
+ stop::halt_summary::no_progress(
+ &crate::agent::tinyagents::host::OpenHumanCopyProvider,
+ consecutive,
+ tool,
+ failure_text,
+ )
+ .summary
}
}
@@ -339,34 +324,28 @@ impl FailureScopePolicy<OpenHumanRunContext> for HostFailurePolicy {
let heuristic = heuristic_text(&call.name, &failure_text);
if result.is_error && !is_command_exit_report(&failure_text) {
if let Some(kind) = stop::terminal_inference_failure_kind(heuristic) {
- let summary = match kind {
+ let halt = match kind {
TerminalInferenceFailureKind::BudgetExhausted => {
stop::halt_summary::budget(
- &OpenHumanCopyProvider,
+ &crate::agent::tinyagents::host::OpenHumanCopyProvider,
&call.name,
&failure_text,
)
- .summary
}
TerminalInferenceFailureKind::ProviderConfig => {
stop::halt_summary::provider_config(
- &OpenHumanCopyProvider,
+ &crate::agent::tinyagents::host::OpenHumanCopyProvider,
&call.name,
&failure_text,
)
- .summary
}
};
return FailureAssessment::Halt {
- summary: summary.clone(),
+ summary: halt.summary.clone(),
cause: Some(tinyagents_harness::no_progress::ClassifiedStopCause {
- class: match kind {
- TerminalInferenceFailureKind::BudgetExhausted => "out_of_credits",
- TerminalInferenceFailureKind::ProviderConfig => "provider_config",
- }
- .to_owned(),
+ class: halt.class.as_str().to_owned(),
operation: call.name.clone(),
- summary,
+ summary: halt.summary,
}),
};
}
diff --git a/crates/openhuman-core/src/web_chat/web_tests_error_copy_fixture_tests.rs b/crates/openhuman-core/src/web_chat/web_tests_error_copy_fixture_tests.rs
index 9cef56c9ac..9c4684e335 100644
--- a/crates/openhuman-core/src/web_chat/web_tests_error_copy_fixture_tests.rs
+++ b/crates/openhuman-core/src/web_chat/web_tests_error_copy_fixture_tests.rs
@@ -273,8 +273,9 @@ fn shared_budget_matcher_reproduces_each_legacy_matcher_on_the_corpus() {
#[test]
fn loop_guard_halt_summaries_are_byte_identical() {
use crate::agent::tinyagents::middleware::repeated_failure::{
- user_actionable_escalation, OpenHumanCopyProvider,
+ user_actionable_escalation,
};
+ use crate::agent::tinyagents::host::OpenHumanCopyProvider;
use tinyagents_hooks::stop;
assert_eq!(
stop::halt_summary::budget(&OpenHumanCopyProvider, "delegate", "boom").summary,