Skip to content

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

test(channels): update remote reset tests and processors

Steven Enamakel9bac9d2b4aa9
diff --git a/crates/openhuman-core/src/channels/routes_remote_reset_tests.rs b/crates/openhuman-core/src/channels/routes_remote_reset_tests.rs
index 8524ea90eb..45f3c4de3a 100644
--- a/crates/openhuman-core/src/channels/routes_remote_reset_tests.rs
+++ b/crates/openhuman-core/src/channels/routes_remote_reset_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use crate::channels::routes::tests::{remote_session_scope, runtime_context};
+use crate::channels::routes::tests::runtime_context;
use crate::core::runtime::{ContextOverlay, CoreContext, DispatchCtx, DomainSet};
use std::collections::HashMap;
use std::path::Path;
@@ -53,15 +53,28 @@ fn transcript_meta(thread_id: &str) -> TranscriptMeta {
}
}
+fn remote_session_scope() -> tinychannels_bus::module_remote::RemoteSessionScope {
+ tinychannels_bus::module_remote::RemoteSessionScope {
+ channel: tinychannels_bus::ChannelRef {
+ id: "telegram".into(),
+ account_id: Some("telegram:bot-a".into()),
+ },
+ conversation: tinychannels_bus::ConversationRef {
+ kind: tinychannels_bus::ConversationKind::Group,
+ id: "room-1".into(),
+ topic_id: Some("topic-3".into()),
+ ..Default::default()
+ },
+ session_key: "prepared-session".into(),
+ }
+}
+
fn seed_session(core: &CoreContext, workspace: &Path, key: &str) -> SessionRef {
let session = SessionRef::scoped(key, "orchestrator");
- let history = crate::agent::session_store::transcripts_or_files_in(
- core,
- "orchestrator",
- workspace,
- )
- .open_session(&session, transcript_meta(key))
- .unwrap();
+ let history =
+ crate::agent::session_store::transcripts_or_files_in(core, "orchestrator", workspace)
+ .open_session(&session, transcript_meta(key))
+ .unwrap();
history
.append(TranscriptMessage::user("prior tenant turn"))
.unwrap();
@@ -72,11 +85,8 @@ fn seed_session(core: &CoreContext, workspace: &Path, key: &str) -> SessionRef {
}
fn session_messages(core: &CoreContext, workspace: &Path, session: &SessionRef) -> Vec<String> {
- let locator = crate::agent::session_store::transcripts_or_files_in(
- core,
- "orchestrator",
- workspace,
- );
+ let locator =
+ crate::agent::session_store::transcripts_or_files_in(core, "orchestrator", workspace);
let head = locator.head_generation(session);
locator
.read_session_transcript(&head)
@@ -93,7 +103,10 @@ fn session_messages(core: &CoreContext, workspace: &Path, session: &SessionRef)
fn tenant_runtime(
profile: &str,
workspace: &Path,
-) -> (Arc<CoreContext>, crate::channels::context::ChannelRuntimeContext) {
+) -> (
+ Arc<CoreContext>,
+ crate::channels::context::ChannelRuntimeContext,
+) {
let workspace = workspace.to_path_buf();
let config = crate::config::Config {
workspace_dir: workspace.clone(),
@@ -162,8 +175,14 @@ async fn remote_clear_resets_only_the_captured_tenant_session() {
)
.await
.is_err());
- assert_eq!(session_messages(&alice_core, workspace, &alice_session).len(), 2);
- assert_eq!(session_messages(&bob_core, workspace, &bob_session).len(), 2);
+ assert_eq!(
+ session_messages(&alice_core, workspace, &alice_session).len(),
+ 2
+ );
+ assert_eq!(
+ session_messages(&bob_core, workspace, &bob_session).len(),
+ 2
+ );
let cleared = crate::channels::host::remote_control::dispatch_callback(
&alice_dispatch,
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/reset.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/reset.rs
index a15bbea282..43b86ae4c0 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/reset.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/reset.rs
@@ -1,6 +1,18 @@
use super::super::host_agent::{self, HostRoute};
use crate::channels::context::ChannelRuntimeContext;
+pub(crate) async fn reset_command(
+ ctx: std::sync::Arc<ChannelRuntimeContext>,
+ message: tinychannels_bus::ChannelMessage,
+ session_key: String,
+ history_key: String,
+) -> Result<(), String> {
+ reset_durable_channel_session(&ctx, &message, &session_key, &history_key)
+ .await
+ .map(|_| ())
+ .map_err(|error| error.to_string())
+}
+
/// Reset the durable session selected for this channel conversation. The
/// module still owns command parsing; this host adapter resolves trusted agent
/// authority and serializes the generation transition with turns.
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
index 6aec8d8c64..9925e83fab 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
@@ -23,7 +23,6 @@ use super::super::helpers::{
};
use super::super::host_agent::{self, HostRoute};
use super::approval::{channel_has_approval_surface, try_route_approval_reply};
-use super::reset_durable_channel_session;
use super::RuntimeChannelMessage;
pub(crate) async fn process_channel_message(
@@ -145,15 +144,13 @@ pub(crate) async fn process_channel_runtime_message(
Some(session_key.clone()),
&msg,
|| async move {
- reset_durable_channel_session(
- &reset_context,
- &reset_message,
- &reset_session_key,
- &reset_history_key,
+ super::reset::reset_command(
+ reset_context,
+ reset_message,
+ reset_session_key,
+ reset_history_key,
)
.await
- .map(|_| ())
- .map_err(|error| error.to_string())
},
)
.await