Skip to content

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

feat(cron): add origin delivery tests for scheduler

Steven Enamakel2bb7a6d80638
diff --git a/crates/openhuman-core/src/cron/scheduler/origin_delivery_tests.rs b/crates/openhuman-core/src/cron/scheduler/origin_delivery_tests.rs
index 122fe71d52..62bb86e5fb 100644
--- a/crates/openhuman-core/src/cron/scheduler/origin_delivery_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler/origin_delivery_tests.rs
@@ -266,3 +266,64 @@ async fn transcript_append_waits_for_a_live_turn() {
drop(guard);
task.await.unwrap().unwrap();
}
+
+/// The append lands in the store the caller's key names: a SaaS profile's
+/// `<profile>~<agent>` transcript, never the unprefixed one of the same
+/// workspace.
+#[tokio::test]
+async fn transcript_append_uses_the_store_key_it_is_given() {
+ let tmp = tempfile::TempDir::new().unwrap();
+ let cfg = config(&tmp);
+ let tenant = crate::core::runtime::Tenant {
+ profile: Some("profile-a".into()),
+ agent: None,
+ };
+ let key = crate::agent::session_store::agent_key_for(&tenant, "orchestrator");
+ assert_eq!(key, "profile-a~default");
+ let locator = crate::agent::session_store::transcripts_or_files(&key, &cfg.workspace_dir);
+ let session = SessionRef::scoped("t-p", "orchestrator");
+ let next = vec![
+ TranscriptMessage::user("remind me"),
+ TranscriptMessage::assistant("Scheduled."),
+ ];
+ locator
+ .open_session(&session, meta())
+ .unwrap()
+ .append_turn(TranscriptTurn {
+ prev: &[],
+ next: &next,
+ meta: &meta(),
+ turn_usage: None,
+ request_id: None,
+ tools: None,
+ })
+ .unwrap();
+
+ let append = |store_key: &'static str| TranscriptAppend {
+ thread_id: "t-p",
+ agent_id: "orchestrator",
+ store_key,
+ text: "Ping!",
+ idempotency_key: "cron:job-p:run-1",
+ job_id: "job-p",
+ run_id: "run-1",
+ };
+ // The unprefixed key has no such session: nothing is written anywhere.
+ append_to_origin_transcript(&cfg.workspace_dir, &append("orchestrator"))
+ .await
+ .unwrap();
+ append_to_origin_transcript(&cfg.workspace_dir, &append("profile-a~default"))
+ .await
+ .unwrap();
+
+ let head = locator.head_generation(&session);
+ let messages = locator
+ .read_session_transcript(&head)
+ .unwrap()
+ .read_session()
+ .unwrap()
+ .unwrap()
+ .messages;
+ assert_eq!(messages.len(), 3, "appended once, to the profile's transcript");
+ assert_eq!(messages.last().unwrap().content, "Ping!");
+}
diff --git a/vendor/tinyagents b/vendor/tinyagents
index 69d295615b..dc9a055e94 160000
--- a/vendor/tinyagents
+++ b/vendor/tinyagents
@@ -1 +1 @@
-Subproject commit 69d295615bf4931493bfdc5213797be93ca18713
+Subproject commit dc9a055e94b3c343ed9ee0b3bd890a728f8484ac