Skip to content

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

chore(agent): remove concurrent turn diagnostic instrumentation

Steven Enamakelff75b98172f4
diff --git a/crates/openhuman-core/src/agent/session_host/driver.rs b/crates/openhuman-core/src/agent/session_host/driver.rs
index 0f3c579fab..7c26dc6dbb 100644
--- a/crates/openhuman-core/src/agent/session_host/driver.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver.rs
@@ -84,7 +84,6 @@ impl SessionDriver<OpenHumanRunContext> for OpenHumanSessionDriver {
&self,
mut request: DriverRequest<OpenHumanRunContext>,
) -> Result<DriverOutcome, DriverFailure> {
- super::runtime_session::concurrent_turn_diagnostic(4);
// Heal an orphaned tool head before reading history.
repair_orphaned_tool_head(&mut request.history);
// Use the policy and context prepared for this exact request.
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
index 5cd7bc7579..dfc3ffaadd 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -37,16 +37,6 @@ use tinyagents_runtime::{
};
use tinyinference_llm::message::Message;
-pub(super) fn concurrent_turn_diagnostic(stage: usize) {
- if std::env::var_os("OH_DIAG_CONCURRENT").is_none() {
- return;
- }
- static COUNTS: [std::sync::atomic::AtomicUsize; 14] =
- [const { std::sync::atomic::AtomicUsize::new(0) }; 14];
- let count = COUNTS[stage].fetch_add(1, std::sync::atomic::Ordering::Relaxed) + 1;
- eprintln!("OpenHuman concurrent diagnostic stage={stage} count={count}");
-}
-
use super::types::OpenHumanSessionHost;
use crate::agent::{
message_convert::{user_message_from_text, user_text_with_markers},
@@ -352,7 +342,6 @@ impl OpenHumanSessionHost {
let resume_target = resume_target.clone();
let state = self.runtime_state.clone();
move |_, options, _| {
- concurrent_turn_diagnostic(0);
let resume_target = resume_target.clone();
begin_turn_resume(
&mut state
@@ -370,7 +359,6 @@ impl OpenHumanSessionHost {
{
let state = self.runtime_state.clone();
move |request, options, view| {
- concurrent_turn_diagnostic(1);
let state = state.clone();
let request_base_len = view.history.len()
+ usize::from(view.history.last() != Some(&request.input));
@@ -398,20 +386,17 @@ impl OpenHumanSessionHost {
// its completion; settle it before this turn reads the goal.
post_commit::await_pending(pending_post_commit).await;
let new_session = !view.resumed && view.history.is_empty();
- concurrent_turn_diagnostic(2);
prelude
.refresh_turn_boundary(new_session)
.await
.map_err(|error| {
tinyagents_runtime::RuntimeError::Driver(error.to_string())
})?;
- concurrent_turn_diagnostic(3);
let context_window = prelude
.turn_model_source
.effective_context_window(&prelude.model_name)
.await
.unwrap_or_default();
- concurrent_turn_diagnostic(5);
options
.run_context
.data
@@ -427,41 +412,27 @@ impl OpenHumanSessionHost {
.take_turn_inputs();
let origin = options.run_context.data.origin.clone();
let (enriched, memory_turn) = futures::join!(
- async {
- let value = prelude
- .enrich_request(
- &original_user_message,
- &turn,
- &mut options.run_context.data,
- )
- .await;
- concurrent_turn_diagnostic(9);
- value
- },
+ prelude.enrich_request(
+ &original_user_message,
+ &turn,
+ &mut options.run_context.data,
+ ),
// Boxed: the hook's future (config load, engine
// calls) would otherwise be inlined into this
// already-large hook future.
- Box::pin(async {
- let value = prelude
- .memory_pre_turn(
- view.history,
- view.committed_turns,
- view.history.last().filter(|last| **last == request.input),
- origin,
- )
- .await;
- concurrent_turn_diagnostic(10);
- value
- }),
+ Box::pin(prelude.memory_pre_turn(
+ view.history,
+ view.committed_turns,
+ view.history.last().filter(|last| **last == request.input),
+ origin,
+ )),
);
- concurrent_turn_diagnostic(6);
options.run_context.data.memory_turn = memory_turn;
request.input = user_message_from_text(&enriched);
let mut preparation =
prelude.prepare(new_session).await.map_err(|error| {
tinyagents_runtime::RuntimeError::Driver(error.to_string())
})?;
- concurrent_turn_diagnostic(7);
prelude.refresh_permanent_prefix(&mut preparation, view.prefix);
if turn.overrides.suppress_tools {
// One-off tool-less turn: must not become the
@@ -511,7 +482,6 @@ impl OpenHumanSessionHost {
.unwrap_or_else(|poisoned| poisoned.into_inner())
.required_output
.clone();
- concurrent_turn_diagnostic(8);
Ok(preparation)
})
}
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/prelude.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/prelude.rs
index f52d3444fb..6085b859b4 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session/prelude.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/prelude.rs
@@ -232,10 +232,7 @@ impl OpenHumanTurnPrelude {
None
} else if let Some(thread_id) = self.thread_id.as_deref() {
let store = crate::agent::goals::goal_store(&self.workspace_dir, &self.dispatch_ctx());
- super::concurrent_turn_diagnostic(11);
- let result = store.prepare_turn(thread_id).await;
- super::concurrent_turn_diagnostic(12);
- match result {
+ match store.prepare_turn(thread_id).await {
Ok(preparation) => {
if let Some(block) = preparation.context_block {
context.push_str(&block);
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
index 614d74b219..d045a5fb8a 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
@@ -10,16 +10,6 @@
use std::collections::{BTreeSet, HashSet};
use std::sync::Arc;
-fn concurrent_turn_diagnostic(stage: usize) {
- if std::env::var_os("OH_DIAG_CONCURRENT").is_none() {
- return;
- }
- static COUNTS: [std::sync::atomic::AtomicUsize; 4] =
- [const { std::sync::atomic::AtomicUsize::new(0) }; 4];
- let count = COUNTS[stage].fetch_add(1, std::sync::atomic::Ordering::Relaxed) + 1;
- eprintln!("turn_exec concurrent diagnostic stage={stage} count={count}");
-}
-
use anyhow::Result;
use tinyagents_harness::runtime::{AgentInvocation, AgentTurnRequest, InvocationRuntime};
use tinyagents_harness::store::{InMemoryStore as ToolResultArtifactIndexStore, StoreRegistry};
@@ -149,7 +139,6 @@ async fn drive_turn(
)>,
native_subagent: Option<NativeSubagentRunContext>,
) -> Result<TinyagentsTurnOutcome> {
- concurrent_turn_diagnostic(0);
let TurnSpec {
mut run_context,
turn_models,
@@ -536,7 +525,6 @@ async fn drive_turn(
stream: streaming,
controls,
};
- concurrent_turn_diagnostic(1);
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)
@@ -636,7 +624,6 @@ async fn drive_turn(
tools = tool_count,
"[tinyagents] turn harness assembled"
);
- concurrent_turn_diagnostic(2);
// Heap-allocate the harness drive future. It is large (it owns the whole run
// context, middleware stack, and loop state), and a sub-agent turn runs
@@ -645,7 +632,6 @@ async fn drive_turn(
// pointer on the stack at each level.
let resolved_route_slot = run_context.resolved_route.clone();
let (run_result, early_exit) = if let Some((base, agent_id)) = hosted_root {
- concurrent_turn_diagnostic(3);
let tool_sets = hosted_tool_sets.expect("hosted root retained its tool sets");
let mut host_bundle =
crate::agent::tinyagents::host::OpenHumanHostBundleFactory::build_for_invocation(