Skip to content

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

feat(tools): add read timing and extract url from validation result

Steven Enamakel59dda575332f
diff --git a/crates/openhuman-core/src/tools/impl/filesystem/file_read.rs b/crates/openhuman-core/src/tools/impl/filesystem/file_read.rs
index 215ad28c00..69abbc15b5 100644
--- a/crates/openhuman-core/src/tools/impl/filesystem/file_read.rs
+++ b/crates/openhuman-core/src/tools/impl/filesystem/file_read.rs
@@ -130,6 +130,7 @@ impl FileReadTool {
}
}
+ let read_started = std::time::Instant::now();
match tokio::fs::read_to_string(&resolved_path).await {
Ok(contents) => {
if let Some(agent_id) = file_state::current_file_state_agent_id() {
@@ -138,7 +139,7 @@ impl FileReadTool {
.ok()
.and_then(|m| m.modified().ok())
.unwrap_or(std::time::SystemTime::UNIX_EPOCH);
- file_state::record_read(&agent_id, resolved_path, mtime, false);
+ file_state::record_read(&agent_id, resolved_path, mtime, false, read_started);
}
// An absent or null offset reads from the start; anything else
// that is not a non-negative integer is rejected, so a
diff --git a/crates/openhuman-core/src/tools/impl/network/curl.rs b/crates/openhuman-core/src/tools/impl/network/curl.rs
index f7e89ba7a6..a501a8e47b 100644
--- a/crates/openhuman-core/src/tools/impl/network/curl.rs
+++ b/crates/openhuman-core/src/tools/impl/network/curl.rs
@@ -86,7 +86,7 @@ impl CurlTool {
}
async fn validate_url(&self, raw_url: &str) -> anyhow::Result<String> {
- validate_url_with_dns_check(raw_url, &self.allowed_domains).await
+ validate_url_with_dns_check(raw_url, &self.allowed_domains).await.map(|v| v.url)
}
fn default_filename_from_url(url: &str) -> String {
diff --git a/crates/openhuman-core/src/tools/impl/network/http_request.rs b/crates/openhuman-core/src/tools/impl/network/http_request.rs
index a5f3bf7d14..e8360ec412 100644
--- a/crates/openhuman-core/src/tools/impl/network/http_request.rs
+++ b/crates/openhuman-core/src/tools/impl/network/http_request.rs
@@ -88,7 +88,7 @@ impl HttpRequestTool {
}
async fn validate_url(&self, raw_url: &str) -> anyhow::Result<String> {
- validate_url_with_dns_check(raw_url, &self.allowed_domains).await
+ validate_url_with_dns_check(raw_url, &self.allowed_domains).await.map(|v| v.url)
}
fn validate_method(&self, method: &str) -> anyhow::Result<reqwest::Method> {
diff --git a/crates/openhuman-core/src/tools/impl/network/web_fetch.rs b/crates/openhuman-core/src/tools/impl/network/web_fetch.rs
index 528d83e532..0909156c44 100644
--- a/crates/openhuman-core/src/tools/impl/network/web_fetch.rs
+++ b/crates/openhuman-core/src/tools/impl/network/web_fetch.rs
@@ -173,7 +173,7 @@ impl Tool for WebFetchTool {
}
let url = match validate_url_with_dns_check(raw_url, &self.allowed_domains).await {
- Ok(u) => u,
+ Ok(u) => u.url,
Err(e) => return Ok(ToolResult::error(format!("URL rejected: {e}"))),
};