Skip to content

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

test(tinyagents): thread context through command exit failure tests

Steven Enamakelde2043c7e6b6
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_command_exit_failure_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_command_exit_failure_tests.rs
index df9409d286..91517db60e 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware_command_exit_failure_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_command_exit_failure_tests.rs
@@ -68,8 +68,10 @@ async fn a_sigpipe_with_401_in_its_output_does_not_halt_the_run() {
let handle = SteeringHandle::allow_all();
let slot = std::sync::Arc::new(std::sync::Mutex::new(None));
let mw = RepeatedToolFailureMiddleware::new(handle.clone(), 3, slot.clone());
+ let mut context = ctx();
run_shell(
&mw,
+ &mut context,
"log-1",
"git log --oneline | head",
failing_result("shell", &sigpipe_git_log_report()),
@@ -87,6 +89,7 @@ async fn rerunning_a_failing_test_between_edits_never_halts() {
let handle = SteeringHandle::allow_all();
let slot = std::sync::Arc::new(std::sync::Mutex::new(None));
let mw = RepeatedToolFailureMiddleware::new(handle.clone(), 3, slot.clone());
+ let mut context = ctx();
let report = tinytools::render_command_failure(
Some(1),
"FAILED tests/test_consumer.py::test_priority - TimeoutError: timed out",
@@ -95,6 +98,7 @@ async fn rerunning_a_failing_test_between_edits_never_halts() {
for round in 0..12 {
run_shell(
&mw,
+ &mut context,
&format!("test-{round}"),
"python -m pytest tests/test_consumer.py",
failing_result("shell", &report),
@@ -102,6 +106,7 @@ async fn rerunning_a_failing_test_between_edits_never_halts() {
.await;
run_shell(
&mw,
+ &mut context,
&format!("edit-{round}"),
"sed -i 's/a/b/' kombu/consumer.py",
tool_result("shell", ""),
@@ -119,9 +124,10 @@ async fn an_identical_failing_command_repeated_unchanged_still_halts() {
let handle = SteeringHandle::allow_all();
let slot = std::sync::Arc::new(std::sync::Mutex::new(None));
let mw = RepeatedToolFailureMiddleware::new(handle.clone(), 3, slot.clone());
+ let mut context = ctx();
let report = tinytools::render_command_failure(Some(2), "", "make: *** No rule to make target");
for id in ["make-1", "make-2", "make-3", "make-4"] {
- run_shell(&mw, id, "make build", failing_result("shell", &report)).await;
+ run_shell(&mw, &mut context, id, "make build", failing_result("shell", &report)).await;
}
assert_eq!(drain_pause_count(&handle), 1);
}
@@ -226,6 +232,7 @@ async fn six_different_failing_command_exit_reports_never_feed_the_ladder() {
let handle = SteeringHandle::allow_all();
let slot = std::sync::Arc::new(std::sync::Mutex::new(None));
let mw = RepeatedToolFailureMiddleware::new(handle.clone(), 3, slot.clone());
+ let mut context = ctx();
let attempts = [
(
"pip install fasttext",
@@ -260,6 +267,7 @@ async fn six_different_failing_command_exit_reports_never_feed_the_ladder() {
for (i, (command, report)) in attempts.iter().enumerate() {
run_shell(
&mw,
+ &mut context,
&format!("probe-{i}"),
command,
failing_result("shell", report),
@@ -279,9 +287,11 @@ async fn the_same_failing_command_three_times_still_halts() {
let handle = SteeringHandle::allow_all();
let slot = std::sync::Arc::new(std::sync::Mutex::new(None));
let mw = RepeatedToolFailureMiddleware::new(handle.clone(), 3, slot.clone());
+ let mut context = ctx();
for i in 0..3 {
run_shell(
&mw,
+ &mut context,
&format!("same-{i}"),
"pip install fasttext",
failing_result(
@@ -308,24 +318,26 @@ async fn a_different_command_between_repeats_resets_the_identical_count() {
let handle = SteeringHandle::allow_all();
let slot = std::sync::Arc::new(std::sync::Mutex::new(None));
let mw = RepeatedToolFailureMiddleware::new(handle.clone(), 3, slot.clone());
+ let mut context = ctx();
let same = || failing_result("shell", &exit_report(1, "", "boom"));
- run_shell(&mw, "a-1", "make", same()).await;
- run_shell(&mw, "a-2", "make", same()).await;
+ run_shell(&mw, &mut context, "a-1", "make", same()).await;
+ run_shell(&mw, &mut context, "a-2", "make", same()).await;
run_shell(
&mw,
+ &mut context,
"b-1",
"ls build/",
failing_result("shell", &exit_report(2, "", "No such file")),
)
.await;
- run_shell(&mw, "a-3", "make", same()).await;
- run_shell(&mw, "a-4", "make", same()).await;
+ run_shell(&mw, &mut context, "a-3", "make", same()).await;
+ run_shell(&mw, &mut context, "a-4", "make", same()).await;
assert_eq!(
drain_pause_count(&handle),
0,
"the streak restarted after `ls build/`"
);
- run_shell(&mw, "a-5", "make", same()).await;
+ run_shell(&mw, &mut context, "a-5", "make", same()).await;
assert_eq!(
drain_pause_count(&handle),
1,
diff --git a/vendor/tinyagents b/vendor/tinyagents
index 092332be58..665f190145 160000
--- a/vendor/tinyagents
+++ b/vendor/tinyagents
@@ -1 +1 @@
-Subproject commit 092332be58aaf4d3f8e7acab9250cb98c2e98435
+Subproject commit 665f19014555c47b6e9ef4bfbfc0e055f56f4ef2