The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(system): remove current_time tool and replace with resolve_time
Steven Enamakelc2448408c9c3
diff --git a/crates/openhuman-core/src/tools/impl/system/current_time.rs b/crates/openhuman-core/src/tools/impl/system/current_time.rsdeleted file mode 100644index 9df5cd0f4b..0000000000--- a/crates/openhuman-core/src/tools/impl/system/current_time.rs+++ /dev/null@@ -1,165 +0,0 @@-//! Tool: current_time — returns the current time in UTC and local time zones.-//!-//! Gives the orchestrator (and other agents) a way to ground reasoning that-//! depends on "now" — reminders, scheduling, relative date parsing — without-//! having to shell out to `date`. Read-only, no arguments beyond an optional-//! IANA timezone for a convenience conversion.--use async_trait::async_trait;-use chrono::{Local, SecondsFormat, Utc};-use chrono_tz::Tz;-use serde_json::json;-use tinytools::{PermissionLevel, Tool, ToolCallOptions, ToolResult};--pub struct CurrentTimeTool;--impl CurrentTimeTool {- pub fn new() -> Self {- Self- }-}--impl Default for CurrentTimeTool {- fn default() -> Self {- Self::new()- }-}--#[async_trait]-impl Tool for CurrentTimeTool {- fn name(&self) -> &str {- "current_time"- }-- fn description(&self) -> &str {- "Get the current date and time in UTC and the machine's local timezone. \- Optionally convert to a specific IANA timezone (e.g. 'America/Los_Angeles', \- 'Asia/Kolkata'). Use before scheduling reminders / cron jobs or when the \- user refers to relative times like 'in 10 minutes', 'tomorrow', 'tonight'."- }-- fn parameters_schema(&self) -> serde_json::Value {- json!({- "type": "object",- "properties": {- "timezone": {- "type": "string",- "description": "Optional IANA timezone name (e.g. 'Europe/London'). \- If omitted, only UTC and machine-local are returned."- }- }- })- }-- fn permission_level(&self) -> PermissionLevel {- PermissionLevel::ReadOnly- }-- fn supports_markdown(&self) -> bool {- true- }-- async fn execute(&self, args: serde_json::Value) -> anyhow::Result<ToolResult> {- self.execute_with_options(args, ToolCallOptions::default())- .await- }-- async fn execute_with_options(- &self,- args: serde_json::Value,- options: ToolCallOptions,- ) -> anyhow::Result<ToolResult> {- tracing::debug!(args = %args, "[current_time] execute start");- let now_utc = Utc::now();- let now_local = Local::now();-- let mut payload = json!({- "utc": now_utc.to_rfc3339_opts(SecondsFormat::Secs, true),- "local": now_local.to_rfc3339_opts(SecondsFormat::Secs, true),- "local_timezone": now_local.format("%Z").to_string(),- "unix_seconds": now_utc.timestamp(),- "weekday": now_local.format("%A").to_string(),- });-- if let Some(tz_name) = args.get("timezone").and_then(|v| v.as_str()) {- let trimmed = tz_name.trim();- tracing::debug!(- tz_name = tz_name,- trimmed = trimmed,- now_utc = %now_utc,- now_local = %now_local,- "[current_time] normalized timezone input"- );- if !trimmed.is_empty() {- match trimmed.parse::<Tz>() {- Ok(tz) => {- let converted = now_utc.with_timezone(&tz);- tracing::debug!(- trimmed = trimmed,- converted = %converted,- "[current_time] timezone conversion succeeded"- );- payload["requested_timezone"] = json!({- "name": trimmed,- "time": converted.to_rfc3339_opts(SecondsFormat::Secs, true),- "weekday": converted.format("%A").to_string(),- });- }- Err(error) => {- tracing::debug!(- trimmed = trimmed,- error = %error,- "[current_time] timezone conversion failed"- );- payload["requested_timezone_error"] = json!(format!(- "Unknown IANA timezone '{trimmed}' — use names like 'America/Los_Angeles'."- ));- }- }- }- }-- tracing::debug!("[current_time] returning payload: {payload}");- let mut result = ToolResult::success(serde_json::to_string_pretty(&payload)?);- if options.prefer_markdown {- let mut md = String::new();- md.push_str(&format!(- "- **utc**: {}\n",- payload["utc"].as_str().unwrap_or("")- ));- md.push_str(&format!(- "- **local**: {} ({})\n",- payload["local"].as_str().unwrap_or(""),- payload["local_timezone"].as_str().unwrap_or("")- ));- md.push_str(&format!(- "- **weekday**: {}\n",- payload["weekday"].as_str().unwrap_or("")- ));- md.push_str(&format!(- "- **unix_seconds**: {}\n",- payload["unix_seconds"].as_i64().unwrap_or(0)- ));- if let Some(rt) = payload.get("requested_timezone") {- md.push_str(&format!(- "- **{}**: {} ({})\n",- rt["name"].as_str().unwrap_or(""),- rt["time"].as_str().unwrap_or(""),- rt["weekday"].as_str().unwrap_or("")- ));- }- if let Some(err) = payload- .get("requested_timezone_error")- .and_then(|v| v.as_str())- {- md.push_str(&format!("- **timezone error**: {err}\n"));- }- result.markdown_formatted = Some(md);- }- Ok(result)- }-}--#[cfg(test)]-#[path = "current_time_tests.rs"]-mod tests;diff --git a/crates/openhuman-core/src/tools/impl/system/current_time_tests.rs b/crates/openhuman-core/src/tools/impl/system/current_time_tests.rsdeleted file mode 100644index 3cee8c8307..0000000000--- a/crates/openhuman-core/src/tools/impl/system/current_time_tests.rs+++ /dev/null@@ -1,51 +0,0 @@-use super::*;--#[test]-fn name_and_permission() {- let tool = CurrentTimeTool::new();- assert_eq!(tool.name(), "current_time");- assert_eq!(tool.permission_level(), PermissionLevel::ReadOnly);-}--#[test]-fn schema_is_object() {- let schema = CurrentTimeTool::new().parameters_schema();- assert_eq!(schema["type"], "object");-}--#[tokio::test]-async fn returns_utc_and_local() {- let result = CurrentTimeTool::new().execute(json!({})).await.unwrap();- assert!(!result.is_error);- let payload: serde_json::Value = serde_json::from_str(&result.output()).unwrap();- assert!(payload["utc"].is_string());- assert!(payload["local"].is_string());- assert!(payload["unix_seconds"].is_number());-}--#[tokio::test]-async fn converts_requested_timezone() {- let result = CurrentTimeTool::new()- .execute(json!({ "timezone": "Asia/Kolkata" }))- .await- .unwrap();- assert!(!result.is_error);- let payload: serde_json::Value = serde_json::from_str(&result.output()).unwrap();- assert!(payload["requested_timezone"].is_object());- assert!(payload["requested_timezone"]["name"].is_string());- assert!(payload["requested_timezone"]["name"]- .as_str()- .unwrap()- .contains("Asia/Kolkata"));-}--#[tokio::test]-async fn unknown_timezone_reports_error_field() {- let result = CurrentTimeTool::new()- .execute(json!({ "timezone": "Not/AReal_Zone" }))- .await- .unwrap();- assert!(!result.is_error);- let payload: serde_json::Value = serde_json::from_str(&result.output()).unwrap();- assert!(payload["requested_timezone_error"].is_string());-}diff --git a/crates/openhuman-core/src/tools/impl/system/mod.rs b/crates/openhuman-core/src/tools/impl/system/mod.rsindex 404cdcce67..339ba34549 100644--- a/crates/openhuman-core/src/tools/impl/system/mod.rs+++ b/crates/openhuman-core/src/tools/impl/system/mod.rs@@ -5,7 +5,6 @@//! `SecurityPolicy` resolver that must stay in step with the `filesystem` copy.mod command_output;-mod current_time;mod detect_tools;mod insert_sql_record;mod install_tool;@@ -15,7 +14,6 @@ mod npm_exec;mod proxy_config;mod pushover;mod python_exec;-mod resolve_time;mod retrieve_tool_output;mod schedule;mod shell;@@ -28,7 +26,7 @@ use crate::security::policy::{TrustedAccess, TrustedRoot};use crate::security::SecurityPolicy;use tinytools::ToolRunContext;-pub use current_time::CurrentTimeTool;+pub use tinyagents_harness::tools::{CurrentTimeTool, ResolveTimeTool};pub use detect_tools::DetectToolsTool;pub use insert_sql_record::InsertSqlRecordTool;pub use install_tool::InstallToolTool;@@ -38,7 +36,6 @@ pub use npm_exec::NpmExecTool;pub use proxy_config::ProxyConfigTool;pub use pushover::PushoverTool;pub use python_exec::PythonExecTool;-pub use resolve_time::ResolveTimeTool;pub use retrieve_tool_output::RetrieveToolOutputTool;pub use schedule::ScheduleTool;pub use shell::ShellTool;diff --git a/crates/openhuman-core/src/tools/impl/system/resolve_time.rs b/crates/openhuman-core/src/tools/impl/system/resolve_time.rsdeleted file mode 100644index e8f9bdff2f..0000000000--- a/crates/openhuman-core/src/tools/impl/system/resolve_time.rs+++ /dev/null@@ -1,508 +0,0 @@-//! Tool: resolve_time — convert a relative or absolute time expression into an-//! exact timestamp in every format a downstream tool might want.-//!-//! Motivation: LLMs are unreliable at Unix-epoch arithmetic. A real incident-//! had the integrations agent compute "24 hours ago" as `1752189120`-//! (2025-07-10) instead of the intended 2026-06-09 — ~10 months off — then-//! fetch Slack history ascending from that wrong floor and never reach the-//! latest messages. `current_time` only returns *now*, so the agent still has-//! to subtract by hand; this tool does the resolution deterministically and-//! returns the value ready to paste into a tool argument-//! (`oldest`/`latest`/`since`/`after`, cron times, …).-//!-//! Read-only, no side effects. Accepts durations, conversational calendar-//! phrases, and ISO dates/timestamps. Bare durations look backward; `in` and-//! `next` look forward. Civil dates and clock times use the requested timezone.-//!-//! Returns every common representation so the caller can pick the one the-//! target tool's schema wants:-//! - `unix_s` — Unix seconds (integer)-//! - `unix_ms` — Unix milliseconds (integer)-//! - `slack_ts` — Slack `conversations.history` style `"<secs>.000000"`-//! - `rfc3339` — `"2026-06-09T19:12:00+00:00"`-//! - `value` — Unix seconds as a string for copy-paste; legacy callers-//! may still select another representation with `format`.--use async_trait::async_trait;-use chrono::{- DateTime, Datelike, Duration, Local, NaiveDate, NaiveDateTime, NaiveTime, SecondsFormat, Utc,- Weekday,-};-use chrono_tz::Tz;-use serde_json::json;-use tinytools::{PermissionLevel, Tool, ToolCallOptions, ToolResult};--pub struct ResolveTimeTool;--impl ResolveTimeTool {- pub fn new() -> Self {- Self- }-}--impl Default for ResolveTimeTool {- fn default() -> Self {- Self::new()- }-}--/// Parse a relative-duration expression into a **signed** [`Duration`] offset-/// from now: negative = the past, positive = the future.-///-/// Direction comes from `ago`, `last`, `past`, or `-` for the past and `in`,-/// `next`, `from now`, or `+` for the future. A bare duration looks backward.-///-/// Getting the sign right matters: `scheduler_agent` passes future phrasing-/// like `"in 10 minutes"`, which must resolve forward, not backward.-fn parse_relative_duration(raw: &str) -> Option<Duration> {- let mut s = raw.trim().to_ascii_lowercase();- let mut future = false;-- // Suffix direction markers.- if let Some(rest) = s.strip_suffix(" ago") {- s = rest.trim().to_string();- } else if let Some(rest) = s.strip_suffix(" from now") {- future = true;- s = rest.trim().to_string();- }- // Prefix direction markers (first match wins).- for (prefix, is_future) in [- ("in ", true),- ("next ", true),- ("last ", false),- ("past ", false),- ] {- if let Some(rest) = s.strip_prefix(prefix) {- future = is_future;- s = rest.trim().to_string();- break;- }- }- if let Some(rest) = s.strip_prefix('+') {- future = true;- s = rest.trim().to_string();- } else if let Some(rest) = s.strip_prefix('-') {- // Leading '-' is the past — which is already the default — just strip it.- s = rest.trim().to_string();- }-- // Split both "2 hours 30 minutes" and "2h30m" into number/unit pairs.- let mut tokens = Vec::new();- let mut current = String::new();- let mut was_digit = None;- for c in s.chars() {- if c.is_ascii_digit() || c.is_ascii_alphabetic() {- let is_digit = c.is_ascii_digit();- if was_digit.is_some_and(|previous| previous != is_digit) && !current.is_empty() {- tokens.push(std::mem::take(&mut current));- }- current.push(c);- was_digit = Some(is_digit);- } else if c.is_whitespace() || c == ',' {- if !current.is_empty() {- tokens.push(std::mem::take(&mut current));- }- was_digit = None;- } else {- return None;- }- }- if !current.is_empty() {- tokens.push(current);- }- let mut parts = tokens.into_iter().filter(|token| token != "and");- let mut seconds = 0_i64;- let mut any = false;- while let Some(number) = parts.next() {- let n: i64 = number.parse().ok()?;- let unit = parts.next()?;- let secs_per = match unit.as_str() {- "s" | "sec" | "secs" | "second" | "seconds" => 1,- "m" | "min" | "mins" | "minute" | "minutes" => 60,- "h" | "hr" | "hrs" | "hour" | "hours" => 3_600,- "d" | "day" | "days" => 86_400,- "w" | "wk" | "wks" | "week" | "weeks" => 604_800,- _ => return None,- };- seconds = seconds.checked_add(n.checked_mul(secs_per)?)?;- any = true;- }- if !any {- return None;- }- let magnitude = Duration::try_seconds(seconds)?;- Some(if future { magnitude } else { -magnitude })-}--/// Resolve `expr` to an absolute UTC instant. `zone` interprets civil-/// inputs (`today`, `yesterday`, bare dates without an explicit offset).-fn parse_weekday(name: &str) -> Option<Weekday> {- match name {- "monday" | "mon" => Some(Weekday::Mon),- "tuesday" | "tue" | "tues" => Some(Weekday::Tue),- "wednesday" | "wed" => Some(Weekday::Wed),- "thursday" | "thu" | "thur" | "thurs" => Some(Weekday::Thu),- "friday" | "fri" => Some(Weekday::Fri),- "saturday" | "sat" => Some(Weekday::Sat),- "sunday" | "sun" => Some(Weekday::Sun),- _ => None,- }-}--fn parse_clock_time(raw: &str) -> Option<NaiveTime> {- let compact = raw- .trim()- .trim_start_matches("at ")- .replace([' ', '.'], "")- .to_ascii_uppercase();- match compact.as_str() {- "NOON" => return NaiveTime::from_hms_opt(12, 0, 0),- "MIDNIGHT" => return NaiveTime::from_hms_opt(0, 0, 0),- _ => {}- }- let (clock, meridiem) = if let Some(clock) = compact.strip_suffix("AM") {- (clock, Some(false))- } else if let Some(clock) = compact.strip_suffix("PM") {- (clock, Some(true))- } else {- (compact.as_str(), None)- };- let parts: Vec<&str> = clock.split(':').collect();- if parts.is_empty() || parts.len() > 3 {- return None;- }- let mut hour: u32 = parts[0].parse().ok()?;- let minute: u32 = parts.get(1).map_or(Some(0), |s| s.parse().ok())?;- let second: u32 = parts.get(2).map_or(Some(0), |s| s.parse().ok())?;- if let Some(pm) = meridiem {- if !(1..=12).contains(&hour) {- return None;- }- hour = hour % 12 + if pm { 12 } else { 0 };- }- NaiveTime::from_hms_opt(hour, minute, second)-}--/// A calendar phrase may be a day on its own or a day plus a clock time.-/// Unqualified weekdays refer to the most recent occurrence, which makes-/// "since Monday" useful for history queries; "next" is always in the future.-fn resolve_calendar_phrase(- lower: &str,- zone: &ResolveZone,- now: DateTime<Utc>,-) -> Option<Result<DateTime<Utc>, String>> {- let words: Vec<&str> = lower.split_whitespace().collect();- let first = *words.first()?;- let anchor_len = if matches!(first, "last" | "next" | "this" | "since")- && words- .get(1)- .is_some_and(|word| parse_weekday(word).is_some())- {- 2- } else if matches!(first, "today" | "tomorrow" | "yesterday" | "tonight")- || parse_weekday(first).is_some()- {- 1- } else {- return None;- };- let anchor = words[..anchor_len].join(" ");- let time_words = words[anchor_len..].join(" ");- let time = if time_words.is_empty() {- // "Tonight" is a period, not an exact instant. Require a clock time- // rather than silently inventing one for a reminder.- if anchor == "tonight" {- return None;- }- NaiveTime::from_hms_opt(0, 0, 0)?- } else {- parse_clock_time(&time_words)?- };- let today = zone.civil_date(now);- let date = match anchor.as_str() {- "today" => today,- "tonight" if time == NaiveTime::from_hms_opt(0, 0, 0)? => today + Duration::days(1),- "tonight" => today,- "yesterday" => today - Duration::days(1),- "tomorrow" => today + Duration::days(1),- _ => {- let (direction, weekday_name) = anchor- .split_once(' ')- .map_or(("since", anchor.as_str()), |(a, b)| (a, b));- let weekday = parse_weekday(weekday_name)?;- let current = today.weekday().num_days_from_monday() as i64;- let target = weekday.num_days_from_monday() as i64;- let days = match direction {- "next" => {- let ahead = (target - current).rem_euclid(7);- if ahead == 0 {- 7- } else {- ahead- }- }- "this" => target - current,- "last" => {- let behind = (current - target).rem_euclid(7);- if behind == 0 {- -7- } else {- -behind- }- }- _ => -(current - target).rem_euclid(7),- };- today + Duration::days(days)- }- };- Some(zone.naive_to_utc(date.and_time(time)))-}--fn resolve_expr(expr: &str, zone: ResolveZone) -> Result<DateTime<Utc>, String> {- resolve_expr_at(expr, zone, Utc::now())-}--fn resolve_expr_at(- expr: &str,- zone: ResolveZone,- now: DateTime<Utc>,-) -> Result<DateTime<Utc>, String> {- let trimmed = expr.trim();- if trimmed.is_empty() {- return Err(- "`expr` is required (e.g. \"24h ago\", \"2026-06-09T19:12:00Z\", \"now\").".into(),- );- }- let lower = trimmed.to_ascii_lowercase();-- if lower == "now" {- return Ok(now);- }-- // Relative duration → signed offset from now (sign encodes past/future).- if let Some(dur) = parse_relative_duration(trimmed) {- return now- .checked_add_signed(dur)- .ok_or_else(|| "relative time is outside the supported date range".to_string());- }-- if let Some(result) = resolve_calendar_phrase(&lower, &zone, now) {- return result;- }-- // RFC-3339 / ISO-8601 with explicit offset (e.g. ...Z, +05:30).- if let Ok(dt) = DateTime::parse_from_rfc3339(trimmed) {- return Ok(dt.with_timezone(&Utc));- }-- // "YYYY-MM-DD HH:MM:SS" or "YYYY-MM-DDTHH:MM:SS" (no offset) → resolve in zone.- for fmt in ["%Y-%m-%d %H:%M:%S", "%Y-%m-%dT%H:%M:%S", "%Y-%m-%d %H:%M"] {- if let Ok(naive) = NaiveDateTime::parse_from_str(trimmed, fmt) {- return zone.naive_to_utc(naive);- }- }-- // Bare date "YYYY-MM-DD" → civil midnight in zone.- if let Ok(date) = NaiveDate::parse_from_str(trimmed, "%Y-%m-%d") {- return zone.civil_midnight_to_utc(date);- }-- // Date with a conversational clock time, e.g. "2026-06-09 at 9am".- if let Some((date_text, clock_text)) = trimmed.split_once(' ') {- if let (Ok(date), Some(time)) = (- NaiveDate::parse_from_str(date_text, "%Y-%m-%d"),- parse_clock_time(clock_text),- ) {- return zone.naive_to_utc(date.and_time(time));- }- }-- // Accept time-first forms too: "11pm tonight", "9am next Friday".- let words: Vec<&str> = lower.split_whitespace().collect();- for anchor_len in [2, 1] {- if words.len() > anchor_len {- let split = words.len() - anchor_len;- let clock = words[..split].join(" ");- if parse_clock_time(&clock).is_some() {- let reordered = format!("{} {clock}", words[split..].join(" "));- if let Some(result) = resolve_calendar_phrase(&reordered, &zone, now) {- return result;- }- }- }- }-- Err(format!(- "could not parse {trimmed:?}; try 'last 24 hours', 'tomorrow at 9am', \- 'since Monday', or an ISO date/time."- ))-}--/// Zone used to interpret civil (offset-less) inputs.-enum ResolveZone {- /// Machine-local timezone (the default, matching `current_time`).- Local,- /// An explicit IANA zone supplied by the caller.- Iana(Tz),-}--impl ResolveZone {- fn civil_date(&self, now: DateTime<Utc>) -> NaiveDate {- match self {- ResolveZone::Local => now.with_timezone(&Local).date_naive(),- ResolveZone::Iana(tz) => now.with_timezone(tz).date_naive(),- }- }-- fn civil_midnight_to_utc(&self, date: NaiveDate) -> Result<DateTime<Utc>, String> {- let naive = date- .and_hms_opt(0, 0, 0)- .ok_or_else(|| "invalid civil midnight".to_string())?;- self.naive_to_utc(naive)- }-- /// Interpret a naive (offset-less) datetime in this zone and convert to UTC.- fn naive_to_utc(&self, naive: NaiveDateTime) -> Result<DateTime<Utc>, String> {- use chrono::TimeZone;- match self {- ResolveZone::Local => Local- .from_local_datetime(&naive)- .single()- .map(|dt| dt.with_timezone(&Utc))- .ok_or_else(|| format!("ambiguous or invalid local time {naive} (DST boundary?)")),- ResolveZone::Iana(tz) => tz- .from_local_datetime(&naive)- .single()- .map(|dt| dt.with_timezone(&Utc))- .ok_or_else(|| {- format!("ambiguous or invalid time {naive} in {tz:?} (DST boundary?)")- }),- }- }-}--#[async_trait]-impl Tool for ResolveTimeTool {- fn name(&self) -> &str {- "resolve_time"- }-- fn description(&self) -> &str {- "Turn a time phrase into exact timestamps. Accepts 'last 24 hours', \- 'in 10 minutes', 'since Monday', 'tomorrow at 9am', or an ISO date/time. \- Returns Unix seconds, milliseconds, Slack timestamp, and RFC-3339."- }-- fn parameters_schema(&self) -> serde_json::Value {- json!({- "type": "object",- "properties": {- "expr": {- "type": "string",- "description": "Time phrase or ISO date/time, e.g. 'tomorrow at 9am'."- },- "timezone": {- "type": "string",- "description": "IANA timezone for dates without an offset; defaults to local."- }- },- "required": ["expr"]- })- }-- fn permission_level(&self) -> PermissionLevel {- PermissionLevel::ReadOnly- }-- fn supports_markdown(&self) -> bool {- true- }-- async fn execute(&self, args: serde_json::Value) -> anyhow::Result<ToolResult> {- self.execute_with_options(args, ToolCallOptions::default())- .await- }-- async fn execute_with_options(- &self,- args: serde_json::Value,- options: ToolCallOptions,- ) -> anyhow::Result<ToolResult> {- tracing::debug!(args = %args, "[resolve_time] execute start");-- let expr = match args.get("expr").and_then(|v| v.as_str()) {- Some(s) => s,- None => {- return Ok(ToolResult::error(- "resolve_time: `expr` is required (e.g. \"24h ago\", \- \"2026-06-09T19:12:00Z\", \"now\").",- ));- }- };-- // Resolve the interpretation zone for civil inputs.- let zone = match args.get("timezone").and_then(|v| v.as_str()) {- Some(tz_name) if !tz_name.trim().is_empty() => match tz_name.trim().parse::<Tz>() {- Ok(tz) => ResolveZone::Iana(tz),- Err(_) => {- return Ok(ToolResult::error(format!(- "resolve_time: unknown IANA timezone '{}' — use names like \- 'America/Los_Angeles'.",- tz_name.trim()- )));- }- },- _ => ResolveZone::Local,- };-- let dt = match resolve_expr(expr, zone) {- Ok(dt) => dt,- Err(e) => {- tracing::debug!(expr = expr, error = %e, "[resolve_time] parse failed");- return Ok(ToolResult::error(format!("resolve_time: {e}")));- }- };-- let unix_s = dt.timestamp();- let unix_ms = dt.timestamp_millis();- let slack_ts = format!("{unix_s}.000000");- let rfc3339 = dt.to_rfc3339_opts(SecondsFormat::Secs, true);-- let format = args- .get("format")- .and_then(|v| v.as_str())- .map(str::trim)- .filter(|s| !s.is_empty())- .unwrap_or("unix_s");- let value = match format {- "unix_ms" => unix_ms.to_string(),- "slack_ts" => slack_ts.clone(),- "rfc3339" => rfc3339.clone(),- _ => unix_s.to_string(),- };-- let payload = json!({- "interpreted": expr,- "value": value,- "unix_s": unix_s,- "unix_ms": unix_ms,- "slack_ts": slack_ts,- "rfc3339": rfc3339,- });-- tracing::debug!("[resolve_time] resolved {expr:?} -> {rfc3339} (unix_s={unix_s})");- let mut result = ToolResult::success(serde_json::to_string_pretty(&payload)?);- if options.prefer_markdown {- result.markdown_formatted = Some(format!(- "- **interpreted**: {expr}\n- **value** ({format}): {value}\n- **unix_s**: \- {unix_s}\n- **unix_ms**: {unix_ms}\n- **slack_ts**: {slack_ts}\n- **rfc3339**: \- {rfc3339}\n"- ));- }- Ok(result)- }-}--#[cfg(test)]-#[path = "resolve_time_tests.rs"]-mod tests;diff --git a/crates/openhuman-core/src/tools/impl/system/resolve_time_tests.rs b/crates/openhuman-core/src/tools/impl/system/resolve_time_tests.rsdeleted file mode 100644index e9758d964b..0000000000--- a/crates/openhuman-core/src/tools/impl/system/resolve_time_tests.rs+++ /dev/null@@ -1,240 +0,0 @@-use super::*;--#[test]-fn name_and_permission() {- let tool = ResolveTimeTool::new();- assert_eq!(tool.name(), "resolve_time");- assert_eq!(tool.permission_level(), PermissionLevel::ReadOnly);-}--#[test]-fn schema_requires_expr() {- let schema = ResolveTimeTool::new().parameters_schema();- assert_eq!(schema["type"], "object");- assert_eq!(schema["required"][0], "expr");- assert!(schema["properties"].get("format").is_none());-}--#[test]-fn past_variants_resolve_to_a_negative_offset() {- // Past phrasing (and bare durations, which default to the past) yield a- // NEGATIVE offset so `now + dur` looks backward.- for s in [- "24h ago",- "last 24 hours",- "past 24 hours",- "-24h",- "24 hours ago",- "24h",- ] {- let d = parse_relative_duration(s).unwrap_or_else(|| panic!("failed: {s}"));- assert_eq!(d.num_seconds(), -86_400, "{s}");- }- assert_eq!(- parse_relative_duration("7d").unwrap().num_seconds(),- -604_800- );- assert_eq!(- parse_relative_duration("2 weeks").unwrap().num_seconds(),- -1_209_600- );- assert_eq!(parse_relative_duration("15m").unwrap().num_seconds(), -900);- assert_eq!(- parse_relative_duration("30 days").unwrap().num_seconds(),- -2_592_000- );-}--#[test]-fn future_variants_resolve_to_a_positive_offset() {- // Regression for the CodeRabbit catch: future phrasing must look- // FORWARD (positive offset), not backward — scheduler_agent relies on- // "in 10 minutes" / "30m from now".- assert_eq!(- parse_relative_duration("in 10 minutes")- .unwrap()- .num_seconds(),- 600- );- assert_eq!(- parse_relative_duration("30m from now")- .unwrap()- .num_seconds(),- 1_800- );- assert_eq!(parse_relative_duration("+2h").unwrap().num_seconds(), 7_200);- assert_eq!(- parse_relative_duration("next 7d").unwrap().num_seconds(),- 604_800- );-}--#[test]-fn combined_durations_are_accepted() {- assert_eq!(- parse_relative_duration("1 hour and 30 minutes ago")- .unwrap()- .num_seconds(),- -5_400- );- assert_eq!(- parse_relative_duration("in 2h30m").unwrap().num_seconds(),- 9_000- );- assert!(parse_relative_duration("in 2 hours and nonsense").is_none());-}--#[test]-fn conversational_dates_resolve_in_the_requested_timezone() {- let zone: Tz = "Asia/Kolkata".parse().unwrap();- let now = DateTime::parse_from_rfc3339("2026-01-07T12:00:00Z")- .unwrap()- .with_timezone(&Utc);- for (expr, expected) in [- ("tomorrow 9am", "2026-01-08T03:30:00Z"),- ("next Friday at 3:30 pm", "2026-01-09T10:00:00Z"),- ("since Monday", "2026-01-04T18:30:00Z"),- ("last Wednesday", "2025-12-30T18:30:00Z"),- ("2026-01-09 at 9am", "2026-01-09T03:30:00Z"),- ("11 PM tonight", "2026-01-07T17:30:00Z"),- ("tonight at midnight", "2026-01-07T18:30:00Z"),- ("9am next Friday", "2026-01-09T03:30:00Z"),- ("tomorrow at noon", "2026-01-08T06:30:00Z"),- ] {- let actual = resolve_expr_at(expr, ResolveZone::Iana(zone), now).unwrap();- assert_eq!(- actual.to_rfc3339_opts(SecondsFormat::Secs, true),- expected,- "{expr}"- );- }- assert!(resolve_expr_at("tonight", ResolveZone::Iana(zone), now).is_err());-}--#[test]-fn rejects_non_durations() {- assert!(parse_relative_duration("now").is_none());- assert!(parse_relative_duration("2026-06-09").is_none());- assert!(parse_relative_duration("h").is_none());- assert!(parse_relative_duration("24 lightyears").is_none());-}--#[test]-fn resolves_rfc3339_to_exact_utc() {- let dt = resolve_expr("2026-06-09T19:12:00Z", ResolveZone::Local).unwrap();- // The exact epoch the real incident's agent miscomputed as 1752189120.- assert_eq!(dt.timestamp(), 1_781_032_320);-}--#[test]-fn relative_is_close_to_now_minus_offset() {- let before = Utc::now().timestamp();- let dt = resolve_expr("24h ago", ResolveZone::Local).unwrap();- let after = Utc::now().timestamp();- let expected_lo = before - 86_400 - 2;- let expected_hi = after - 86_400 + 2;- assert!(- dt.timestamp() >= expected_lo && dt.timestamp() <= expected_hi,- "got {}, expected ~[{expected_lo},{expected_hi}]",- dt.timestamp()- );-}--#[test]-fn future_relative_resolves_forward() {- // "in 10 minutes" must land ~600s in the FUTURE (the bug fix).- let before = Utc::now().timestamp();- let dt = resolve_expr("in 10 minutes", ResolveZone::Local).unwrap();- let after = Utc::now().timestamp();- assert!(- dt.timestamp() >= before + 600 - 2 && dt.timestamp() <= after + 600 + 2,- "got {}, expected ~now+600",- dt.timestamp()- );-}--#[test]-fn tomorrow_is_after_today_after_yesterday() {- let tz: Tz = "Asia/Kolkata".parse().unwrap();- let y = resolve_expr("yesterday", ResolveZone::Iana(tz)).unwrap();- let t = resolve_expr("today", ResolveZone::Iana(tz)).unwrap();- let m = resolve_expr("tomorrow", ResolveZone::Iana(tz)).unwrap();- assert!(y < t && t < m, "ordering broken: {y} {t} {m}");- // Consecutive civil days are exactly 24h apart.- assert_eq!((t - y).num_seconds(), 86_400);- assert_eq!((m - t).num_seconds(), 86_400);-}--#[test]-fn now_resolves() {- let dt = resolve_expr("now", ResolveZone::Local).unwrap();- assert!((dt.timestamp() - Utc::now().timestamp()).abs() <= 2);-}--#[test]-fn bare_date_in_explicit_zone() {- // 2026-06-09 00:00 in Asia/Kolkata (UTC+5:30) == 2026-06-08T18:30:00Z.- let tz: Tz = "Asia/Kolkata".parse().unwrap();- let dt = resolve_expr("2026-06-09", ResolveZone::Iana(tz)).unwrap();- assert_eq!(- dt.to_rfc3339_opts(SecondsFormat::Secs, true),- "2026-06-08T18:30:00Z"- );-}--#[test]-fn unparseable_expr_errors() {- assert!(resolve_expr("sometime next quarter", ResolveZone::Local).is_err());- assert!(resolve_expr("", ResolveZone::Local).is_err());-}--#[tokio::test]-async fn execute_returns_all_formats() {- let result = ResolveTimeTool::new()- .execute(json!({ "expr": "2026-06-09T19:12:00Z" }))- .await- .unwrap();- assert!(!result.is_error);- let payload: serde_json::Value = serde_json::from_str(&result.output()).unwrap();- assert_eq!(payload["unix_s"], 1_781_032_320_i64);- assert_eq!(payload["unix_ms"], 1_781_032_320_000_i64);- assert_eq!(payload["slack_ts"], "1781032320.000000");- assert_eq!(payload["value"], "1781032320"); // default format = unix_s-}--#[tokio::test]-async fn execute_format_selects_value() {- let result = ResolveTimeTool::new()- .execute(json!({ "expr": "2026-06-09T19:12:00Z", "format": "slack_ts" }))- .await- .unwrap();- let payload: serde_json::Value = serde_json::from_str(&result.output()).unwrap();- assert_eq!(payload["value"], "1781032320.000000");-}--#[tokio::test]-async fn execute_missing_expr_errors() {- let result = ResolveTimeTool::new().execute(json!({})).await.unwrap();- assert!(result.is_error);- assert!(result.output().contains("`expr` is required"));-}--#[tokio::test]-async fn execute_bad_timezone_errors() {- let result = ResolveTimeTool::new()- .execute(json!({ "expr": "today", "timezone": "Not/AZone" }))- .await- .unwrap();- assert!(result.is_error);- assert!(result.output().contains("unknown IANA timezone"));-}--#[tokio::test]-async fn execute_rejects_out_of_range_duration_without_panicking() {- let result = ResolveTimeTool::new()- .execute(json!({ "expr": "in 9223372036854776s" }))- .await- .unwrap();- assert!(result.is_error);- assert!(result.output().contains("could not parse"));-}diff --git a/tests/raw_coverage/composio_raw_coverage_e2e.rs b/tests/raw_coverage/composio_raw_coverage_e2e.rsindex d57b7b06f0..f6f43237aa 100644--- a/tests/raw_coverage/composio_raw_coverage_e2e.rs+++ b/tests/raw_coverage/composio_raw_coverage_e2e.rs@@ -18,20 +18,12 @@ use openhuman_core::agent::prompts::ConnectedIntegration;use openhuman_core::config::Config;use openhuman_core::core::all::RegisteredController;use openhuman_core::integrations::composio::client::{- create_composio_client, direct_execute, ComposioClientKind,+ create_composio_client, ComposioClientKind,};use openhuman_core::integrations::composio::error_mapping::{classify_composio_error, format_provider_error, remap_transport_error, ComposioErrorClass,};-use openhuman_core::integrations::composio::execute_dispatch::{- execute_composio_action, execute_composio_action_kind,-};use openhuman_core::integrations::composio::execute_prepare::prepare_execute_arguments;-use openhuman_core::integrations::composio::oauth_handoff::{- clear_non_active_connections, is_authorize_rate_limited, is_clearable_oauth_status,- is_inflight_oauth_status, is_meta_oauth_toolkit, meta_oauth_rate_limit_message,- wrap_authorize_rate_limit_error,-};use openhuman_core::integrations::composio::providers::{classify_unknown, find_curated, toolkit_from_slug, CuratedTool, ToolScope, UserScopePref,};@@ -258,48 +250,6 @@ fn composio_error_mapping_classifies_and_formats_provider_failures() {assert!(validation_transport.starts_with("[composio:error:validation]"));}-#[test]-fn composio_oauth_handoff_helpers_classify_meta_status_and_rate_limits() {- crate::tinyhumans_boot::boot();- assert!(is_meta_oauth_toolkit(" Instagram "));- assert!(is_meta_oauth_toolkit("FACEBOOK"));- assert!(!is_meta_oauth_toolkit("gmail"));-- for status in ["pending", "INITIATED", " initializing "] {- assert!(- is_inflight_oauth_status(status),- "{status} should be inflight"- );- assert!(- is_clearable_oauth_status(status),- "{status} should be clearable"- );- }- for status in ["failed", "ERROR", " expired "] {- assert!(!is_inflight_oauth_status(status));- assert!(is_clearable_oauth_status(status));- }- assert!(!is_clearable_oauth_status("ACTIVE"));-- for message in ["HTTP 429", "too many requests", "rate_limit", "ratelimited"] {- assert!(is_authorize_rate_limited(message));- }- assert!(!is_authorize_rate_limited("plain auth failure"));-- let instagram = meta_oauth_rate_limit_message("instagram");- assert!(instagram.contains("Instagram Business or Creator"));- let facebook = meta_oauth_rate_limit_message("facebook");- assert!(facebook.contains("Business Manager"));- let unknown = meta_oauth_rate_limit_message("threads");- assert!(!unknown.contains("Business Manager"));-- let wrapped =- wrap_authorize_rate_limit_error("instagram", anyhow::anyhow!("429 too many requests"));- assert!(wrapped.to_string().contains("temporarily rate-limiting"));- let passthrough = wrap_authorize_rate_limit_error("gmail", anyhow::anyhow!("429"));- assert_eq!(passthrough.to_string(), "429");-}-#[tokio::test]async fn composio_connected_integrations_public_helpers_handle_empty_auth_and_identity_edges() {crate::tinyhumans_boot::boot();@@ -511,10 +461,6 @@ async fn composio_client_and_dispatch_reject_invalid_inputs_before_network() {assert!(delete_empty.to_string().contains("connectionId must not be empty"));- let execute_empty = client.execute_tool("\t", None).await.unwrap_err();- assert!(execute_empty- .to_string()- .contains("tool slug must not be empty"));let create_empty = client.create_trigger(" ", None, None).await.unwrap_err();assert!(create_empty.to_string().contains("slug must not be empty"));let available_empty = client@@ -543,37 +489,8 @@ async fn composio_client_and_dispatch_reject_invalid_inputs_before_network() {.to_string().contains("triggerId must not be empty"));- let dispatch_empty = execute_composio_action(&client, " ", None)- .await- .unwrap_err();- assert!(dispatch_empty.contains("tool slug must not be empty"));- let dispatch_validation = execute_composio_action(- &client,- "GMAIL_SEND_EMAIL",- Some(json!({ "subject": "missing recipient" })),- )- .await- .unwrap_err();- assert!(dispatch_validation.starts_with("[composio:error:"));- assert!(dispatch_validation.contains("recipient"));-- let backend_kind = ComposioClientKind::Backend(client.clone());+ let backend_kind = ComposioClientKind::Backend(client);assert_eq!(backend_kind.mode(), "backend");- let kind_empty = execute_composio_action_kind(backend_kind, " ", None, "entity")- .await- .unwrap_err();- assert!(kind_empty.contains("tool slug must not be empty"));-- let kind_validation = execute_composio_action_kind(- ComposioClientKind::Backend(client),- "GMAIL_SEND_EMAIL",- Some(json!({ "subject": "missing recipient" })),- "entity",- )- .await- .unwrap_err();- assert!(kind_validation.starts_with("[composio:error:"));- assert!(kind_validation.contains("recipient"));let direct_tool = Arc::new(ComposioTool::new("direct-key",@@ -582,16 +499,6 @@ async fn composio_client_and_dispatch_reject_invalid_inputs_before_network() {));let direct_kind = ComposioClientKind::Direct(direct_tool);assert_eq!(direct_kind.mode(), "direct");- let direct_validation = execute_composio_action_kind(- direct_kind,- "GMAIL_SEND_EMAIL",- Some(json!({ "subject": "still missing recipient" })),- "entity-1",- )- .await- .expect_err("direct dispatch validates before network");- assert!(direct_validation.starts_with("[composio:error:"));- assert!(direct_validation.contains("recipient"));}#[test]@@ -669,12 +576,6 @@ async fn composio_backend_client_local_validation_rejects_bad_inputs_before_http.expect_err("blank connection id should fail before HTTP");assert!(blank_delete.to_string().contains("connectionId"));- let blank_execute = client- .execute_tool(" ", Some(json!({})))- .await- .expect_err("blank tool should fail before HTTP");- assert!(blank_execute.to_string().contains("tool slug"));-let blank_create = client.create_trigger(" ", None, None).await@@ -704,16 +605,6 @@ async fn composio_backend_client_local_validation_rejects_bad_inputs_before_http.await.expect_err("blank trigger id should fail before HTTP");assert!(blank_disable.to_string().contains("triggerId"));-- let direct_tool = Arc::new(ComposioTool::new(- "direct-api-key",- Some("entity-1"),- Arc::new(SecurityPolicy::default()),- ));- let blank_direct_execute = direct_execute(&direct_tool, " ", None, "entity-1", None)- .await- .expect_err("blank direct tool should fail before HTTP");- assert!(blank_direct_execute.to_string().contains("tool slug"));}#[tokio::test]