Skip to content

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

chore: files changed crates/openhuman-core/src/web_chat/channel_event.rs,crates/openhuman-core/src/w

Steven Enamakel4418b69a11fa
diff --git a/crates/openhuman-core/src/web_chat/channel_event.rs b/crates/openhuman-core/src/web_chat/channel_event.rs
index c32ce3d097..7ad69bab53 100644
--- a/crates/openhuman-core/src/web_chat/channel_event.rs
+++ b/crates/openhuman-core/src/web_chat/channel_event.rs
@@ -5,7 +5,7 @@ use tinychannels_bus::web as bus_web;
pub use bus_web::{
ChatSuggestion, GuardrailPayload, GuardrailReason, QueueItemPayload, SubagentProgressDetail,
- SubagentUsagePayload, TurnTimingPayload, TurnUsagePayload, WebChannelEvent,
+ SubagentUsagePayload, TurnTimingPayload, TurnUsagePayload, WebChannelEvent, WebEventContext,
};
pub(crate) fn event_context(
@@ -93,4 +93,3 @@ impl Serialize for ScopedWebEvent {
#[cfg(test)]
#[path = "channel_event_tests.rs"]
mod tests;
-
diff --git a/crates/openhuman-core/src/web_chat/event_bus.rs b/crates/openhuman-core/src/web_chat/event_bus.rs
index a6d092d1ed..2e787db373 100644
--- a/crates/openhuman-core/src/web_chat/event_bus.rs
+++ b/crates/openhuman-core/src/web_chat/event_bus.rs
@@ -5,9 +5,9 @@
use async_trait::async_trait;
use std::sync::{Arc, OnceLock};
+use super::channel_event::event_context;
use crate::core::events::DomainEvent;
use crate::web_chat::WebChannelEvent;
-use super::channel_event::event_context;
use tinybus::EventHandler;
use tinybus::SubscriptionHandle;
diff --git a/crates/openhuman-core/src/web_chat/event_bus_tests.rs b/crates/openhuman-core/src/web_chat/event_bus_tests.rs
index 276561e6ec..a7a45f8b22 100644
--- a/crates/openhuman-core/src/web_chat/event_bus_tests.rs
+++ b/crates/openhuman-core/src/web_chat/event_bus_tests.rs
@@ -488,7 +488,7 @@ async fn approval_surface_drops_approval_decided_without_chat_routing() {
if ev.event == "approval_decided"
&& ev.request_id == "req-decided-no-route" =>
{
- return Some(ev)
+ return Some(ev);
}
Ok(_) => continue,
Err(broadcast::error::RecvError::Lagged(_)) => continue,
diff --git a/crates/openhuman-core/src/web_chat/ingress.rs b/crates/openhuman-core/src/web_chat/ingress.rs
index 00d46c594b..7f1f4c5ced 100644
--- a/crates/openhuman-core/src/web_chat/ingress.rs
+++ b/crates/openhuman-core/src/web_chat/ingress.rs
@@ -14,12 +14,12 @@ use tinyagents_harness::turn_runner::{
};
use super::ops::StartChatError;
-use super::runner::{scope_of, Admission, CancelNote, Shared, WebRunner};
+use super::runner::{Admission, CancelNote, Shared, WebRunner, scope_of};
use crate::agent::queued_turn::QueuedPayload;
use crate::core::events::DomainEvent;
use crate::core::runtime::DispatchCtx;
use crate::security::prompt_injection::{
- enforce_prompt_input, PromptEnforcementAction, PromptEnforcementContext,
+ PromptEnforcementAction, PromptEnforcementContext, enforce_prompt_input,
};
const LOG: &str = "[web-channel]";
diff --git a/crates/openhuman-core/src/web_chat/mod.rs b/crates/openhuman-core/src/web_chat/mod.rs
index 2352925c42..ac7298056b 100644
--- a/crates/openhuman-core/src/web_chat/mod.rs
+++ b/crates/openhuman-core/src/web_chat/mod.rs
@@ -50,15 +50,15 @@ pub(crate) use web_errors::classify_inference_error;
#[cfg(any(test, debug_assertions))]
#[allow(unused_imports)]
pub(crate) use web_errors::{
- generic_inference_error_user_message, is_action_budget_exhausted,
- is_non_retryable_rate_limit_text, retry_after_hint, ClassifiedError,
+ ClassifiedError, generic_inference_error_user_message, is_action_budget_exhausted,
+ is_non_retryable_rate_limit_text, retry_after_hint,
};
// Public API — event bus
pub use channel_event::{
ChatSuggestion, GuardrailPayload, GuardrailReason, QueueItemPayload, ScopedWebEvent,
SubagentProgressDetail, SubagentUsagePayload, TurnTimingPayload, TurnUsagePayload,
- WebChannelEvent,
+ WebChannelEvent, WebEventContext,
};
pub use egress_surface::register_egress_surface_subscriber;
pub use event_bus::{
@@ -85,10 +85,10 @@ pub use ops::parallel_in_flight_entries_for_test;
#[cfg(test)]
pub(crate) use ops::track_parallel_turn_for_test;
pub use ops::{
- cancel_all_turns, cancel_chat_scoped, cancel_should_target, channel_web_cancel,
- channel_web_chat, channel_web_queue_clear, channel_web_queue_remove, channel_web_queue_status,
+ SESSION_CHECKOUT_FAILURE, SYSTEM_CLIENT_ID, StartChatError, cancel_all_turns,
+ cancel_chat_scoped, cancel_should_target, channel_web_cancel, channel_web_chat,
+ channel_web_queue_clear, channel_web_queue_remove, channel_web_queue_status,
in_flight_entries_for_test, invalidate_thread_sessions, run_system_turn_on_thread, start_chat,
- StartChatError, SESSION_CHECKOUT_FAILURE, SYSTEM_CLIENT_ID,
};
pub use types::ChatRequestMetadata;
@@ -133,11 +133,11 @@ pub(crate) use web_errors::{
// Test helpers (debug/test builds only)
#[cfg(any(test, debug_assertions))]
-pub use ops::set_test_forced_run_chat_task_error;
-#[cfg(any(test, debug_assertions))]
pub use ops::RUN_CHAT_TASK_TEST_LOCK;
#[cfg(any(test, debug_assertions))]
-pub use ops::{set_test_park_after_run, set_test_run_chat_task_block, TestRunChatTaskBlock};
+pub use ops::set_test_forced_run_chat_task_error;
+#[cfg(any(test, debug_assertions))]
+pub use ops::{TestRunChatTaskBlock, set_test_park_after_run, set_test_run_chat_task_block};
#[cfg(any(test, debug_assertions))]
#[path = "mod_test_support_tests.rs"]
diff --git a/crates/openhuman-core/src/web_chat/ops.rs b/crates/openhuman-core/src/web_chat/ops.rs
index 8da87704e4..ba64958e08 100644
--- a/crates/openhuman-core/src/web_chat/ops.rs
+++ b/crates/openhuman-core/src/web_chat/ops.rs
@@ -13,8 +13,8 @@ mod system_turn;
mod test_hooks;
pub(super) use budget_correlation::{
- classify_budget_correlation, clear_budget_signal, has_fresh_budget_signal,
- record_budget_signal, BudgetCorrelation,
+ BudgetCorrelation, classify_budget_correlation, clear_budget_signal, has_fresh_budget_signal,
+ record_budget_signal,
};
pub use channel_ops::{
@@ -22,8 +22,8 @@ pub use channel_ops::{
channel_web_queue_clear, channel_web_queue_remove, channel_web_queue_status,
};
-pub use start_chat::{start_chat, StartChatError};
-pub use system_turn::{run_system_turn_on_thread, SESSION_CHECKOUT_FAILURE, SYSTEM_CLIENT_ID};
+pub use start_chat::{StartChatError, start_chat};
+pub use system_turn::{SESSION_CHECKOUT_FAILURE, SYSTEM_CLIENT_ID, run_system_turn_on_thread};
#[cfg(test)]
pub use state::drain_queued_turns_for_test;
@@ -40,13 +40,13 @@ pub(crate) use state::{event_session_id_for, key_for};
pub(crate) use state::{key_in, unscope_in};
pub(super) use state::{tenant_of, thread_sessions};
+#[cfg(any(test, debug_assertions))]
+pub use test_hooks::RUN_CHAT_TASK_TEST_LOCK;
#[cfg(any(test, debug_assertions))]
pub use test_hooks::set_test_forced_run_chat_task_error;
#[cfg(test)]
pub(crate) use test_hooks::track_parallel_turn_for_test;
#[cfg(any(test, debug_assertions))]
-pub use test_hooks::RUN_CHAT_TASK_TEST_LOCK;
-#[cfg(any(test, debug_assertions))]
-pub(super) use test_hooks::{run_test_hooks, test_hooks_active, TEST_PARK_AFTER_RUN};
+pub(super) use test_hooks::{TEST_PARK_AFTER_RUN, run_test_hooks, test_hooks_active};
#[cfg(any(test, debug_assertions))]
-pub use test_hooks::{set_test_park_after_run, set_test_run_chat_task_block, TestRunChatTaskBlock};
+pub use test_hooks::{TestRunChatTaskBlock, set_test_park_after_run, set_test_run_chat_task_block};
diff --git a/crates/openhuman-core/src/web_chat/ops/channel_ops.rs b/crates/openhuman-core/src/web_chat/ops/channel_ops.rs
index bb4e51771b..1cd7481f06 100644
--- a/crates/openhuman-core/src/web_chat/ops/channel_ops.rs
+++ b/crates/openhuman-core/src/web_chat/ops/channel_ops.rs
@@ -3,15 +3,15 @@
//! inspecting/clearing a thread's run queue. The turns and their queues live
//! in the context's turn runner; these are the thin entry points over it.
-use serde_json::{json, Value};
+use serde_json::{Value, json};
-use crate::core::runtime::DispatchCtx;
use crate::core::Outcome;
+use crate::core::runtime::DispatchCtx;
use crate::web_chat::WebChannelEvent;
use crate::web_chat::channel_event::event_context;
use super::super::event_bus::publish_web_channel_event_in;
-use super::super::runner::{runtime, scope_of, CancelNote};
+use super::super::runner::{CancelNote, runtime, scope_of};
use super::super::types::ChatRequestMetadata;
use super::start_chat::start_chat;
@@ -125,7 +125,9 @@ async fn cancel_chat_inner(
if let Some(rid) = request_id {
log::info!(
"[web-channel] ignoring stale cancel request_id={rid} for thread_id={thread_id} — current in-flight is {:?}; newer turn preserved",
- live.iter().find(|turn| !turn.parallel).map(|turn| turn.request_id.as_str())
+ live.iter()
+ .find(|turn| !turn.parallel)
+ .map(|turn| turn.request_id.as_str())
);
}
}
diff --git a/crates/openhuman-core/src/web_chat/ops/start_chat.rs b/crates/openhuman-core/src/web_chat/ops/start_chat.rs
index 6144b87c1c..3301857b74 100644
--- a/crates/openhuman-core/src/web_chat/ops/start_chat.rs
+++ b/crates/openhuman-core/src/web_chat/ops/start_chat.rs
@@ -14,7 +14,7 @@ use tinyagents_harness::turn_runner::{QueueDisposition, TurnRequest, TurnRunnerE
use tinychannels_bus::web::{ChatRequestMetadata, QueueMode};
use uuid::Uuid;
-use super::super::runner::{runtime, scope_of, Admission};
+use super::super::runner::{Admission, runtime, scope_of};
use super::super::turn_activity::configured_idle_window;
use crate::agent::queued_turn::QueuedPayload;
use crate::core::events::DomainEvent;
diff --git a/crates/openhuman-core/src/web_chat/ops/state_tests.rs b/crates/openhuman-core/src/web_chat/ops/state_tests.rs
index d7238292f5..dbbdd48563 100644
--- a/crates/openhuman-core/src/web_chat/ops/state_tests.rs
+++ b/crates/openhuman-core/src/web_chat/ops/state_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use crate::core::runtime::{context::CoreContext, ContextOverlay, DomainSet};
+use crate::core::runtime::{ContextOverlay, DomainSet, context::CoreContext};
use crate::tools::toolpacks::ToolGroups;
use crate::web_chat::runner::runtime;
use crate::web_chat::track_parallel_turn_for_test;
diff --git a/crates/openhuman-core/src/web_chat/ops/system_turn.rs b/crates/openhuman-core/src/web_chat/ops/system_turn.rs
index 018c53e7e4..38fc38a3ef 100644
--- a/crates/openhuman-core/src/web_chat/ops/system_turn.rs
+++ b/crates/openhuman-core/src/web_chat/ops/system_turn.rs
@@ -17,10 +17,10 @@
use std::sync::Arc;
use tinyagents_harness::run_queue::RunQueue;
-use crate::agent::turn_origin::{with_origin, AgentTurnOrigin};
+use crate::agent::turn_origin::{AgentTurnOrigin, with_origin};
use super::super::session::{
- checkin_session_agent_if_vacant, checkout_session_agent, CheckedOutSession, CheckoutPolicy,
+ CheckedOutSession, CheckoutPolicy, checkin_session_agent_if_vacant, checkout_session_agent,
};
/// Client id stamped on host-authored turns. Never a real socket, so it never
diff --git a/crates/openhuman-core/src/web_chat/ops_budget_correlation_tests_tests.rs b/crates/openhuman-core/src/web_chat/ops_budget_correlation_tests_tests.rs
index a30d23f863..4ba960a45e 100644
--- a/crates/openhuman-core/src/web_chat/ops_budget_correlation_tests_tests.rs
+++ b/crates/openhuman-core/src/web_chat/ops_budget_correlation_tests_tests.rs
@@ -126,7 +126,7 @@ async fn record_prunes_other_threads_stale_entries() {
#[tokio::test]
async fn budget_signals_stay_with_the_agent_that_recorded_them() {
- use crate::core::runtime::{context::CoreContext, ContextOverlay, DomainSet};
+ use crate::core::runtime::{ContextOverlay, DomainSet, context::CoreContext};
let root = CoreContext::for_test(DomainSet::full(), None);
let agent = |id: &str| {
root.derive_with(
diff --git a/crates/openhuman-core/src/web_chat/proactive.rs b/crates/openhuman-core/src/web_chat/proactive.rs
index e6a1b6296b..688021ddcf 100644
--- a/crates/openhuman-core/src/web_chat/proactive.rs
+++ b/crates/openhuman-core/src/web_chat/proactive.rs
@@ -6,8 +6,8 @@
use crate::core::events::DomainEvent;
use crate::core::runtime::DispatchCtx;
-use crate::web_chat::{publish_web_channel_event_in, WebChannelEvent};
use crate::web_chat::channel_event::event_context;
+use crate::web_chat::{WebChannelEvent, publish_web_channel_event_in};
use async_trait::async_trait;
use std::sync::Arc;
use tinybus::EventHandler;
diff --git a/crates/openhuman-core/src/web_chat/progress_map_tests.rs b/crates/openhuman-core/src/web_chat/progress_map_tests.rs
index 5a88a92257..5ad986f0d7 100644
--- a/crates/openhuman-core/src/web_chat/progress_map_tests.rs
+++ b/crates/openhuman-core/src/web_chat/progress_map_tests.rs
@@ -90,10 +90,12 @@ fn a_finished_tool_call_caps_output_and_arguments_and_names_its_failure() {
panic!("tool result")
};
assert!(output.len() <= MAX_WEB_TOOL_PAYLOAD_BYTES && output.contains("truncated"));
- assert!(arguments
- .expect("arguments")
- .as_str()
- .is_some_and(|marker| marker.contains("truncated")));
+ assert!(
+ arguments
+ .expect("arguments")
+ .as_str()
+ .is_some_and(|marker| marker.contains("truncated"))
+ );
let summary = summary.expect("failure summary");
assert_eq!(summary.cause_plain, failure.cause_plain);
assert_eq!(summary.recoverable, failure.recoverable);
@@ -298,9 +300,11 @@ fn subagent_tool_calls_carry_their_arguments_and_capped_results() {
.expect("a completed sub-agent call"),
);
assert_eq!(completed.state, "tool_result");
- assert!(completed
- .output
- .is_some_and(|out| out.contains("truncated")));
+ assert!(
+ completed
+ .output
+ .is_some_and(|out| out.contains("truncated"))
+ );
assert_eq!(completed.structured, Some(json!({ "kind": "web_search" })));
assert!(sub_tool_completed(AgentProgress::TurnStarted).is_none());
}
diff --git a/crates/openhuman-core/src/web_chat/reply_persistence.rs b/crates/openhuman-core/src/web_chat/reply_persistence.rs
index 5d48eeacf8..f5886fbfb8 100644
--- a/crates/openhuman-core/src/web_chat/reply_persistence.rs
+++ b/crates/openhuman-core/src/web_chat/reply_persistence.rs
@@ -24,7 +24,7 @@ use std::path::Path;
use serde_json::json;
use crate::memory::types::TurnCitation;
-use crate::threads::store::{self as conversations, run_reply_message_id, ConversationMessage};
+use crate::threads::store::{self as conversations, ConversationMessage, run_reply_message_id};
/// Metadata scope stamped on a reply persisted by the web-channel delivery path.
///
diff --git a/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs b/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs
index e236379367..615ec2baba 100644
--- a/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs
+++ b/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs
@@ -111,13 +111,15 @@ fn an_empty_reply_is_not_stored() {
)
.expect("no error");
assert!(!stored, "an empty reply reports that nothing was stored");
- assert!(conversations::get_messages(
- &crate::core::runtime::DispatchCtx::ambient(),
- ws.clone(),
- "t-3"
- )
- .expect("messages")
- .is_empty());
+ assert!(
+ conversations::get_messages(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ ws.clone(),
+ "t-3"
+ )
+ .expect("messages")
+ .is_empty()
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/web_chat/runner.rs b/crates/openhuman-core/src/web_chat/runner.rs
index 4118e24ebe..56186676fc 100644
--- a/crates/openhuman-core/src/web_chat/runner.rs
+++ b/crates/openhuman-core/src/web_chat/runner.rs
@@ -17,7 +17,7 @@ use std::sync::{Arc, Mutex, MutexGuard};
use std::time::Duration;
use tinyagents_harness::turn_runner::{ScopeKey, TurnRunner, TurnRunnerConfig};
-use tokio::sync::{oneshot, Mutex as AsyncMutex};
+use tokio::sync::{Mutex as AsyncMutex, oneshot};
use super::ingress::WebIngress;
use super::ops::StartChatError;
diff --git a/crates/openhuman-core/src/web_chat/schemas.rs b/crates/openhuman-core/src/web_chat/schemas.rs
index 7f1db439e3..ae534b453d 100644
--- a/crates/openhuman-core/src/web_chat/schemas.rs
+++ b/crates/openhuman-core/src/web_chat/schemas.rs
@@ -5,8 +5,8 @@
use crate::core::runtime::DispatchCtx;
use serde_json::{Map, Value};
-use crate::core::all::{ControllerFuture, RegisteredController};
use crate::core::Outcome;
+use crate::core::all::{ControllerFuture, RegisteredController};
use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
use super::ops::{
@@ -152,17 +152,17 @@ pub fn schemas(function: &str) -> ControllerSchema {
required_string("thread_id", "Thread identifier."),
required_string("item_id", "Id of the queued item to remove."),
],
- outputs: vec![json_output(
- "result",
- "{ thread_id, item_id, removed }.",
- )],
+ outputs: vec![json_output("result", "{ thread_id, item_id, removed }.")],
},
"voice_note_store" => ControllerSchema {
namespace: "channel",
function: "web_voice_note_store",
description: "Store the audio of a voice note the user recorded, so the thread row can point at it.",
inputs: vec![
- required_string("note_id", "Caller-chosen id (letters, digits, '-', '_'); storing the same id again replaces the audio."),
+ required_string(
+ "note_id",
+ "Caller-chosen id (letters, digits, '-', '_'); storing the same id again replaces the audio.",
+ ),
required_string("audio_base64", "Base64 of the recorded audio."),
optional_string("mime", "Audio mime type (default audio/webm)."),
],
@@ -172,8 +172,14 @@ pub fn schemas(function: &str) -> ControllerSchema {
namespace: "channel",
function: "web_voice_note_read",
description: "Read the audio of a stored voice note (user recording or spoken assistant reply).",
- inputs: vec![required_string("note_id", "Voice note id from the message metadata.")],
- outputs: vec![json_output("result", "{ note_id, mime, audio_base64 }; audio_base64 is null when no audio exists.")],
+ inputs: vec![required_string(
+ "note_id",
+ "Voice note id from the message metadata.",
+ )],
+ outputs: vec![json_output(
+ "result",
+ "{ note_id, mime, audio_base64 }; audio_base64 is null when no audio exists.",
+ )],
},
_ => ControllerSchema {
namespace: "channel",
diff --git a/crates/openhuman-core/src/web_chat/session_checkout_tests.rs b/crates/openhuman-core/src/web_chat/session_checkout_tests.rs
index cc38a08422..06ddcabc10 100644
--- a/crates/openhuman-core/src/web_chat/session_checkout_tests.rs
+++ b/crates/openhuman-core/src/web_chat/session_checkout_tests.rs
@@ -11,8 +11,8 @@ use std::path::Path;
use tinyagents_session::transcript::TranscriptMeta;
use super::{
- checkin_session_agent, checkin_session_agent_if_vacant, checkout_session_agent,
- fingerprint_diff, CheckedOutSession, CheckoutPolicy,
+ CheckedOutSession, CheckoutPolicy, checkin_session_agent, checkin_session_agent_if_vacant,
+ checkout_session_agent, fingerprint_diff,
};
use crate::agent::OpenHumanSessionHost;
use crate::config::Config;
diff --git a/crates/openhuman-core/src/web_chat/session_routing_tests.rs b/crates/openhuman-core/src/web_chat/session_routing_tests.rs
index 379fd13dcc..8addceac04 100644
--- a/crates/openhuman-core/src/web_chat/session_routing_tests.rs
+++ b/crates/openhuman-core/src/web_chat/session_routing_tests.rs
@@ -345,9 +345,11 @@ fn persisted_managed_model_changes_invalidate_the_session_fingerprint() {
first, second,
"the old cached agent must not survive a saved model change"
);
- assert!(super::fingerprint_diff(&first, &second)
- .iter()
- .any(|field| field.starts_with("effective_model:")));
+ assert!(
+ super::fingerprint_diff(&first, &second)
+ .iter()
+ .any(|field| field.starts_with("effective_model:"))
+ );
config.default_model = None;
assert_ne!(
second,
diff --git a/crates/openhuman-core/src/web_chat/suggestions.rs b/crates/openhuman-core/src/web_chat/suggestions.rs
index 0aae420715..314ff25ad2 100644
--- a/crates/openhuman-core/src/web_chat/suggestions.rs
+++ b/crates/openhuman-core/src/web_chat/suggestions.rs
@@ -35,8 +35,8 @@ use tinyinference_llm::message::Message;
use tinyinference_llm::model::ModelRequest;
use crate::inference::provider;
-use crate::web_chat::{ChatSuggestion, WebChannelEvent};
use crate::web_chat::channel_event::event_context;
+use crate::web_chat::{ChatSuggestion, WebChannelEvent};
use super::publish_web_channel_event_in;
diff --git a/crates/openhuman-core/src/web_chat/suggestions_tests.rs b/crates/openhuman-core/src/web_chat/suggestions_tests.rs
index 55d55e23bf..191c1d2bb0 100644
--- a/crates/openhuman-core/src/web_chat/suggestions_tests.rs
+++ b/crates/openhuman-core/src/web_chat/suggestions_tests.rs
@@ -1,5 +1,5 @@
-use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
+use std::sync::atomic::{AtomicUsize, Ordering};
use async_trait::async_trait;
use tinyinference_llm::model::{ChatModel, ModelRequest, ModelResponse};
@@ -104,7 +104,7 @@ async fn drain_suggestions_event(
loop {
match tokio::time::timeout(Duration::from_secs(2), rx.recv()).await {
Ok(Ok(ev)) if ev.event == "chat_suggestions" && ev.thread_id == thread_id => {
- return Some(ev)
+ return Some(ev);
}
Ok(Ok(_)) => continue,
Ok(Err(tokio::sync::broadcast::error::RecvError::Lagged(_))) => continue,
diff --git a/crates/openhuman-core/src/web_chat/turn_events.rs b/crates/openhuman-core/src/web_chat/turn_events.rs
index 9f9646f2fb..d9eb18fd01 100644
--- a/crates/openhuman-core/src/web_chat/turn_events.rs
+++ b/crates/openhuman-core/src/web_chat/turn_events.rs
@@ -19,10 +19,10 @@ use tinychannels_bus::web as bus_web;
use super::runner::{CancelNote, Shared};
use super::surface::{Surface, TurnIds};
-use super::turn_close::{close_reply, StopCause, StoppedTurn};
+use super::turn_close::{StopCause, StoppedTurn, close_reply};
use super::web_errors::{
- classify_inference_error, is_outer_backstop_timeout, turn_idle_error_message,
- turn_timeout_error_message, ClassifiedError,
+ ClassifiedError, classify_inference_error, is_outer_backstop_timeout, turn_idle_error_message,
+ turn_timeout_error_message,
};
use crate::agent::queued_turn::QueuedPayload;
diff --git a/crates/openhuman-core/src/web_chat/turn_events_tests.rs b/crates/openhuman-core/src/web_chat/turn_events_tests.rs
index 5137e41a6b..679dd936f4 100644
--- a/crates/openhuman-core/src/web_chat/turn_events_tests.rs
+++ b/crates/openhuman-core/src/web_chat/turn_events_tests.rs
@@ -248,10 +248,12 @@ async fn a_turn_stopped_before_its_config_resolved_cannot_be_closed() {
let shared = Arc::new(Shared::default());
let summarizer = WebSummarizer::new(shared.clone());
let req = request("close-none", QueueDisposition::Interrupt);
- assert!(summarizer
- .grounded_close(&req, RUNNER_DEADLINE)
- .await
- .is_none());
+ assert!(
+ summarizer
+ .grounded_close(&req, RUNNER_DEADLINE)
+ .await
+ .is_none()
+ );
assert!(summarizer.grounded_close(&req, RUNNER_IDLE).await.is_none());
}
diff --git a/crates/openhuman-core/src/web_chat/turn_host.rs b/crates/openhuman-core/src/web_chat/turn_host.rs
index 6b08bb9570..c65de23d12 100644
--- a/crates/openhuman-core/src/web_chat/turn_host.rs
+++ b/crates/openhuman-core/src/web_chat/turn_host.rs
@@ -16,19 +16,19 @@ use std::sync::Arc;
use std::time::Duration;
use async_trait::async_trait;
+use tinyagents_harness::CancellationToken;
use tinyagents_harness::run_queue::RunQueue;
use tinyagents_harness::turn_runner::{
QueueDisposition, TurnHost, TurnRequest, TurnResult, TurnSession, TurnSignal,
};
-use tinyagents_harness::CancellationToken;
use tinyinference_llm::failure::is_empty_provider_response_text;
-use tokio::sync::{mpsc, watch, Mutex as AsyncMutex};
+use tokio::sync::{Mutex as AsyncMutex, mpsc, watch};
use super::ops::{self, BudgetCorrelation};
-use super::progress::{ProgressProjection, INFERENCE_HEARTBEAT_SECS};
+use super::progress::{INFERENCE_HEARTBEAT_SECS, ProgressProjection};
use super::runner::{Admission, Shared};
use super::session::{
- checkin_session_agent, checkout_session_agent, normalize_model_override, CheckoutPolicy,
+ CheckoutPolicy, checkin_session_agent, checkout_session_agent, normalize_model_override,
};
use super::surface::TurnIds;
use super::turn_activity::{TurnActivity, WorkTracker};
@@ -37,7 +37,7 @@ use super::web_errors::{
inference_budget_exceeded_user_message, is_inference_budget_exceeded_error,
};
use crate::agent::queued_turn::QueuedPayload;
-use crate::agent::turn_origin::{with_origin, AgentTurnOrigin};
+use crate::agent::turn_origin::{AgentTurnOrigin, with_origin};
use crate::core::events::DomainEvent;
use crate::core::runtime::DispatchCtx;
use tinyagents_harness::progress::AgentProgress;
@@ -453,8 +453,12 @@ async fn speak_and_publish(
.map(str::to_string),
..Default::default()
};
- match crate::voice::reply_speech::synthesize_reply(config, &task_result.full_response, &opts)
- .await
+ match crate::voice::reply_speech::synthesize_reply(
+ config,
+ &task_result.full_response,
+ &opts,
+ )
+ .await
{
Ok(outcome) => {
let stored = super::voice_notes::store_synthesized_reply(
diff --git a/crates/openhuman-core/src/web_chat/voice_notes.rs b/crates/openhuman-core/src/web_chat/voice_notes.rs
index 0dbdf670fc..18f28936ab 100644
--- a/crates/openhuman-core/src/web_chat/voice_notes.rs
+++ b/crates/openhuman-core/src/web_chat/voice_notes.rs
@@ -12,7 +12,7 @@
use std::path::{Path, PathBuf};
-use serde_json::{json, Value};
+use serde_json::{Value, json};
const LOG_PREFIX: &str = "[web_channel][voice_note]";
/// `source` the composer stamps on a turn that began as a voice note.
diff --git a/crates/openhuman-core/src/web_chat/web_errors.rs b/crates/openhuman-core/src/web_chat/web_errors.rs
index 65cb39d2d2..91bee727ee 100644
--- a/crates/openhuman-core/src/web_chat/web_errors.rs
+++ b/crates/openhuman-core/src/web_chat/web_errors.rs
@@ -13,7 +13,7 @@ pub(crate) use budget::{
generic_inference_error_user_message, inference_budget_exceeded_user_message,
is_action_budget_exhausted, is_inference_budget_exceeded_error,
};
-pub(crate) use classify::{classify_inference_error, ClassifiedError};
+pub(crate) use classify::{ClassifiedError, classify_inference_error};
pub(crate) use retry::{is_non_retryable_rate_limit_text, retry_after_hint};
pub(crate) use timeout::{
is_outer_backstop_timeout, is_turn_timeout_error, turn_idle_error_message,
diff --git a/crates/openhuman-core/src/web_chat/web_errors/backend_error_code.rs b/crates/openhuman-core/src/web_chat/web_errors/backend_error_code.rs
index 2503cc3753..23127d1367 100644
--- a/crates/openhuman-core/src/web_chat/web_errors/backend_error_code.rs
+++ b/crates/openhuman-core/src/web_chat/web_errors/backend_error_code.rs
@@ -25,8 +25,8 @@ pub(super) fn classify_by_backend_error_code(
fallback_available: Option<bool>,
) -> Option<ClassifiedError> {
use crate::inference::provider::{
- body_flags_malformed, extract_backend_error_code, is_managed_backend_envelope,
- BackendErrorCode,
+ BackendErrorCode, body_flags_malformed, extract_backend_error_code,
+ is_managed_backend_envelope,
};
// Managed-vs-BYO gate: an `errorCode` is only trustworthy on a
@@ -49,7 +49,7 @@ pub(super) fn classify_by_backend_error_code(
);
use super::classify::{classified, classified_plain, copy_params};
- use crate::inference::failure_copy::{failure_copy, FailureClass as C};
+ use crate::inference::failure_copy::{FailureClass as C, failure_copy};
let classified = match code {
BackendErrorCode::RateLimited => {
diff --git a/crates/openhuman-core/src/web_chat/web_errors/budget.rs b/crates/openhuman-core/src/web_chat/web_errors/budget.rs
index 8bab4a48d0..23271e16e1 100644
--- a/crates/openhuman-core/src/web_chat/web_errors/budget.rs
+++ b/crates/openhuman-core/src/web_chat/web_errors/budget.rs
@@ -3,8 +3,8 @@
//! copy lives in the host copy table; the phrase matching in
//! `tinyinference_providers::billing`.
-use crate::inference::failure_copy::{failure_copy, FailureClass};
-use tinyinference_providers::{is_budget_message, BudgetMatch};
+use crate::inference::failure_copy::{FailureClass, failure_copy};
+use tinyinference_providers::{BudgetMatch, is_budget_message};
/// Whether an error string signals an exhausted inference budget, read with the
/// chat surface's [`BudgetMatch::Managed`] strictness: the managed no-credits
diff --git a/crates/openhuman-core/src/web_chat/web_errors/classify.rs b/crates/openhuman-core/src/web_chat/web_errors/classify.rs
index c666459f06..16a99f248a 100644
--- a/crates/openhuman-core/src/web_chat/web_errors/classify.rs
+++ b/crates/openhuman-core/src/web_chat/web_errors/classify.rs
@@ -6,7 +6,7 @@ use super::backend_error_code::classify_by_backend_error_code;
use super::budget::{is_action_budget_exhausted, is_inference_budget_exceeded_error};
use super::retry::{is_non_retryable_rate_limit_text, retry_after_hint};
use super::timeout::is_turn_timeout_error;
-use crate::inference::failure_copy::{failure_copy, FailureClass};
+use crate::inference::failure_copy::{FailureClass, failure_copy};
use tinyinference_llm::failure::{
extract_provider_error_detail, extract_provider_name, is_auth_error_text,
is_codex_token_expired_text, is_connection_dropped_text, is_context_length_text,
diff --git a/crates/openhuman-core/src/web_chat/web_tests.rs b/crates/openhuman-core/src/web_chat/web_tests.rs
index af2d17807b..0e59a1e49b 100644
--- a/crates/openhuman-core/src/web_chat/web_tests.rs
+++ b/crates/openhuman-core/src/web_chat/web_tests.rs
@@ -1,4 +1,5 @@
use super::{
+ ChatRequestMetadata, ClassifiedError, StartChatError, TestRunChatTaskBlock, WebChatParams,
all_web_channel_controller_schemas, all_web_channel_registered_controllers, cancel_chat_scoped,
channel_web_cancel, channel_web_queue_clear, channel_web_queue_remove,
channel_web_queue_status, classify_inference_error, drain_queued_turns_for_test,
@@ -7,14 +8,13 @@ use super::{
locale_reply_directive, normalize_model_override, parallel_in_flight_entries_for_test,
provider_role_for_model_override, schemas, sentry_suppression_reason,
set_test_forced_run_chat_task_error, set_test_run_chat_task_block, start_chat,
- subscribe_web_channel_events, ChatRequestMetadata, ClassifiedError, StartChatError,
- TestRunChatTaskBlock, WebChatParams,
+ subscribe_web_channel_events,
};
use crate::core::TypeSchema;
-use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
+use std::sync::atomic::{AtomicBool, Ordering};
use tinyagents_harness::run_queue::QueueLane;
-use tokio::time::{timeout, Duration};
+use tokio::time::{Duration, timeout};
// Serializes every test that drives `start_chat` with the process-global
// `run_chat_task` test hooks (forced error / forced block) or the
diff --git a/crates/openhuman-core/src/web_chat/web_tests_error_code_classification_tests.rs b/crates/openhuman-core/src/web_chat/web_tests_error_code_classification_tests.rs
index 3b9cd1161e..309e1d9783 100644
--- a/crates/openhuman-core/src/web_chat/web_tests_error_code_classification_tests.rs
+++ b/crates/openhuman-core/src/web_chat/web_tests_error_code_classification_tests.rs
@@ -465,14 +465,16 @@ fn chat_schema_requires_client_thread_message() {
assert!(required.contains(&"thread_id"));
assert!(required.contains(&"message"));
// model_override and temperature must be optional.
- assert!(s
- .inputs
- .iter()
- .any(|f| f.name == "model_override" && !f.required));
- assert!(s
- .inputs
- .iter()
- .any(|f| f.name == "temperature" && !f.required));
+ assert!(
+ s.inputs
+ .iter()
+ .any(|f| f.name == "model_override" && !f.required)
+ );
+ assert!(
+ s.inputs
+ .iter()
+ .any(|f| f.name == "temperature" && !f.required)
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/web_chat/web_tests_error_copy_fixture_tests.rs b/crates/openhuman-core/src/web_chat/web_tests_error_copy_fixture_tests.rs
index 5582ad38f5..cc05ec9a3b 100644
--- a/crates/openhuman-core/src/web_chat/web_tests_error_copy_fixture_tests.rs
+++ b/crates/openhuman-core/src/web_chat/web_tests_error_copy_fixture_tests.rs
@@ -8,7 +8,7 @@
//! (web_chat regex list, triage whole-word list, loop-guard billing list).
use super::*;
-use crate::agent::triage::evaluator::{classify_error, ArmError};
+use crate::agent::triage::evaluator::{ArmError, classify_error};
use crate::web_chat::WebChannelEvent;
use regex::Regex;
@@ -26,44 +26,424 @@ const EXPECTED: &[(
Option<bool>,
&str,
)] = &[
- ("codex_expired", "Codex authentication token is expired; sign in again", "provider_error", "auth", false, None, Some("openai_codex"), None, "Your Codex session has expired. Please reconnect it in Settings → Integrations."),
- ("session_expired", "SESSION_EXPIRED", "session_expired", "auth", false, None, None, None, "Your OpenHuman session has expired. Please sign in again to continue."),
- ("local_session_managed", "BACKEND_UNAVAILABLE: managed inference is unavailable for the offline local session", "auth_error", "config", false, None, None, None, "You're on the local offline profile, which has no OpenHuman account behind it, so the managed (cloud) model can't run. Sign in to use managed models, or switch routing to \"Use Your Own Models\" in Connections → API keys → LLM and add your own provider."),
- ("action_budget", "Action blocked: rate limit exceeded for tool curl", "action_budget_exceeded", "openhuman_budget", true, None, None, None, "You've hit OpenHuman's per-hour action budget — this is a local safety cap, not your AI provider. The window decays gradually; you can keep chatting in this thread and tool-heavy steps will resume as the budget refills."),
- ("max_iterations", "Agent exceeded maximum tool iterations (10)", "max_iterations", "agent_loop", true, None, None, None, "The agent ran the maximum number of tool steps for one turn without finishing. This usually means a tool kept failing (often a rate limit on a web fetch). You can retry the same question in this thread once the underlying limit clears."),
- ("turn_timeout_marker", "openhuman_turn_wall_clock_timeout: agent turn exceeded its 600s wall-clock budget", "turn_timeout", "agent_loop", true, None, None, None, "This turn ran past its time budget without finishing and was stopped so it wouldn't hang. This usually means a tool call or a delegated sub-agent stalled. You can retry your question in this thread."),
- ("turn_timeout_harness", "run timed out: tool call for run `x` exceeded its remaining wall-clock budget (5 ms)", "turn_timeout", "agent_loop", true, None, None, None, "This turn ran past its time budget without finishing and was stopped so it wouldn't hang. This usually means a tool call or a delegated sub-agent stalled. You can retry your question in this thread."),
- ("empty_response", "The model returned an empty response. Please try again.", "empty_response", "agent_loop", true, None, None, None, "The model returned an empty response. Please retry. If it keeps happening, try a different model or check its setup in Connections → API keys → LLM."),
- ("chat_template", "openai API error (400): Jinja Exception: No user query found in messages.", "chat_template_rejected", "provider", true, None, Some("openai"), None, "This model's chat template rejected the request — it isn't the model, the temperature, or your API key. Local models without native tool calling are driven through their own chat template, and some templates refuse the message shape of a tool step. Start a new chat to reset the history, or pick a model with native tool support in Connections → API keys → LLM."),
- ("rate_limited_transient", "openrouter API error (429 Too Many Requests): Retry-After: 30", "rate_limited", "provider", true, Some(30000), Some("openrouter"), None, "Your AI provider is rate-limiting requests. This is a transient upstream limit, not a thread-level block — you can retry in this thread. Try again in 30 seconds."),
- ("rate_limited_business", "openai API error (429): plan does not include this model; insufficient balance", "rate_limited", "provider", false, None, Some("openai"), None, "Your AI provider is rejecting requests for billing or plan reasons (out of credits, plan limit, or unavailable model). Retrying won't help — open Settings to top up, upgrade your plan, or pick a different model."),
- ("timeout", "request timed out after 30s", "timeout", "transport", true, None, None, None, "The request timed out. Please check your connection and try again."),
- ("auth_error", "openai API error (401 Unauthorized): invalid api key", "auth_error", "config", false, None, Some("openai"), None, "There's an authentication issue with the AI provider. Please check your API key in settings."),
- ("budget_402", "openai API error (402 Payment Required)", "budget_exhausted", "provider", false, None, Some("openai"), None, "You're out of credits, so I can't run the managed (cloud) model right now. You can top up your credits or pick a plan to continue — or, if you've enabled a local model like Ollama, switch routing to \"Use Your Own Models\" in Connections → API keys → LLM."),
- ("budget_phrase", "Insufficient budget: please top up", "budget_exhausted", "openhuman_billing", false, None, None, None, "You're out of credits, so I can't run the managed (cloud) model right now. You can top up your credits or pick a plan to continue — or, if you've enabled a local model like Ollama, switch routing to \"Use Your Own Models\" in Connections → API keys → LLM."),
- ("budget_phrase_provider_source", "openrouter API error (400): out of credits", "budget_exhausted", "provider", false, None, Some("openrouter"), None, "You're out of credits, so I can't run the managed (cloud) model right now. You can top up your credits or pick a plan to continue — or, if you've enabled a local model like Ollama, switch routing to \"Use Your Own Models\" in Connections → API keys → LLM."),
- ("provider_5xx", "anthropic API error (503 Service Unavailable)", "provider_error", "provider", true, None, Some("anthropic"), None, "The AI provider is temporarily unavailable. Please try again later."),
- ("context_overflow", "context length exceeded", "context_overflow", "config", false, None, None, None, "The conversation is too long. Please start a new chat."),
- ("config_rejection", "openai API error (400): model `reasoning-v1` does not exist", "model_unavailable", "config", false, None, Some("openai"), None, "The selected model isn't available on your provider. Check your model settings."),
- ("model_unavailable", "model foo not found on this endpoint", "model_unavailable", "config", false, None, None, None, "The selected model isn't available on your provider. Check your model settings."),
- ("model_transient", "the model is temporarily unavailable", "provider_error", "provider", true, None, None, None, "The AI provider is temporarily unavailable. Please try again later."),
- ("vision", "provider_capability_error capability=vision does not support vision input", "capability_unsupported", "config", false, None, None, None, "This model can't process images. Remove the attachment or switch to a vision-capable model in Connections → API keys → LLM."),
- ("malformed_history_byo", "openai API error (400): messages with role 'tool' must be a response to a preceding message with 'tool_calls'", "provider_request_rejected", "provider", true, None, Some("openai"), None, "We hit a temporary glitch in this conversation — we've cleared it. Please send your message again."),
- ("request_rejected_4xx", "someprovider API error (422 Unprocessable Entity): bad thing", "provider_request_rejected", "provider", false, None, Some("someprovider"), None, "The AI provider rejected the request — this is usually a model or parameter incompatibility. Try a different model in Connections → API keys → LLM."),
- ("network", "error sending request: connection reset by peer", "network", "transport", true, None, None, None, "The connection to the AI service dropped mid-response — usually a sleep/wake or network change. Please try again."),
- ("transient_529", "anthropic API error (529): overloaded", "provider_error", "provider", true, None, Some("anthropic"), None, "The AI provider is temporarily unavailable. Please try again later."),
- ("generic", "kaboom", "inference", "provider", true, None, None, None, "Something went wrong. Please try again."),
- ("fallback_chain", "All providers/models failed. Attempts: x", "inference", "provider", true, None, None, Some(false), "Something went wrong. Please try again."),
- ("be_rate_limited", "OpenHuman API error (429): {\"error\":{\"errorCode\":\"RATE_LIMITED\",\"retryAfter\":30}}", "rate_limited", "provider", true, Some(30000), Some("openhuman"), None, "Your AI provider is rate-limiting requests. You can retry in this thread. Try again in 30 seconds."),
- ("be_credits", "OpenHuman API error (402): {\"error\":{\"errorCode\":\"USER_INSUFFICIENT_CREDITS\"}}", "budget_exhausted", "openhuman_billing", false, None, Some("openhuman"), None, "You're out of credits. Top up, or switch to 'Use Your Own Models' in Settings."),
- ("be_upstream", "OpenHuman API error (502): {\"error\":{\"errorCode\":\"UPSTREAM_UNAVAILABLE\"}}", "provider_error", "provider", true, None, Some("openhuman"), None, "The AI service is temporarily unavailable — we've been notified. Please try again shortly."),
- ("be_model_unavailable", "OpenHuman API error (503): {\"error\":{\"errorCode\":\"MODEL_UNAVAILABLE\"}}", "provider_error", "provider", true, None, Some("openhuman"), None, "The AI service is temporarily unavailable — we've been notified. Please try again shortly."),
- ("be_payload", "OpenHuman API error (413): {\"error\":{\"errorCode\":\"PAYLOAD_TOO_LARGE\"}}", "payload_too_large", "config", false, None, Some("openhuman"), None, "Your message or attachment is too large for this model. Shorten it or remove the attachment — or start a new thread."),
- ("be_context", "OpenHuman API error (400): {\"error\":{\"errorCode\":\"CONTEXT_LENGTH_EXCEEDED\"}}", "context_overflow", "config", false, None, Some("openhuman"), None, "The conversation is too long. Please start a new chat."),
- ("be_bad_request", "OpenHuman API error (400): {\"error\":{\"errorCode\":\"BAD_REQUEST\",\"message\":\"x\"}}", "provider_request_rejected", "provider", false, None, Some("openhuman"), None, "The request was rejected — usually a model or parameter mismatch. Try a different model in Connections → API keys → LLM."),
- ("be_bad_request_malformed", "OpenHuman API error (400): {\"error\":{\"errorCode\":\"BAD_REQUEST\",\"malformed\":true}}", "provider_request_rejected", "provider", false, None, Some("openhuman"), None, "Something went wrong with this message. Try rephrasing it — or start a new thread if it keeps happening."),
- ("be_bad_request_history", "OpenHuman API error (400): {\"error\":{\"errorCode\":\"BAD_REQUEST\",\"message\":\"messages with role 'tool' must be a response to a preceding message with 'tool_calls'\"}}", "provider_request_rejected", "provider", true, None, Some("openhuman"), None, "We hit a temporary glitch in this conversation — we've cleared it. Please send your message again."),
- ("be_internal", "OpenHuman API error (500): {\"error\":{\"errorCode\":\"INTERNAL_ERROR\"}}", "inference", "provider", true, None, Some("openhuman"), None, "Something went wrong — we've been notified. Please try again."),
+ (
+ "codex_expired",
+ "Codex authentication token is expired; sign in again",
+ "provider_error",
+ "auth",
+ false,
+ None,
+ Some("openai_codex"),
+ None,
+ "Your Codex session has expired. Please reconnect it in Settings → Integrations.",
+ ),
+ (
+ "session_expired",
+ "SESSION_EXPIRED",
+ "session_expired",
+ "auth",
+ false,
+ None,
+ None,
+ None,
+ "Your OpenHuman session has expired. Please sign in again to continue.",
+ ),
+ (
+ "local_session_managed",
+ "BACKEND_UNAVAILABLE: managed inference is unavailable for the offline local session",
+ "auth_error",
+ "config",
+ false,
+ None,
+ None,
+ None,
+ "You're on the local offline profile, which has no OpenHuman account behind it, so the managed (cloud) model can't run. Sign in to use managed models, or switch routing to \"Use Your Own Models\" in Connections → API keys → LLM and add your own provider.",
+ ),
+ (
+ "action_budget",
+ "Action blocked: rate limit exceeded for tool curl",
+ "action_budget_exceeded",
+ "openhuman_budget",
+ true,
+ None,
+ None,
+ None,
+ "You've hit OpenHuman's per-hour action budget — this is a local safety cap, not your AI provider. The window decays gradually; you can keep chatting in this thread and tool-heavy steps will resume as the budget refills.",
+ ),
+ (
+ "max_iterations",
+ "Agent exceeded maximum tool iterations (10)",
+ "max_iterations",
+ "agent_loop",
+ true,
+ None,
+ None,
+ None,
+ "The agent ran the maximum number of tool steps for one turn without finishing. This usually means a tool kept failing (often a rate limit on a web fetch). You can retry the same question in this thread once the underlying limit clears.",
+ ),
+ (
+ "turn_timeout_marker",
+ "openhuman_turn_wall_clock_timeout: agent turn exceeded its 600s wall-clock budget",
+ "turn_timeout",
+ "agent_loop",
+ true,
+ None,
+ None,
+ None,
+ "This turn ran past its time budget without finishing and was stopped so it wouldn't hang. This usually means a tool call or a delegated sub-agent stalled. You can retry your question in this thread.",
+ ),
+ (
+ "turn_timeout_harness",
+ "run timed out: tool call for run `x` exceeded its remaining wall-clock budget (5 ms)",
+ "turn_timeout",
+ "agent_loop",
+ true,
+ None,
+ None,
+ None,
+ "This turn ran past its time budget without finishing and was stopped so it wouldn't hang. This usually means a tool call or a delegated sub-agent stalled. You can retry your question in this thread.",
+ ),
+ (
+ "empty_response",
+ "The model returned an empty response. Please try again.",
+ "empty_response",
+ "agent_loop",
+ true,
+ None,
+ None,
+ None,
+ "The model returned an empty response. Please retry. If it keeps happening, try a different model or check its setup in Connections → API keys → LLM.",
+ ),
+ (
+ "chat_template",
+ "openai API error (400): Jinja Exception: No user query found in messages.",
+ "chat_template_rejected",
+ "provider",
+ true,
+ None,
+ Some("openai"),
+ None,
+ "This model's chat template rejected the request — it isn't the model, the temperature, or your API key. Local models without native tool calling are driven through their own chat template, and some templates refuse the message shape of a tool step. Start a new chat to reset the history, or pick a model with native tool support in Connections → API keys → LLM.",
+ ),
+ (
+ "rate_limited_transient",
+ "openrouter API error (429 Too Many Requests): Retry-After: 30",
+ "rate_limited",
+ "provider",
+ true,
+ Some(30000),
+ Some("openrouter"),
+ None,
+ "Your AI provider is rate-limiting requests. This is a transient upstream limit, not a thread-level block — you can retry in this thread. Try again in 30 seconds.",
+ ),
+ (
+ "rate_limited_business",
+ "openai API error (429): plan does not include this model; insufficient balance",
+ "rate_limited",
+ "provider",
+ false,
+ None,
+ Some("openai"),
+ None,
+ "Your AI provider is rejecting requests for billing or plan reasons (out of credits, plan limit, or unavailable model). Retrying won't help — open Settings to top up, upgrade your plan, or pick a different model.",
+ ),
+ (
+ "timeout",
+ "request timed out after 30s",
+ "timeout",
+ "transport",
+ true,
+ None,
+ None,
+ None,
+ "The request timed out. Please check your connection and try again.",
+ ),
+ (
+ "auth_error",
+ "openai API error (401 Unauthorized): invalid api key",
+ "auth_error",
+ "config",
+ false,
+ None,
+ Some("openai"),
+ None,
+ "There's an authentication issue with the AI provider. Please check your API key in settings.",
+ ),
+ (
+ "budget_402",
+ "openai API error (402 Payment Required)",
+ "budget_exhausted",
+ "provider",
+ false,
+ None,
+ Some("openai"),
+ None,
+ "You're out of credits, so I can't run the managed (cloud) model right now. You can top up your credits or pick a plan to continue — or, if you've enabled a local model like Ollama, switch routing to \"Use Your Own Models\" in Connections → API keys → LLM.",
+ ),
+ (
+ "budget_phrase",
+ "Insufficient budget: please top up",
+ "budget_exhausted",
+ "openhuman_billing",
+ false,
+ None,
+ None,
+ None,
+ "You're out of credits, so I can't run the managed (cloud) model right now. You can top up your credits or pick a plan to continue — or, if you've enabled a local model like Ollama, switch routing to \"Use Your Own Models\" in Connections → API keys → LLM.",
+ ),
+ (
+ "budget_phrase_provider_source",
+ "openrouter API error (400): out of credits",
+ "budget_exhausted",
+ "provider",
+ false,
+ None,
+ Some("openrouter"),
+ None,
+ "You're out of credits, so I can't run the managed (cloud) model right now. You can top up your credits or pick a plan to continue — or, if you've enabled a local model like Ollama, switch routing to \"Use Your Own Models\" in Connections → API keys → LLM.",
+ ),
+ (
+ "provider_5xx",
+ "anthropic API error (503 Service Unavailable)",
+ "provider_error",
+ "provider",
+ true,
+ None,
+ Some("anthropic"),
+ None,
+ "The AI provider is temporarily unavailable. Please try again later.",
+ ),
+ (
+ "context_overflow",
+ "context length exceeded",
+ "context_overflow",
+ "config",
+ false,
+ None,
+ None,
+ None,
+ "The conversation is too long. Please start a new chat.",
+ ),
+ (
+ "config_rejection",
+ "openai API error (400): model `reasoning-v1` does not exist",
+ "model_unavailable",
+ "config",
+ false,
+ None,
+ Some("openai"),
+ None,
+ "The selected model isn't available on your provider. Check your model settings.",
+ ),
+ (
+ "model_unavailable",
+ "model foo not found on this endpoint",
+ "model_unavailable",
+ "config",
+ false,
+ None,
+ None,
+ None,
+ "The selected model isn't available on your provider. Check your model settings.",
+ ),
+ (
+ "model_transient",
+ "the model is temporarily unavailable",
+ "provider_error",
+ "provider",
+ true,
+ None,
+ None,
+ None,
+ "The AI provider is temporarily unavailable. Please try again later.",
+ ),
+ (
+ "vision",
+ "provider_capability_error capability=vision does not support vision input",
+ "capability_unsupported",
+ "config",
+ false,
+ None,
+ None,
+ None,
+ "This model can't process images. Remove the attachment or switch to a vision-capable model in Connections → API keys → LLM.",
+ ),
+ (
+ "malformed_history_byo",
+ "openai API error (400): messages with role 'tool' must be a response to a preceding message with 'tool_calls'",
+ "provider_request_rejected",
+ "provider",
+ true,
+ None,
+ Some("openai"),
+ None,
+ "We hit a temporary glitch in this conversation — we've cleared it. Please send your message again.",
+ ),
+ (
+ "request_rejected_4xx",
+ "someprovider API error (422 Unprocessable Entity): bad thing",
+ "provider_request_rejected",
+ "provider",
+ false,
+ None,
+ Some("someprovider"),
+ None,
+ "The AI provider rejected the request — this is usually a model or parameter incompatibility. Try a different model in Connections → API keys → LLM.",
+ ),
+ (
+ "network",
+ "error sending request: connection reset by peer",
+ "network",
+ "transport",
+ true,
+ None,
+ None,
+ None,
+ "The connection to the AI service dropped mid-response — usually a sleep/wake or network change. Please try again.",
+ ),
+ (
+ "transient_529",
+ "anthropic API error (529): overloaded",
+ "provider_error",
+ "provider",
+ true,
+ None,
+ Some("anthropic"),
+ None,
+ "The AI provider is temporarily unavailable. Please try again later.",
+ ),
+ (
+ "generic",
+ "kaboom",
+ "inference",
+ "provider",
+ true,
+ None,
+ None,
+ None,
+ "Something went wrong. Please try again.",
+ ),
+ (
+ "fallback_chain",
+ "All providers/models failed. Attempts: x",
+ "inference",
+ "provider",
+ true,
+ None,
+ None,
+ Some(false),
+ "Something went wrong. Please try again.",
+ ),
+ (
+ "be_rate_limited",
+ "OpenHuman API error (429): {\"error\":{\"errorCode\":\"RATE_LIMITED\",\"retryAfter\":30}}",
+ "rate_limited",
+ "provider",
+ true,
+ Some(30000),
+ Some("openhuman"),
+ None,
+ "Your AI provider is rate-limiting requests. You can retry in this thread. Try again in 30 seconds.",
+ ),
+ (
+ "be_credits",
+ "OpenHuman API error (402): {\"error\":{\"errorCode\":\"USER_INSUFFICIENT_CREDITS\"}}",
+ "budget_exhausted",
+ "openhuman_billing",
+ false,
+ None,
+ Some("openhuman"),
+ None,
+ "You're out of credits. Top up, or switch to 'Use Your Own Models' in Settings.",
+ ),
+ (
+ "be_upstream",
+ "OpenHuman API error (502): {\"error\":{\"errorCode\":\"UPSTREAM_UNAVAILABLE\"}}",
+ "provider_error",
+ "provider",
+ true,
+ None,
+ Some("openhuman"),
+ None,
+ "The AI service is temporarily unavailable — we've been notified. Please try again shortly.",
+ ),
+ (
+ "be_model_unavailable",
+ "OpenHuman API error (503): {\"error\":{\"errorCode\":\"MODEL_UNAVAILABLE\"}}",
+ "provider_error",
+ "provider",
+ true,
+ None,
+ Some("openhuman"),
+ None,
+ "The AI service is temporarily unavailable — we've been notified. Please try again shortly.",
+ ),
+ (
+ "be_payload",
+ "OpenHuman API error (413): {\"error\":{\"errorCode\":\"PAYLOAD_TOO_LARGE\"}}",
+ "payload_too_large",
+ "config",
+ false,
+ None,
+ Some("openhuman"),
+ None,
+ "Your message or attachment is too large for this model. Shorten it or remove the attachment — or start a new thread.",
+ ),
+ (
+ "be_context",
+ "OpenHuman API error (400): {\"error\":{\"errorCode\":\"CONTEXT_LENGTH_EXCEEDED\"}}",
+ "context_overflow",
+ "config",
+ false,
+ None,
+ Some("openhuman"),
+ None,
+ "The conversation is too long. Please start a new chat.",
+ ),
+ (
+ "be_bad_request",
+ "OpenHuman API error (400): {\"error\":{\"errorCode\":\"BAD_REQUEST\",\"message\":\"x\"}}",
+ "provider_request_rejected",
+ "provider",
+ false,
+ None,
+ Some("openhuman"),
+ None,
+ "The request was rejected — usually a model or parameter mismatch. Try a different model in Connections → API keys → LLM.",
+ ),
+ (
+ "be_bad_request_malformed",
+ "OpenHuman API error (400): {\"error\":{\"errorCode\":\"BAD_REQUEST\",\"malformed\":true}}",
+ "provider_request_rejected",
+ "provider",
+ false,
+ None,
+ Some("openhuman"),
+ None,
+ "Something went wrong with this message. Try rephrasing it — or start a new thread if it keeps happening.",
+ ),
+ (
+ "be_bad_request_history",
+ "OpenHuman API error (400): {\"error\":{\"errorCode\":\"BAD_REQUEST\",\"message\":\"messages with role 'tool' must be a response to a preceding message with 'tool_calls'\"}}",
+ "provider_request_rejected",
+ "provider",
+ true,
+ None,
+ Some("openhuman"),
+ None,
+ "We hit a temporary glitch in this conversation — we've cleared it. Please send your message again.",
+ ),
+ (
+ "be_internal",
+ "OpenHuman API error (500): {\"error\":{\"errorCode\":\"INTERNAL_ERROR\"}}",
+ "inference",
+ "provider",
+ true,
+ None,
+ Some("openhuman"),
+ None,
+ "Something went wrong — we've been notified. Please try again.",
+ ),
];
#[test]
@@ -273,15 +653,24 @@ fn shared_budget_matcher_reproduces_each_legacy_matcher_on_the_corpus() {
#[test]
fn loop_guard_halt_summaries_are_byte_identical() {
use crate::inference::failure_copy::{
- recoverable_identical_halt_summary, recoverable_no_progress_halt_summary,
- terminal_inference_halt_summary, user_actionable_escalation, TerminalInferenceFailure,
+ TerminalInferenceFailure, recoverable_identical_halt_summary,
+ recoverable_no_progress_halt_summary, terminal_inference_halt_summary,
+ user_actionable_escalation,
};
assert_eq!(
- terminal_inference_halt_summary(TerminalInferenceFailure::BudgetExhausted, "delegate", "boom"),
+ terminal_inference_halt_summary(
+ TerminalInferenceFailure::BudgetExhausted,
+ "delegate",
+ "boom"
+ ),
"Stopping: the `delegate` step failed because the account is out of inference budget/credits \u{2014} every retry hits the same wall. Add credits to your account (or, when using a custom/BYO provider, top up that provider's own account) and try again. Details:\nboom"
);
assert_eq!(
- terminal_inference_halt_summary(TerminalInferenceFailure::ProviderConfig, "delegate", "boom"),
+ terminal_inference_halt_summary(
+ TerminalInferenceFailure::ProviderConfig,
+ "delegate",
+ "boom"
+ ),
"Stopping: the `delegate` step failed because the configured model/provider rejected the request (e.g. an unknown model, a non-chat/embedding model, a missing credential, or a region block) \u{2014} retrying will not help. Fix the model or API key in Connections \u{2192} API keys \u{2192} LLM. Details:\nboom"
);
assert_eq!(
@@ -294,7 +683,9 @@ fn loop_guard_halt_summaries_are_byte_identical() {
);
assert_eq!(
user_actionable_escalation("gmail", "Gmail is not connected").as_deref(),
- Some("I can't continue without your input: the `gmail` action needs a service that isn't connected. Gmail is not connected\n\nConnect it (Connections), then tell me to retry \u{2014} or tell me how you'd like to proceed instead.")
+ Some(
+ "I can't continue without your input: the `gmail` action needs a service that isn't connected. Gmail is not connected\n\nConnect it (Connections), then tell me to retry \u{2014} or tell me how you'd like to proceed instead."
+ )
);
assert_eq!(
user_actionable_escalation("gmail", "insufficient scope"),
diff --git a/crates/openhuman-core/src/web_chat/web_tests_queue_acceptance_tests.rs b/crates/openhuman-core/src/web_chat/web_tests_queue_acceptance_tests.rs
index a949e8380e..cf601d2d82 100644
--- a/crates/openhuman-core/src/web_chat/web_tests_queue_acceptance_tests.rs
+++ b/crates/openhuman-core/src/web_chat/web_tests_queue_acceptance_tests.rs
@@ -169,9 +169,11 @@ async fn terminal_turn_dispatches_followup_as_a_fresh_host_turn() {
.any(|(key, request_id)| key == thread_id && request_id != &primary_request_id)
})
.await;
- assert!(entries
- .iter()
- .any(|(key, request_id)| key == thread_id && request_id != &primary_request_id));
+ assert!(
+ entries
+ .iter()
+ .any(|(key, request_id)| key == thread_id && request_id != &primary_request_id)
+ );
cancel_parked_turn(thread_id, &block).await;
}
@@ -233,27 +235,33 @@ async fn cancellation_discards_pending_lanes_before_a_replacement_turn() {
.await
.expect("replacement queue status should be available");
assert_eq!(replacement.value["total"], 0);
- assert!(drain_queued_turns_for_test(
- &crate::core::runtime::DispatchCtx::ambient(),
- thread_id,
- QueueLane::Followup
- )
- .await
- .is_empty());
- assert!(drain_queued_turns_for_test(
- &crate::core::runtime::DispatchCtx::ambient(),
- thread_id,
- QueueLane::Steer
- )
- .await
- .is_empty());
- assert!(drain_queued_turns_for_test(
- &crate::core::runtime::DispatchCtx::ambient(),
- thread_id,
- QueueLane::Collect
- )
- .await
- .is_empty());
+ assert!(
+ drain_queued_turns_for_test(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ thread_id,
+ QueueLane::Followup
+ )
+ .await
+ .is_empty()
+ );
+ assert!(
+ drain_queued_turns_for_test(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ thread_id,
+ QueueLane::Steer
+ )
+ .await
+ .is_empty()
+ );
+ assert!(
+ drain_queued_turns_for_test(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ thread_id,
+ QueueLane::Collect
+ )
+ .await
+ .is_empty()
+ );
cancel_parked_turn(thread_id, &replacement_block).await;
}
@@ -314,10 +322,12 @@ async fn web_queue_status_wire_shape_and_clear_cleanup_remain_stable() {
assert_eq!(lanes, ["collect", "followup", "steer"]);
for item in items {
assert!(!item["id"].as_str().expect("id").is_empty());
- assert!(item["text_preview"]
- .as_str()
- .expect("text_preview")
- .ends_with("payload"));
+ assert!(
+ item["text_preview"]
+ .as_str()
+ .expect("text_preview")
+ .ends_with("payload")
+ );
}
let cleared = channel_web_queue_clear(&DispatchCtx::ambient(), thread_id)
diff --git a/crates/openhuman-core/src/web_chat/web_tests_turn_lifecycle_tests.rs b/crates/openhuman-core/src/web_chat/web_tests_turn_lifecycle_tests.rs
index fcf806279e..a74dd2ec72 100644
--- a/crates/openhuman-core/src/web_chat/web_tests_turn_lifecycle_tests.rs
+++ b/crates/openhuman-core/src/web_chat/web_tests_turn_lifecycle_tests.rs
@@ -150,10 +150,12 @@ async fn a_refused_message_publishes_no_turn_events() {
.await
.expect_err("the guardrail refuses it");
assert!(matches!(error, StartChatError::Guardrail { .. }), "{error}");
- assert!(!in_flight_entries_for_test(&DispatchCtx::ambient())
- .await
- .iter()
- .any(|(k, _)| k == "lifecycle-refused"));
+ assert!(
+ !in_flight_entries_for_test(&DispatchCtx::ambient())
+ .await
+ .iter()
+ .any(|(k, _)| k == "lifecycle-refused")
+ );
while let Ok(event) = rx.try_recv() {
assert_ne!(event.thread_id, "lifecycle-refused", "{}", event.event);
}
@@ -165,11 +167,11 @@ async fn a_refused_message_publishes_no_turn_events() {
/// `chat_error` after which the thread is free and no session is cached.
#[tokio::test]
async fn a_turn_with_an_unavailable_local_provider_ends_in_one_classified_chat_error() {
- use crate::core::runtime::{context::CoreContext, DomainSet};
+ use crate::core::runtime::{DomainSet, context::CoreContext};
let _serial = FORCED_ERROR_TEST_LOCK.lock().await;
use wiremock::{
- matchers::{method, path},
Mock, MockServer, ResponseTemplate,
+ matchers::{method, path},
};
let server = MockServer::start().await;
@@ -314,12 +316,16 @@ async fn a_turn_with_an_unavailable_local_provider_ends_in_one_classified_chat_e
// The terminal event is the go-ahead for the next message: the thread is
// free, and the failed turn left no cached agent behind.
- assert!(!in_flight_entries_for_test(&ctx)
- .await
- .iter()
- .any(|(k, _)| k == thread_id));
- assert!(!crate::web_chat::ops::thread_sessions(&ctx)
- .lock()
- .await
- .contains_key(&key_for(&ctx, thread_id)));
+ assert!(
+ !in_flight_entries_for_test(&ctx)
+ .await
+ .iter()
+ .any(|(k, _)| k == thread_id)
+ );
+ assert!(
+ !crate::web_chat::ops::thread_sessions(&ctx)
+ .lock()
+ .await
+ .contains_key(&key_for(&ctx, thread_id))
+ );
}
diff --git a/crates/openhuman-embed/src/chat_surface.rs b/crates/openhuman-embed/src/chat_surface.rs
index f39d319ad7..e27dc744da 100644
--- a/crates/openhuman-embed/src/chat_surface.rs
+++ b/crates/openhuman-embed/src/chat_surface.rs
@@ -6,7 +6,7 @@
//! then reads it with [`subscribe_web_channel_events`].
pub use openhuman_core::web_chat::{
- publish_web_channel_event, register_approval_surface_subscriber,
- register_artifact_surface_subscriber, subscribe_web_channel_events, ScopedWebEvent,
- WebChannelEvent,
+ ScopedWebEvent, WebChannelEvent, WebEventContext, publish_web_channel_event,
+ register_approval_surface_subscriber, register_artifact_surface_subscriber,
+ subscribe_web_channel_events,
};
diff --git a/crates/openhuman-tui/src/app/thread_actions.rs b/crates/openhuman-tui/src/app/thread_actions.rs
index 59aae18ab6..ddf4bd92c6 100644
--- a/crates/openhuman-tui/src/app/thread_actions.rs
+++ b/crates/openhuman-tui/src/app/thread_actions.rs
@@ -48,12 +48,21 @@ pub(super) fn send_message(
// Surface the failure in-transcript via a synthetic chat_error so
// the reducer clears the streaming state and shows the reason.
web_chat::publish_web_channel_event(WebChannelEvent {
- event: "chat_error".to_string(),
- client_id: cid,
- thread_id: tid,
+ context: web_chat::WebEventContext {
+ client_id: cid,
+ thread_id: tid,
+ ..Default::default()
+ },
message: Some(format!("Failed to send: {e}")),
error_type: Some("transport".to_string()),
- ..Default::default()
+ error_source: None,
+ error_retryable: None,
+ error_retry_after_ms: None,
+ error_provider: None,
+ error_fallback_available: None,
+ copy_key: None,
+ copy_params: None,
+ guardrail: None,
});
}
});
diff --git a/crates/openhuman-tui/src/event_view.rs b/crates/openhuman-tui/src/event_view.rs
index 7b9e62324b..1355d96967 100644
--- a/crates/openhuman-tui/src/event_view.rs
+++ b/crates/openhuman-tui/src/event_view.rs
@@ -76,37 +76,101 @@ impl WebEventView {
E::ChatCancelled { cancel_reason, .. } => {
view.message.clone_from(cancel_reason);
}
- E::TextDelta { delta, .. } | E::ThinkingDelta { delta, .. } | E::SubagentTextDelta { delta, .. } | E::SubagentThinkingDelta { delta, .. } => {
+ E::TextDelta { delta, .. }
+ | E::ThinkingDelta { delta, .. }
+ | E::SubagentTextDelta { delta, .. }
+ | E::SubagentThinkingDelta { delta, .. } => {
view.delta.clone_from(delta);
}
E::IterationStart { message, .. }
| E::RunModeChanged { message, .. }
- | E::UserError { error_source: message, .. } => {
+ | E::UserError {
+ error_source: message,
+ ..
+ } => {
view.message.clone_from(message);
}
- E::ToolCall { tool_name, skill_id, args, tool_call_id, tool_display_label, .. }
- | E::SubagentToolCall { tool_name, skill_id, args, tool_call_id, tool_display_label, .. } => {
+ E::ToolCall {
+ tool_name,
+ skill_id,
+ args,
+ tool_call_id,
+ tool_display_label,
+ ..
+ }
+ | E::SubagentToolCall {
+ tool_name,
+ skill_id,
+ args,
+ tool_call_id,
+ tool_display_label,
+ ..
+ } => {
view.tool_name.clone_from(tool_name);
view.skill_id.clone_from(skill_id);
view.args.clone_from(args);
view.tool_call_id.clone_from(tool_call_id);
view.tool_display_label.clone_from(tool_display_label);
}
- E::ApprovalRequest { tool_name, args, tool_call_id, message, .. }
- | E::PlanReviewRequest { tool_name, args, tool_call_id, message, .. } => {
+ E::ApprovalRequest {
+ tool_name,
+ args,
+ tool_call_id,
+ message,
+ ..
+ }
+ | E::PlanReviewRequest {
+ tool_name,
+ args,
+ tool_call_id,
+ message,
+ ..
+ } => {
view.tool_name.clone_from(tool_name);
view.args.clone_from(args);
view.tool_call_id.clone_from(tool_call_id);
view.message.clone_from(message);
}
- E::ApprovalDecided { tool_name, message, tool_call_id, .. }
- | E::PlanReviewDecided { tool_name, message, tool_call_id, .. } => {
+ E::ApprovalDecided {
+ tool_name,
+ message,
+ tool_call_id,
+ ..
+ }
+ | E::PlanReviewDecided {
+ tool_name,
+ message,
+ tool_call_id,
+ ..
+ } => {
view.tool_name.clone_from(tool_name);
view.message.clone_from(message);
view.tool_call_id.clone_from(tool_call_id);
}
- E::ToolResult { tool_name, skill_id, output, args, success, tool_call_id, failure, elapsed_ms, tool_display_label, .. }
- | E::SubagentToolResult { tool_name, skill_id, output, args, success, tool_call_id, failure, elapsed_ms, tool_display_label, .. } => {
+ E::ToolResult {
+ tool_name,
+ skill_id,
+ output,
+ args,
+ success,
+ tool_call_id,
+ failure,
+ elapsed_ms,
+ tool_display_label,
+ ..
+ }
+ | E::SubagentToolResult {
+ tool_name,
+ skill_id,
+ output,
+ args,
+ success,
+ tool_call_id,
+ failure,
+ elapsed_ms,
+ tool_display_label,
+ ..
+ } => {
view.tool_name.clone_from(tool_name);
view.skill_id.clone_from(skill_id);
view.output.clone_from(output);
@@ -117,21 +181,61 @@ impl WebEventView {
view.elapsed_ms.clone_from(elapsed_ms);
view.tool_display_label.clone_from(tool_display_label);
}
- E::ToolArgsDelta { delta, tool_name, skill_id, tool_call_id, .. } => {
+ E::ToolArgsDelta {
+ delta,
+ tool_name,
+ skill_id,
+ tool_call_id,
+ ..
+ } => {
view.delta.clone_from(delta);
view.tool_name.clone_from(tool_name);
view.skill_id.clone_from(skill_id);
view.tool_call_id.clone_from(tool_call_id);
}
- E::ToolProgress { tool_call_id, message, .. } => {
+ E::ToolProgress {
+ tool_call_id,
+ message,
+ ..
+ } => {
view.tool_call_id.clone_from(tool_call_id);
view.message.clone_from(message);
}
- E::SubagentSpawned { tool_name, skill_id, subagent, message, .. }
- | E::SubagentCompleted { tool_name, skill_id, subagent, message, .. }
- | E::SubagentFailed { tool_name, skill_id, subagent, message, .. }
- | E::SubagentAwaitingUser { tool_name, skill_id, subagent, message, .. }
- | E::SubagentIterationStart { tool_name, skill_id, subagent, message, .. } => {
+ E::SubagentSpawned {
+ tool_name,
+ skill_id,
+ subagent,
+ message,
+ ..
+ }
+ | E::SubagentCompleted {
+ tool_name,
+ skill_id,
+ subagent,
+ message,
+ ..
+ }
+ | E::SubagentFailed {
+ tool_name,
+ skill_id,
+ subagent,
+ message,
+ ..
+ }
+ | E::SubagentAwaitingUser {
+ tool_name,
+ skill_id,
+ subagent,
+ message,
+ ..
+ }
+ | E::SubagentIterationStart {
+ tool_name,
+ skill_id,
+ subagent,
+ message,
+ ..
+ } => {
view.tool_name.clone_from(tool_name);
view.skill_id.clone_from(skill_id);
view.message.clone_from(message);
@@ -142,9 +246,15 @@ impl WebEventView {
output: detail.output.clone(),
});
}
- E::ArtifactReady { tool_call_id, args, .. }
- | E::ArtifactFailed { tool_call_id, args, .. }
- | E::ArtifactPending { tool_call_id, args, .. } => {
+ E::ArtifactReady {
+ tool_call_id, args, ..
+ }
+ | E::ArtifactFailed {
+ tool_call_id, args, ..
+ }
+ | E::ArtifactPending {
+ tool_call_id, args, ..
+ } => {
view.tool_call_id.clone_from(tool_call_id);
view.args.clone_from(args);
}
diff --git a/crates/openhuman-tui/src/state_tests.rs b/crates/openhuman-tui/src/state_tests.rs
index 156f0adb67..f2f0a12595 100644
--- a/crates/openhuman-tui/src/state_tests.rs
+++ b/crates/openhuman-tui/src/state_tests.rs
@@ -32,18 +32,25 @@ fn ev(event: &str, fields: serde_json::Value) -> WebChannelEvent {
"thread_id": "thread-1",
"request_id": "request-1"
});
- value.as_object_mut().unwrap().extend(
- fields.as_object().unwrap().clone(),
- );
+ value
+ .as_object_mut()
+ .unwrap()
+ .extend(fields.as_object().unwrap().clone());
serde_json::from_value(value).expect("test event matches the owner contract")
}
fn text_delta(delta: &str) -> WebChannelEvent {
- ev("text_delta", serde_json::json!({"delta":delta,"delta_kind":"text"}))
+ ev(
+ "text_delta",
+ serde_json::json!({"delta":delta,"delta_kind":"text"}),
+ )
}
fn thinking_delta(delta: &str) -> WebChannelEvent {
- ev("thinking_delta", serde_json::json!({"delta":delta,"delta_kind":"thinking"}))
+ ev(
+ "thinking_delta",
+ serde_json::json!({"delta":delta,"delta_kind":"thinking"}),
+ )
}
#[test]
@@ -106,7 +113,10 @@ fn chat_done_replaces_streamed_text_with_full_response() {
let mut s = TranscriptState::new(CLIENT);
s.begin_user_turn("hi");
s.apply_event(&text_delta("Hel")); // partial / laggy stream
- let done = ev("chat_done", serde_json::json!({"full_response":"Hello, world!"}));
+ let done = ev(
+ "chat_done",
+ serde_json::json!({"full_response":"Hello, world!"}),
+ );
s.apply_event(&done);
let assistant: Vec<_> = s
@@ -126,7 +136,10 @@ fn chat_done_replaces_streamed_text_with_full_response() {
fn chat_done_without_prior_deltas_still_shows_full_response() {
let mut s = TranscriptState::new(CLIENT);
s.begin_user_turn("hi");
- let done = ev("chat_done", serde_json::json!({"full_response":"Direct answer"}));
+ let done = ev(
+ "chat_done",
+ serde_json::json!({"full_response":"Direct answer"}),
+ );
s.apply_event(&done);
let assistant = s
.entries()
@@ -141,7 +154,10 @@ fn chat_done_without_prior_deltas_still_shows_full_response() {
fn chat_error_pushes_error_entry_and_ends_stream() {
let mut s = TranscriptState::new(CLIENT);
s.begin_user_turn("hi");
- let err = ev("chat_error", serde_json::json!({"message":"rate limited","error_type":"rate_limit"}));
+ let err = ev(
+ "chat_error",
+ serde_json::json!({"message":"rate limited","error_type":"rate_limit"}),
+ );
s.apply_event(&err);
let error = s
.entries()
@@ -156,9 +172,12 @@ fn chat_error_pushes_error_entry_and_ends_stream() {
fn retryable_error_includes_retry_timing() {
let mut state = TranscriptState::new(CLIENT);
state.begin_user_turn("try");
- state.apply_event(&ev("chat_error", serde_json::json!({
- "message":"rate limited","error_retryable":true,"error_retry_after_ms":2100
- })));
+ state.apply_event(&ev(
+ "chat_error",
+ serde_json::json!({
+ "message":"rate limited","error_retryable":true,"error_retry_after_ms":2100
+ }),
+ ));
assert_eq!(
state.entries().last().unwrap().text,
"rate limited · retryable after 3s"
@@ -171,7 +190,10 @@ fn last_assistant_excludes_an_in_flight_partial_answer() {
state.begin_user_turn("question");
state.apply_event(&text_delta("partial"));
assert_eq!(state.last_assistant(), None);
- state.apply_event(&ev("chat_done", serde_json::json!({"full_response":"complete"})));
+ state.apply_event(&ev(
+ "chat_done",
+ serde_json::json!({"full_response":"complete"}),
+ ));
assert_eq!(state.last_assistant(), Some("complete"));
}
@@ -181,7 +203,9 @@ fn events_for_other_client_id_are_ignored() {
s.begin_user_turn("hi");
let before = s.entries().len();
let foreign = {
- let mut event = serde_json::to_value(ev("text_delta", serde_json::json!({"delta":"not mine"}))).unwrap();
+ let mut event =
+ serde_json::to_value(ev("text_delta", serde_json::json!({"delta":"not mine"})))
+ .unwrap();
event["client_id"] = "tui-someone-else".into();
serde_json::from_value(event).unwrap()
};
@@ -223,13 +247,19 @@ fn projected_transcript_is_restored_in_chronological_order() {
fn tool_result_updates_the_originating_activity() {
let mut s = TranscriptState::new(CLIENT);
s.begin_user_turn("do it");
- let call = ev("tool_call", serde_json::json!({
- "tool_name":"web_search","args":{"query":"rust ratatui"}
- }));
+ let call = ev(
+ "tool_call",
+ serde_json::json!({
+ "tool_name":"web_search","args":{"query":"rust ratatui"}
+ }),
+ );
s.apply_event(&call);
- let result = ev("tool_result", serde_json::json!({
- "tool_name":"web_search","success":true,"output":"3 results"
- }));
+ let result = ev(
+ "tool_result",
+ serde_json::json!({
+ "tool_name":"web_search","success":true,"output":"3 results"
+ }),
+ );
s.apply_event(&result);
let tools: Vec<_> = s
@@ -248,9 +278,12 @@ fn tool_result_updates_the_originating_activity() {
fn failed_tool_result_uses_cross_marker() {
let mut s = TranscriptState::new(CLIENT);
s.begin_user_turn("do it");
- let result = ev("tool_result", serde_json::json!({
- "tool_name":"run_shell","success":false,"output":"exit code 1"
- }));
+ let result = ev(
+ "tool_result",
+ serde_json::json!({
+ "tool_name":"run_shell","success":false,"output":"exit code 1"
+ }),
+ );
s.apply_event(&result);
let tool = s
.entries()
@@ -292,14 +325,20 @@ fn concurrent_same_named_tools_match_results_by_call_identity() {
let mut state = TranscriptState::new(CLIENT);
state.set_thread("thread-1");
for id in ["a", "b"] {
- state.apply_event(&ev("tool_call", serde_json::json!({
- "tool_call_id":id,"tool_name":"read","request_id":"turn"
- })));
+ state.apply_event(&ev(
+ "tool_call",
+ serde_json::json!({
+ "tool_call_id":id,"tool_name":"read","request_id":"turn"
+ }),
+ ));
}
- state.apply_event(&ev("tool_result", serde_json::json!({
- "tool_call_id":"b","tool_name":"read","request_id":"turn",
- "success":false,"output":"failure"
- })));
+ state.apply_event(&ev(
+ "tool_result",
+ serde_json::json!({
+ "tool_call_id":"b","tool_name":"read","request_id":"turn",
+ "success":false,"output":"failure"
+ }),
+ ));
assert_eq!(
state.entries()[0].activity.as_ref().unwrap().status,
Status::Running
@@ -308,9 +347,12 @@ fn concurrent_same_named_tools_match_results_by_call_identity() {
state.entries()[1].activity.as_ref().unwrap().status,
Status::Error
);
- state.apply_event(&ev("tool_result", serde_json::json!({
- "tool_call_id":"b","request_id":"turn","success":false
- })));
+ state.apply_event(&ev(
+ "tool_result",
+ serde_json::json!({
+ "tool_call_id":"b","request_id":"turn","success":false
+ }),
+ ));
assert_eq!(state.entries().len(), 2);
}
@@ -322,9 +364,12 @@ fn child_activity_accumulates_output_and_failed_status_in_one_record() {
("subagent_text_delta", Some("partial")),
("subagent_failed", None),
] {
- state.apply_event(&ev(event, serde_json::json!({
- "skill_id":"task","request_id":"turn","delta":delta,"message":"Timed out"
- })));
+ state.apply_event(&ev(
+ event,
+ serde_json::json!({
+ "skill_id":"task","request_id":"turn","delta":delta,"message":"Timed out"
+ }),
+ ));
}
assert_eq!(state.entries().len(), 1);
let child = state.entries()[0].activity.as_ref().unwrap();
@@ -337,7 +382,10 @@ fn child_activity_accumulates_output_and_failed_status_in_one_record() {
#[test]
fn sequence_duplicates_do_not_duplicate_streamed_text() {
let mut state = TranscriptState::new(CLIENT);
- let event = ev("text_delta", serde_json::json!({"request_id":"turn","seq":0,"delta":"one","delta_kind":"text"}));
+ let event = ev(
+ "text_delta",
+ serde_json::json!({"request_id":"turn","seq":0,"delta":"one","delta_kind":"text"}),
+ );
state.apply_event(&event);
state.apply_event(&event);
assert_eq!(state.entries()[0].text, "one");
diff --git a/crates/openhuman-tui/src/viewport_tests.rs b/crates/openhuman-tui/src/viewport_tests.rs
index c66d42ffc8..7b35f68ed0 100644
--- a/crates/openhuman-tui/src/viewport_tests.rs
+++ b/crates/openhuman-tui/src/viewport_tests.rs
@@ -64,9 +64,12 @@ fn idle_and_old_entry_edits_do_not_revisit_settled_history() {
fn indexed_rows_equal_full_wrapping_after_updates_resizes_and_expired_journal() {
use openhuman_rpc::embed::chat_surface::WebChannelEvent;
let mut state = TranscriptState::new("test");
- state.apply_event(&serde_json::from_value(serde_json::json!({
- "event":"tool_call","client_id":"test","tool_call_id":"first","tool_name":"tool"
- })).unwrap());
+ state.apply_event(
+ &serde_json::from_value(serde_json::json!({
+ "event":"tool_call","client_id":"test","tool_call_id":"first","tool_name":"tool"
+ }))
+ .unwrap(),
+ );
for index in 0..150 {
state.push_system(format!("entry {index} 界e\u{301}\nnext"));
}
@@ -76,10 +79,13 @@ fn indexed_rows_equal_full_wrapping_after_updates_resizes_and_expired_journal()
state.toggle_entry(0);
}
if step == 4 {
- state.apply_event(&serde_json::from_value(serde_json::json!({
- "event":"tool_result","client_id":"test","tool_call_id":"first",
- "output":"a\nb\nc","success":true
- })).unwrap());
+ state.apply_event(
+ &serde_json::from_value(serde_json::json!({
+ "event":"tool_result","client_id":"test","tool_call_id":"first",
+ "output":"a\nb\nc","success":true
+ }))
+ .unwrap(),
+ );
}
if step == 5 {
for _ in 0..140 {
@@ -161,7 +167,10 @@ fn changing_an_old_tools_height_updates_prefix_lookup_without_rebuilding_history
let mut value = serde_json::json!({
"event":name,"client_id":"test","tool_call_id":"old","tool_name":"tool"
});
- value.as_object_mut().unwrap().extend(fields.as_object().unwrap().clone());
+ value
+ .as_object_mut()
+ .unwrap()
+ .extend(fields.as_object().unwrap().clone());
serde_json::from_value::<WebChannelEvent>(value).unwrap()
};
state.apply_event(&event("tool_call"));