Skip to content

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

feat(agent): retry a dead call at the same cap, without reasoning, sticky after two

sanil-234c7d4c092e63
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs b/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs
index a22649a5bb..e675863d9c 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs
@@ -162,6 +162,17 @@ pub(crate) fn run_policy_for_provider_with_backoff(
response_cache_enabled,
overrides: env_overrides(),
});
+ // A call that dies at its output cap with nothing to show is retried at
+ // the same cap, never a doubled one: a model that reasons past the cap
+ // without answering does the same past twice the cap, at twice the cost.
+ policy.truncated_empty_constant_cap = true;
+ // And the call after a dead one goes out without reasoning: a model that
+ // thought to the cap without acting tends to do so again at any cap.
+ policy.truncated_empty_reasoning_off = true;
+ // From the second dead call in a turn on, the rest of the turn runs
+ // without reasoning: one reasoning-off call recovers the step, but the
+ // model thinks to the cap again as soon as reasoning comes back.
+ policy.truncated_empty_reasoning_off_sticky_after = 2;
apply_retry_backoff_override(&mut policy, retry_backoff_ms);
policy
}
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_policy_budget_tests.rs b/crates/openhuman-core/src/agent/tinyagents/turn_policy_budget_tests.rs
index 52270bd360..24784a92e0 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_policy_budget_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_policy_budget_tests.rs
@@ -134,3 +134,19 @@ fn retry_backoff_override_shrinks_the_schedule_and_ignores_junk() {
assert_eq!(policy.retry.max_backoff_ms, 200);
assert_eq!(policy.retry.max_attempts, production.max_attempts);
}
+
+#[test]
+fn a_dead_call_is_retried_at_the_same_cap_without_reasoning_sticky_after_two() {
+ for local_provider in [false, true] {
+ let policy = run_policy_for_provider(50, false, local_provider, None);
+ assert!(
+ policy.truncated_empty_constant_cap,
+ "no doubling past the cap"
+ );
+ assert!(
+ policy.truncated_empty_reasoning_off,
+ "the call after a dead one runs without reasoning"
+ );
+ assert_eq!(policy.truncated_empty_reasoning_off_sticky_after, 2);
+ }
+}