fix(routines): run cron checks immediately on ticker startup (#1066)

* fix(routines): run cron check immediately at ticker startup

* test/ci: add routine_engine test and fix style lint drift
This commit is contained in:
Nige
2026-03-12 15:04:21 -07:00
committed by GitHub
parent 442a42d996
commit 7a9cbb3b50
2 changed files with 31 additions and 2 deletions
+11 -2
View File
@@ -1150,9 +1150,11 @@ pub fn spawn_cron_ticker(
interval: Duration,
) -> tokio::task::JoinHandle<()> {
tokio::spawn(async move {
// Run one check immediately so routines due at startup don't wait
// an extra full polling interval.
engine.check_cron_triggers().await;
let mut ticker = tokio::time::interval(interval);
// Skip immediate first tick
ticker.tick().await;
loop {
ticker.tick().await;
@@ -1358,4 +1360,11 @@ mod tests {
assert_eq!(finish_reason_length, crate::llm::FinishReason::Length);
assert_eq!(finish_reason_stop, crate::llm::FinishReason::Stop);
}
#[test]
fn test_truncate_adds_ellipsis_when_over_limit() {
let input = "abcdefghijk";
let out = super::truncate(input, 5);
assert_eq!(out, "abcde...");
}
}