Skip to content

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

fix(tinyagents): box the turn driver prepare future

Steven Enamakelac3322f192bf
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
index 251c6fb479..52df44cdd5 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
@@ -524,10 +524,14 @@ async fn drive_turn(
stream: streaming,
controls,
};
- let mut prepared = driver.prepare(request).await.map_err(|failure| {
- tracing::error!(error = %failure.error, "[tinyagents] turn driver could not prepare the turn");
- anyhow::anyhow!("{}", failure.error)
- })?;
+ // Heap-allocate the planning future: nested delegates poll this turn on
+ // their parent's stack even while earlier states await setup work.
+ let mut prepared = Box::pin(driver.prepare(request))
+ .await
+ .map_err(|failure| {
+ tracing::error!(error = %failure.error, "[tinyagents] turn driver could not prepare the turn");
+ anyhow::anyhow!("{}", failure.error)
+ })?;
let steering =
prepared.run_context.steering.clone().ok_or_else(|| {
anyhow::anyhow!("turn driver prepared a run without a steering handle")