Skip to content

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

fix(agent): record fast-path delegations, fix a wrong test ordering, and report parallel-turn errors\n\nReview follow-ups on #5804.\n\n- The deterministic memory fast path returns a completed outcome before the\n recorder, so a turn whose delegations are all fast-path retrievals never\n accumulated a sample and left the budget gate disarmed for its whole life.\n Record there too. Including short samples cannot weaken the gate: the\n statistic is a running maximum, so a small sample leaves it where it was.\n The comment claiming otherwise was wrong about its own statistic.\n\n- `concurrent_same_task_dispatches_share_one_guard` recorded its 60s sample\n before its own `check()`, so the first worker judged itself against a\n duration it had just written and the `Allow` assertion could never hold.\n A worker checks on the way in and records on the way out; the test now\n mirrors that.\n\n- `spawn_parallel_turn`'s error branch reported nothing to Sentry — not only\n the timeouts this change un-suppresses but every error type, for as long as\n the parallel path has existed. Fixing only the serial `start_chat` site\n would have left `QueueMode::Parallel` exactly as blind as before, so it now\n shares the same suppression policy and carries `timeout_bound` plus a\n `queue_mode` tag.\n

M3gA-Mindf889718554fd
diff --git a/src/openhuman/agent/harness/subagent_runner/ops/runner.rs b/src/openhuman/agent/harness/subagent_runner/ops/runner.rs
index f7f0e41c17..4a0e626b35 100644
--- a/src/openhuman/agent/harness/subagent_runner/ops/runner.rs
+++ b/src/openhuman/agent/harness/subagent_runner/ops/runner.rs
@@ -489,6 +489,19 @@ pub async fn run_subagent(
)
.await
{
+ // The fast path completes a real delegation and returns here,
+ // short-circuiting the recorder below — so record it too, or a
+ // turn whose only delegations are deterministic memory
+ // retrievals never accumulates a sample and the budget gate
+ // stays disarmed for the whole turn (#5804 review).
+ //
+ // Including it cannot weaken the gate. `observed_max` is a
+ // running **maximum**, so a short sample can only leave it
+ // where it was — an earlier revision of this comment claimed
+ // the opposite and was wrong about its own statistic. What it
+ // does buy is a correct `observed_samples` count and a gate
+ // that arms on a turn shaped entirely from fast-path work.
+ turn_dispatch_guard::record_subagent_elapsed(started.elapsed());
return Ok(outcome);
}
}
@@ -553,7 +566,8 @@ pub async fn run_subagent(
// Feed this delegation's wall-clock into the turn's running maximum,
// which is the only thing the budget gate above judges a later
- // dispatch against (#5804).
+ // dispatch against (#5804). The deterministic fast path above records
+ // separately and returns, so it cannot reach here twice.
//
// Recorded on BOTH the success and the failure path, and before the
// `?`: a delegation that ran for three minutes and then errored spent
diff --git a/src/openhuman/agent/harness/turn_dispatch_guard_tests.rs b/src/openhuman/agent/harness/turn_dispatch_guard_tests.rs
index 3dbfbfe075..a40beae5f8 100644
--- a/src/openhuman/agent/harness/turn_dispatch_guard_tests.rs
+++ b/src/openhuman/agent/harness/turn_dispatch_guard_tests.rs
@@ -263,9 +263,15 @@ async fn concurrent_same_task_dispatches_share_one_guard() {
// this pins the consequence: concurrency does not bypass the gate, and the
// sample one worker records is visible to the next worker's check.
with_dispatch_guard(Some(Duration::from_millis(50)), async {
+ // Order matters, and getting it wrong here is what an earlier revision
+ // of this test did: it recorded the 60s sample *before* its own
+ // `check()`, so the first worker judged itself against a duration it
+ // had just written and the `Allow` assertion could never hold. A worker
+ // checks on the way in and records on the way out — mirror that.
let a = async {
+ let decision = check();
record_subagent_elapsed(Duration::from_secs(60));
- check()
+ decision
};
let b = async {
tokio::time::sleep(Duration::from_millis(60)).await;
diff --git a/src/openhuman/web_chat/ops.rs b/src/openhuman/web_chat/ops.rs
index 13c50a725d..ff3ea18e91 100644
--- a/src/openhuman/web_chat/ops.rs
+++ b/src/openhuman/web_chat/ops.rs
@@ -1032,7 +1032,54 @@ async fn spawn_parallel_turn(
request_id_task,
err
);
+ let detailed = format!(
+ "parallel run_chat_task failed client_id={} thread_id={} request_id={} error={}",
+ client_id_task, thread_id_task, request_id_task, err
+ );
let classified = classify_inference_error(&err);
+ let classified_type = classified.error_type;
+
+ // A parallel turn runs under the same deadline wrapper as the
+ // serial one and dies the same way, but this branch reported
+ // NOTHING to Sentry — not merely the timeouts this PR
+ // un-suppresses, but every error type, since the parallel path
+ // was added. So a discarded turn was invisible here even
+ // before the suppression arm existed, and fixing only
+ // `start_chat` would have left `QueueMode::Parallel` exactly
+ // as blind as it was (#5804 review).
+ //
+ // Same policy as the serial site, deliberately sharing
+ // `sentry_suppression_reason` rather than restating it: the
+ // outer backstop stays suppressed, a harness `Timeout` reports
+ // with the ceiling that fired.
+ if let Some(reason) = sentry_suppression_reason(&detailed) {
+ log::info!(
+ target: "web_channel",
+ "[web_channel.spawn_parallel_turn] suppressed Sentry emission for {} \
+ client_id={} thread_id={} request_id={} error_type={} message={}",
+ reason,
+ client_id_task,
+ thread_id_task,
+ request_id_task,
+ classified_type,
+ detailed
+ );
+ } else {
+ crate::core::observability::report_error_or_expected(
+ detailed.as_str(),
+ "web_channel",
+ "spawn_parallel_turn",
+ &[
+ ("channel", "web"),
+ ("error_type", classified_type),
+ ("thread_id", thread_id_task.as_str()),
+ ("request_id", request_id_task.as_str()),
+ ("queue_mode", "parallel"),
+ ("timeout_bound", timeout_bound_tag(&detailed)),
+ ],
+ );
+ }
+
publish_web_channel_event(WebChannelEvent {
event: "chat_error".to_string(),
client_id: client_id_task.clone(),