Skip to content

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

feat(tinyagents): add turn execution drive setup

Steven Enamakelffa29303e246
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_exec/drive/setup.rs b/crates/openhuman-core/src/agent/tinyagents/turn_exec/drive/setup.rs
new file mode 100644
index 0000000000..948245abdf
--- /dev/null
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_exec/drive/setup.rs
@@ -0,0 +1,77 @@
+use super::*;
+
+pub(super) fn run_config(
+ run_context: &mut OpenHumanRunContext,
+ native_subagent: Option<&NativeSubagentRunContext>,
+ is_subagent: bool,
+ observed: bool,
+ max_iterations: usize,
+ max_output_tokens: Option<u32>,
+ model: &str,
+) -> (tinyagents_harness::context::RunConfig, tinyagents_harness::ids::RunId) {
+ let mut config = native_subagent
+ .map(|native| native.config.clone())
+ .unwrap_or_else(|| {
+ run_context.root_run_config(if is_subagent {
+ "openhuman-subagent"
+ } else {
+ "openhuman-agent-turn"
+ })
+ })
+ .with_max_model_calls(max_iterations)
+ .with_max_tool_calls(run_context.tool_call_limit_for(max_iterations))
+ .with_max_depth(super::super::super::budget::depth(run_context))
+ .with_tag("openhuman")
+ .with_tag(if observed { "observed" } else { "unobserved" });
+ // The loop stamps this cap onto every model request; it does not bake into
+ // the primary or routed models.
+ if let Some(cap) = max_output_tokens {
+ config = config.with_max_turn_output_tokens(cap);
+ }
+ let journal_run_id = config.run_id.clone();
+ tracing::info!(
+ model,
+ max_iterations,
+ observed,
+ "[tinyagents] routing turn through the runtime turn driver (shared tools)"
+ );
+ (config, journal_run_id)
+}
+
+#[allow(clippy::too_many_arguments)]
+pub(super) fn event_bridge(
+ sink: &EventSink,
+ on_progress: Option<tokio::sync::mpsc::Sender<crate::progress::AgentProgress>>,
+ model: &str,
+ provider_id: String,
+ max_iterations: usize,
+ subagent_scope: Option<SubagentScope>,
+ cursor: &tinyagents_harness::events::IterationCursor,
+ tool_names: &crate::agent::tinyagents::observability::ToolNameMap,
+ failure_map: &crate::agent::tinyagents::observability::ToolFailureMap,
+ provider_usage_carry: &crate::agent::tinyagents::observability::ProviderUsageCarry,
+ bridge_tool_sets: Vec<Arc<Vec<Box<dyn tinytools::Tool>>>>,
+ run_context: &OpenHumanRunContext,
+) -> Arc<OpenhumanEventBridge> {
+ let bridge = OpenhumanEventBridge::with_scope(
+ on_progress,
+ model,
+ provider_id,
+ max_iterations,
+ subagent_scope,
+ cursor.clone(),
+ tool_names.clone(),
+ failure_map.clone(),
+ provider_usage_carry.clone(),
+ bridge_tool_sets,
+ run_context.dispatch_ctx(),
+ );
+ bridge.set_definition(
+ run_context
+ .memory_identity
+ .as_ref()
+ .and_then(|identity| identity.agent_id.as_deref()),
+ );
+ sink.subscribe(bridge.clone());
+ bridge
+}