Skip to content

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

refactor(agent): drop redundant boxing in turn execution

Steven Enamakel6f7d19420b19
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_continuation_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_continuation_tests.rs
index 0f1389bdfd..c5135023f9 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_continuation_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_continuation_tests.rs
@@ -26,19 +26,20 @@ async fn continue_subagent_resumes_paused_job_through_shared_driver() {
.insert("ask_user_clarification".into());
let live =
crate::agent::orchestration::tools::live_parent_run_context("continue-paused-e2e", parent);
- let paused = Box::pin(SpawnSubagentTool::new().execute_with_live_parent_context(
- json!({
- "agent_id": "task_manager_agent",
- "prompt": "Investigate the pause-resume fixture",
- "model": "test-model",
- "blocking": true
- }),
- None,
- live.data.child(),
- Some(&live),
- ))
- .await
- .expect("initial spawn");
+ let paused = SpawnSubagentTool::new()
+ .execute_with_live_parent_context(
+ json!({
+ "agent_id": "task_manager_agent",
+ "prompt": "Investigate the pause-resume fixture",
+ "model": "test-model",
+ "blocking": true
+ }),
+ None,
+ live.data.child(),
+ Some(&live),
+ )
+ .await
+ .expect("initial spawn");
assert!(!paused.is_error, "{}", paused.output());
assert_eq!(provider.calls.load(std::sync::atomic::Ordering::SeqCst), 1);
let task_id = paused
@@ -62,8 +63,8 @@ async fn continue_subagent_resumes_paused_job_through_shared_driver() {
.expect("initial pause is registered in shared Jobs");
assert_eq!(paused_job.status, SubAgentJobStatus::AwaitingInput);
- let resumed = Box::pin(
- ContinueSubagentTool::new().execute_with_live_parent_context(
+ let resumed = ContinueSubagentTool::new()
+ .execute_with_live_parent_context(
json!({
"task_id": task_id,
"agent_id": "task_manager_agent",
@@ -72,10 +73,9 @@ async fn continue_subagent_resumes_paused_job_through_shared_driver() {
None,
live.data.child(),
Some(&live),
- ),
- )
- .await
- .expect("continue");
+ )
+ .await
+ .expect("continue");
assert!(!resumed.is_error, "{}", resumed.output());
assert!(provider.saw("Inspect the README and continue."));
assert_eq!(provider.calls.load(std::sync::atomic::Ordering::SeqCst), 2);
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
index 52df44cdd5..72ced1691b 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
@@ -338,13 +338,8 @@ async fn drive_turn(
}
// `session_kv_store` self-gates on the dual-write flag (config default ON +
// env kill switch), returning `None` when disabled or unresolvable.
- // Heap-allocate config-loading setup state here: nested delegates poll on
- // their parent's stack even when TurnSpec itself is boxed.
- let dispatch_ctx = run_context.dispatch_ctx();
- if let Some(session_kv) = Box::pin(crate::storage::import::live::session_kv_store(
- &dispatch_ctx,
- ))
- .await
+ if let Some(session_kv) =
+ crate::storage::import::live::session_kv_store(&run_context.dispatch_ctx()).await
{
stores.get_or_insert_with(StoreRegistry::new).register(
crate::storage::import::live::TINYAGENTS_SESSION_KV_STORE,
@@ -524,14 +519,10 @@ async fn drive_turn(
stream: streaming,
controls,
};
- // 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 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)
+ })?;
let steering =
prepared.run_context.steering.clone().ok_or_else(|| {
anyhow::anyhow!("turn driver prepared a run without a steering handle")