Skip to content

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

test(cron): cover channel session identity in cron tool tests

Steven Enamakel543231be13bf
diff --git a/crates/openhuman-core/src/cron/tools/collapsed_tests.rs b/crates/openhuman-core/src/cron/tools/collapsed_tests.rs
index b61bb656f6..8455aa588d 100644
--- a/crates/openhuman-core/src/cron/tools/collapsed_tests.rs
+++ b/crates/openhuman-core/src/cron/tools/collapsed_tests.rs
@@ -153,6 +153,27 @@ async fn run_uses_the_explicit_core_context_and_preserves_markdown_options() {
.is_some_and(|md| md.contains("status")));
}
+/// The trusted durable-session identity a channel turn carries. Jobs created
+/// from a channel conversation record it; a turn without one has no
+/// conversation to bind a job to.
+fn channel_session(reply_target: &str) -> tinyflows_bus::schedule::ChannelSessionIdentity {
+ tinyflows_bus::schedule::ChannelSessionIdentity {
+ tenant_key: "profile:alice".into(),
+ agent_id: "orchestrator".into(),
+ session_key: format!("main:telegram:bot-a:dm:{reply_target}"),
+ provider: "telegram".into(),
+ account_id: Some("telegram:bot-a".into()),
+ conversation: tinyflows_bus::schedule::ChannelConversationIdentity {
+ kind: "dm".into(),
+ id: reply_target.into(),
+ scope_id: None,
+ parent_id: None,
+ thread_id: None,
+ topic_id: None,
+ },
+ }
+}
+
#[tokio::test]
async fn add_uses_the_explicit_channel_origin_without_ambient_turn_state() {
let tmp = tempfile::TempDir::new().unwrap();
@@ -173,7 +194,7 @@ async fn add_uses_the_explicit_channel_origin_without_ambient_turn_state() {
reply_target: "42".into(),
message_id: "message-1".into(),
history_key: Some("telegram-alice-42".into()),
- channel_session: None,
+ channel_session: Some(channel_session("42")),
};
let mut run = OpenHumanRunContext::new();
run.origin = Some(origin);
@@ -205,7 +226,7 @@ async fn add_uses_the_explicit_channel_origin_without_ambient_turn_state() {
history_key: "telegram-alice-42".into(),
sender: Some("alice".into()),
thread_id: None,
- channel_session: None,
+ channel_session: Some(Box::new(channel_session("42"))),
})
);
assert_eq!(jobs[0].delivery.mode, "origin");
diff --git a/crates/openhuman-core/src/cron/tools/update_tests.rs b/crates/openhuman-core/src/cron/tools/update_tests.rs
index ca868b5175..febf1c84a5 100644
--- a/crates/openhuman-core/src/cron/tools/update_tests.rs
+++ b/crates/openhuman-core/src/cron/tools/update_tests.rs
@@ -7,6 +7,27 @@ use tinyagents_harness::{context::RunConfig, ids::CallId, tool::ToolExecutionCon
use tinyflows_bus::schedule::types::{DeliveryConfig, JobOrigin, Schedule, SessionTarget};
use tinyflows_bus::schedule::AgentJobSpec;
+/// The trusted durable-session identity a channel turn carries. Jobs created
+/// from a channel conversation record it; a turn without one has no
+/// conversation to bind a job to.
+fn channel_session(reply_target: &str) -> tinyflows_bus::schedule::ChannelSessionIdentity {
+ tinyflows_bus::schedule::ChannelSessionIdentity {
+ tenant_key: "profile:alice".into(),
+ agent_id: "orchestrator".into(),
+ session_key: format!("main:telegram:bot-a:dm:{reply_target}"),
+ provider: "telegram".into(),
+ account_id: Some("telegram:bot-a".into()),
+ conversation: tinyflows_bus::schedule::ChannelConversationIdentity {
+ kind: "dm".into(),
+ id: reply_target.into(),
+ scope_id: None,
+ parent_id: None,
+ thread_id: None,
+ topic_id: None,
+ },
+ }
+}
+
fn channel_origin(reply_target: &str) -> JobOrigin {
JobOrigin::Channel {
channel: "telegram".into(),
@@ -14,7 +35,7 @@ fn channel_origin(reply_target: &str) -> JobOrigin {
history_key: format!("telegram-user-{reply_target}"),
sender: Some("alice".into()),
thread_id: None,
- channel_session: None,
+ channel_session: Some(Box::new(channel_session(reply_target))),
}
}
@@ -27,7 +48,7 @@ fn trusted_channel_context(reply_target: &str) -> (impl Sized, ToolExecutionCont
reply_target: reply_target.into(),
message_id: "message-1".into(),
history_key: Some(format!("telegram-user-{reply_target}")),
- channel_session: None,
+ channel_session: Some(channel_session(reply_target)),
});
let run = run_context.into_tinyagents(RunConfig::new("cron-update-context"));
let tool_context =