Skip to content

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

feat(tinyagents): add headless descendant settlement tracking

Steven Enamakel32893fd25cc1
diff --git a/crates/openhuman-cli/Cargo.toml b/crates/openhuman-cli/Cargo.toml
index 1750e44e33..f77cfc6cb3 100644
--- a/crates/openhuman-cli/Cargo.toml
+++ b/crates/openhuman-cli/Cargo.toml
@@ -217,6 +217,10 @@ path = "../../tests/cli_model_overrides_e2e.rs"
name = "cli_sigpipe"
path = "../../tests/cli_sigpipe.rs"
+[[test]]
+name = "cli_agent_chat_headless_e2e"
+path = "../../tests/cli_agent_chat_headless_e2e.rs"
+
[[test]]
name = "cli_storage_url_e2e"
path = "../../tests/cli_storage_url_e2e.rs"
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
index 173ae7e7d4..44a7fc758c 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
@@ -643,6 +643,7 @@ impl OpenHumanRunContext {
child.subagent_usage = Arc::new(Mutex::new(Vec::new()));
child.parent_subagent_usage = None;
child.cancellation = tinyagents_harness::cancel::CancellationToken::new();
+ child.headless_descendant_settlement = false;
child
}
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/run_context_tests.rs b/crates/openhuman-core/src/agent/tinyagents/host/run_context_tests.rs
index b6544c9365..328965b3d5 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context_tests.rs
@@ -97,6 +97,7 @@ fn child_inherits_tree_handles_but_isolates_observations_and_usage() {
let mut parent = OpenHumanRunContext::new();
parent.thread_id = Some("thread-a".to_string());
parent.file_state_agent_id = Some("parent-file-state".to_string());
+ parent.headless_descendant_settlement = true;
*parent.resolved_route.lock().expect("route lock") =
Some(tinyinference_llm::model::ResolvedModelRoute {
provider: "provider-a".to_string(),
@@ -107,6 +108,7 @@ fn child_inherits_tree_handles_but_isolates_observations_and_usage() {
let child = parent.child();
assert_eq!(child.spawn_depth, 1);
+ assert!(child.headless_descendant_settlement);
assert_eq!(child.thread_id.as_deref(), Some("thread-a"));
assert!(child.file_state_agent_id().is_none());
assert!(child
@@ -209,12 +211,17 @@ fn failed_outer_run_promotes_completed_nested_usage_once() {
fn detached_children_reset_turn_accounting_and_cancellation() {
let mut root = OpenHumanRunContext::new();
root.thread_id = Some("thread-a".into());
+ root.headless_descendant_settlement = true;
let dispatch = Arc::new(TurnDispatchState::new(Some(std::time::Duration::ZERO)));
dispatch.record_subagent_elapsed(std::time::Duration::from_secs(1));
root.dispatch = Some(dispatch);
let detached = root.detached_child();
assert_eq!(detached.thread_id.as_deref(), Some("thread-a"));
+ assert!(
+ !detached.headless_descendant_settlement,
+ "detached work is outside the root's settlement lease"
+ );
assert!(detached.dispatch.is_none());
root.cancellation.cancel();
assert!(!detached.cancellation.is_cancelled());