Skip to content

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

refactor(session_host): drop typed failure-cause plumbing from stop summaries

Steven Enamakel85262acbc5dd
diff --git a/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs b/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs
index 2db2f74251..ef2f7ac37f 100644
--- a/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs
@@ -18,7 +18,6 @@ use tinyagents_harness::middleware::wrap_harness_instruction;
use crate::agent::{
session_host::turn_checkpoint::{
self, build_deterministic_checkpoint, build_deterministic_final_summary,
- build_deterministic_final_summary_with_cause,
close_verification_prompt, final_answer_instruction, harness_instruction_needles,
render_tool_results, results_from_tool_outcomes,
},
@@ -235,16 +234,12 @@ pub(super) struct GroundedClose {
/// additional provider calls once its recovery budget is exhausted.
fn classified_halt_close(outcome: &TinyagentsTurnOutcome) -> Option<GroundedClose> {
let reason = outcome.breaker_halt.as_deref()?;
- if outcome.failure_cause.is_none() && !reason.starts_with("Stopping after ") {
+ if !reason.starts_with("Stopping after ") {
return None;
}
let records = results_from_tool_outcomes(&outcome.tool_outcomes);
Some(GroundedClose {
- output: build_deterministic_final_summary_with_cause(
- &records,
- Some(reason),
- outcome.failure_cause.as_ref(),
- ),
+ output: build_deterministic_final_summary(&records, Some(reason)),
usage: RepairUsage::default(),
})
}
@@ -403,11 +398,7 @@ pub(super) async fn close_if_needed(
if needs_cap_close {
build_deterministic_checkpoint(&records, outcome.model_calls)
} else {
- build_deterministic_final_summary_with_cause(
- &records,
- stop_reason,
- outcome.failure_cause.as_ref(),
- )
+ build_deterministic_final_summary(&records, stop_reason)
}
};
diff --git a/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs b/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs
index bc60c4bf2c..2e6887a6bc 100644
--- a/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs
@@ -133,9 +133,9 @@ fn classified_halt_summary_uses_typed_cause_when_halt_copy_conflicts() {
fn classified_halt_summary_uses_typed_class_for_translated_notes() {
let note = "Interrompo aqui: bloqueado por política de segurança, orçamento esgotado.";
let cases = [
- ("out_of_credits", "inference budget"),
- ("provider_config", "configured correctly"),
- ("transient", "temporary service issues"),
+ ("out_of_credits", "inference credits"),
+ ("provider_config", "configured model or provider rejected"),
+ ("transient", "temporarily unavailable"),
("blocked_by_policy", "security settings"),
];
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 2a5ba971fb..0baadea0f3 100644
--- a/crates/openhuman-core/src/agent/session_host/stop_summary.rs
+++ b/crates/openhuman-core/src/agent/session_host/stop_summary.rs
@@ -212,8 +212,6 @@ impl StopReasonKind {
"validation" | "invalid_arguments" => Self::InvalidCalls,
"unavailable" | "service_refused" => Self::Unavailable,
"site_refused" => Self::SiteRefused,
- "out_of_credits" => Self::OutOfCredits,
- "provider_config" => Self::ProviderConfig,
_ => Self::Generic,
}
}
@@ -264,19 +262,7 @@ fn times(count: usize) -> String {
/// The user-facing reply for a turn the breaker stopped with `stop_note`.
pub(crate) fn render_stop_summary(results: &[CheckpointToolResult], stop_note: &str) -> String {
- render_stop_summary_with_cause(results, stop_note, None)
-}
-
-/// Render a stopped-turn summary from its typed cause when the harness has
-/// one. The note is only a compatibility source for old, untyped stops.
-pub(crate) fn render_stop_summary_with_cause(
- results: &[CheckpointToolResult],
- stop_note: &str,
- failure_cause: Option<&tinyagents_harness::no_progress::ClassifiedStopCause>,
-) -> String {
- let kind = failure_cause
- .map(|cause| StopReasonKind::from_failure_class(&cause.class))
- .unwrap_or_else(|| StopReasonKind::from_stop_note(stop_note));
+ let kind = StopReasonKind::from_stop_note(stop_note);
tracing::debug!(
reason = kind.key(),
results = results.len(),
diff --git a/crates/openhuman-core/src/agent/session_host/turn_checkpoint.rs b/crates/openhuman-core/src/agent/session_host/turn_checkpoint.rs
index 1523d5d67d..3d33e2a080 100644
--- a/crates/openhuman-core/src/agent/session_host/turn_checkpoint.rs
+++ b/crates/openhuman-core/src/agent/session_host/turn_checkpoint.rs
@@ -508,26 +508,12 @@ pub(crate) fn close_verification_prompt(user_request: &str, records: &str, reply
pub(crate) fn build_deterministic_final_summary(
results: &[CheckpointToolResult],
stop_reason: Option<&str>,
-) -> String {
- build_deterministic_final_summary_with_cause(results, stop_reason, None)
-}
-
-/// Build the deterministic final summary using a typed breaker cause when
-/// available. The note remains a legacy fallback for persisted untyped stops.
-pub(crate) fn build_deterministic_final_summary_with_cause(
- results: &[CheckpointToolResult],
- stop_reason: Option<&str>,
- failure_cause: Option<&tinyagents_harness::no_progress::ClassifiedStopCause>,
) -> String {
if results.is_empty() && stop_reason.is_none() {
return "I finished this turn but produced no result to report.".to_string();
}
if let Some(reason) = stop_reason {
- return super::stop_summary::render_stop_summary_with_cause(
- results,
- reason,
- failure_cause,
- );
+ return super::stop_summary::render_stop_summary(results, reason);
}
let mut out = String::from(
"I finished this turn without writing up a result. Here is what each tool call returned:\n",