Skip to content

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

feat(web_chat): expose SESSION_CHECKOUT_FAILURE constant

Steven Enamakel28d941472912
diff --git a/crates/openhuman-core/src/web_chat/mod.rs b/crates/openhuman-core/src/web_chat/mod.rs
index ea9f2d1a8a..6aa095f5cf 100644
--- a/crates/openhuman-core/src/web_chat/mod.rs
+++ b/crates/openhuman-core/src/web_chat/mod.rs
@@ -67,7 +67,8 @@ pub use ops::parallel_in_flight_entries_for_test;
pub use ops::{
cancel_chat, cancel_chat_scoped, cancel_should_target, channel_web_cancel, channel_web_chat,
channel_web_queue_clear, channel_web_queue_status, in_flight_entries_for_test,
- invalidate_thread_sessions, run_system_turn_on_thread, start_chat, SYSTEM_CLIENT_ID,
+ invalidate_thread_sessions, run_system_turn_on_thread, start_chat, SESSION_CHECKOUT_FAILURE,
+ SYSTEM_CLIENT_ID,
};
pub use types::ChatRequestMetadata;
diff --git a/crates/openhuman-core/src/web_chat/ops.rs b/crates/openhuman-core/src/web_chat/ops.rs
index 70ff1b3cdc..37625bb973 100644
--- a/crates/openhuman-core/src/web_chat/ops.rs
+++ b/crates/openhuman-core/src/web_chat/ops.rs
@@ -24,7 +24,7 @@ pub use channel_ops::{
};
pub use start_chat::start_chat;
-pub use system_turn::{run_system_turn_on_thread, SYSTEM_CLIENT_ID};
+pub use system_turn::{run_system_turn_on_thread, SESSION_CHECKOUT_FAILURE, SYSTEM_CLIENT_ID};
#[cfg(test)]
pub use state::drain_queued_turns_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 c7d71a8176..0934a93441 100644
--- a/crates/openhuman-core/src/web_chat/ops/system_turn.rs
+++ b/crates/openhuman-core/src/web_chat/ops/system_turn.rs
@@ -29,6 +29,11 @@ use super::super::session::{
/// collides with a user's cancel/interrupt routing.
pub const SYSTEM_CLIENT_ID: &str = "system";
+/// Prefix on the error a system turn returns when the thread's session could
+/// not even be checked out (config load or agent build), as opposed to a turn
+/// that ran and failed. Callers that track "did a turn run" key off it.
+pub const SESSION_CHECKOUT_FAILURE: &str = "session checkout failed: ";
+
/// Run one host-authored turn on `thread_id` through the thread's session and
/// return the reply text. Best-effort: the caller decides how to surface the
/// reply (background delivery persists and announces it; goal continuation
@@ -43,7 +48,9 @@ pub async fn run_system_turn_on_thread(
prompt: &str,
origin: AgentTurnOrigin,
) -> Result<String, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = config_rpc::load_config_with_timeout()
+ .await
+ .map_err(|error| format!("{SESSION_CHECKOUT_FAILURE}{error}"))?;
let CheckedOutSession {
mut agent,
fingerprint,
@@ -57,7 +64,8 @@ pub async fn run_system_turn_on_thread(
/* fork */ false,
"",
)
- .await?;
+ .await
+ .map_err(|error| format!("{SESSION_CHECKOUT_FAILURE}{error}"))?;
log::info!(
"[web-channel] running system turn on thread={} run_id={} origin={} prompt_chars={}",