Skip to content

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

fix(web_chat): handle missing runner without early return

Steven Enamakel9130ec03d1bf
diff --git a/crates/openhuman-core/src/web_chat/ingress.rs b/crates/openhuman-core/src/web_chat/ingress.rs
index a783511a20..00d46c594b 100644
--- a/crates/openhuman-core/src/web_chat/ingress.rs
+++ b/crates/openhuman-core/src/web_chat/ingress.rs
@@ -242,13 +242,14 @@ impl WebIngress {
ctx,
&request.thread_id,
);
- let Some(runner) = self.runner.get().and_then(Weak::upgrade) else {
- return;
+ let in_flight = match self.runner.get().and_then(Weak::upgrade) {
+ Some(runner) => {
+ runner
+ .in_flight_request_id(&scope_of(ctx), &request.thread_id)
+ .await
+ }
+ None => None,
};
- let scope = scope_of(ctx);
- let in_flight = runner
- .in_flight_request_id(&scope, &request.thread_id)
- .await;
if request.disposition == QueueDisposition::Interrupt {
if let Some(cancelled) = in_flight.clone() {
log::info!(
diff --git a/crates/openhuman-core/src/web_chat/ingress_tests.rs b/crates/openhuman-core/src/web_chat/ingress_tests.rs
index 6a20b22c4d..9dbceb8a64 100644
--- a/crates/openhuman-core/src/web_chat/ingress_tests.rs
+++ b/crates/openhuman-core/src/web_chat/ingress_tests.rs
@@ -60,10 +60,16 @@ async fn the_guardrail_refuses_an_override_attempt_and_tells_the_submitter() {
.apply(IngressStage::Guardrail, &mut req)
.await
.expect("a verdict");
- assert!(matches!(decision, IngressDecision::Reject(_)), "{decision:?}");
+ assert!(
+ matches!(decision, IngressDecision::Reject(_)),
+ "{decision:?}"
+ );
match rx.await.expect("answered") {
Admission::Rejected(StartChatError::Guardrail { verdict, .. }) => {
- assert!(verdict == "block" || verdict == "review_blocked", "{verdict}");
+ assert!(
+ verdict == "block" || verdict == "review_blocked",
+ "{verdict}"
+ );
}
other => panic!("expected a guardrail refusal, got {other:?}"),
}
@@ -72,7 +78,11 @@ async fn the_guardrail_refuses_an_override_attempt_and_tells_the_submitter() {
#[tokio::test]
async fn the_guardrail_lets_an_ordinary_message_through_silently() {
let (policy, shared, mut rx) = policy_with_admission("ingress-ok");
- let mut req = request("ingress-ok", "what is the weather", QueueDisposition::Interrupt);
+ let mut req = request(
+ "ingress-ok",
+ "what is the weather",
+ QueueDisposition::Interrupt,
+ );
for stage in [IngressStage::Guardrail, IngressStage::ApprovalInterception] {
assert_eq!(
policy.apply(stage, &mut req).await.expect("a verdict"),
@@ -86,7 +96,11 @@ async fn the_guardrail_lets_an_ordinary_message_through_silently() {
#[tokio::test]
async fn text_without_upload_markers_is_not_staged() {
let (policy, _shared, _rx) = policy_with_admission("ingress-plain");
- let mut req = request("ingress-plain", "no files here", QueueDisposition::Interrupt);
+ let mut req = request(
+ "ingress-plain",
+ "no files here",
+ QueueDisposition::Interrupt,
+ );
assert_eq!(
policy
.apply(IngressStage::StageAttachments, &mut req)
@@ -110,7 +124,10 @@ async fn an_upload_that_cannot_be_saved_refuses_the_message() {
.apply(IngressStage::StageAttachments, &mut req)
.await
.expect("a verdict");
- assert!(matches!(decision, IngressDecision::Reject(_)), "{decision:?}");
+ assert!(
+ matches!(decision, IngressDecision::Reject(_)),
+ "{decision:?}"
+ );
assert!(matches!(
rx.await.expect("answered"),
Admission::Rejected(StartChatError::Other(message)) if message.contains("upload")
diff --git a/tests/agent_harness_e2e.rs b/tests/agent_harness_e2e.rs
index 641b2f37ad..b6710b1760 100644
--- a/tests/agent_harness_e2e.rs
+++ b/tests/agent_harness_e2e.rs
@@ -2646,12 +2646,12 @@ mod streaming_support {
/// 5. Final answer is "stream final".
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn streaming_tool_call_accumulation() {
- use tinyagents_harness::progress::AgentProgress;
use std::sync::Mutex;
use streaming_support::{
agent_with_s, native_tool_response_s, text_response_s, workspace_s, EchoTool,
ScriptedProvider,
};
+ use tinyagents_harness::progress::AgentProgress;
use tinyinference_llm::model::{ModelProfile, ModelStreamItem};
use tinyinference_llm::tool::ToolDelta;