Skip to content

feat(ai): web_fetch tool#964

Merged
ehayes2000 merged 8 commits intomainfrom
fetch-tool
Jan 13, 2026
Merged

feat(ai): web_fetch tool#964
ehayes2000 merged 8 commits intomainfrom
fetch-tool

Conversation

@ehayes2000
Copy link
Copy Markdown
Contributor

  • dog anthropic doesn't work
  • backend working-ish
  • tool renderer

@ehayes2000 ehayes2000 requested review from a team as code owners January 13, 2026 17:39
@ehayes2000 ehayes2000 force-pushed the fetch-tool branch 2 times, most recently from 7d36ce1 to 6fe2304 Compare January 13, 2026 17:43
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 13, 2026

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Jan 13, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Jan 13, 2026


Code review

No issues found. Checked for bugs and CLAUDE.md compliance.


Comment on lines +95 to +184
#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_deserialize_web_fetch_result() {
let json = r#"{
"tool_use_id": "srvtoolu_01234567890abcdef",
"content": {
"type": "web_fetch_result",
"url": "https://example.com/article",
"content": {
"source": {
"type": "text",
"media_type": "text/plain",
"data": "Full text content of the article..."
},
"title": "Article Title",
"citations": {"enabled": true}
},
"retrieved_at": "2025-08-25T10:30:00Z"
}
}"#;

let result: WebFetchResponse = serde_json::from_str(json).expect("deserialize");
assert_eq!(result.tool_use_id, "srvtoolu_01234567890abcdef");
if let WebFetchContent::WebFetchResult(r) = result.content {
assert_eq!(r.url, "https://example.com/article");
assert_eq!(r.content.title, Some("Article Title".to_string()));
} else {
panic!("Expected WebFetchResult");
}
}

#[test]
fn test_deserialize_web_fetch_pdf() {
let json = r#"{
"tool_use_id": "srvtoolu_02",
"content": {
"type": "web_fetch_result",
"url": "https://example.com/paper.pdf",
"content": {
"source": {
"type": "base64",
"media_type": "application/pdf",
"data": "JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmo..."
},
"citations": {"enabled": true}
},
"retrieved_at": "2025-08-25T10:30:02Z"
}
}"#;

let result: WebFetchResponse = serde_json::from_str(json).expect("deserialize");
if let WebFetchContent::WebFetchResult(r) = result.content {
if let WebFetchSource::Base64 { media_type, .. } = r.content.source {
assert_eq!(media_type, "application/pdf");
} else {
panic!("Expected Base64 source");
}
} else {
panic!("Expected WebFetchResult");
}
}

#[test]
fn test_deserialize_web_fetch_error() {
let json = r#"{
"tool_use_id": "srvtoolu_a93jad",
"content": {
"type": "web_fetch_tool_result_error",
"error_code": "url_not_accessible"
}
}"#;

let result: WebFetchResponse = serde_json::from_str(json).expect("deserialize");
if let WebFetchContent::WebFetchToolError(e) = result.content {
assert_eq!(e.error_code, WebFetchErrorCode::UrlNotAccessible);
} else {
panic!("Expected WebFetchToolError");
}
}

#[test]
fn test_deserialize_tool_call() {
let json = r#"{"url": "https://example.com/article"}"#;
let call: WebFetchToolCall = serde_json::from_str(json).expect("deserialize");
assert_eq!(call.url, "https://example.com/article");
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests should live in their own file.

async-openai = { workspace = true, optional = true}
chrono.workspace = true
lazy_static = {workspace = true}
regex.workspace = true
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: prefer regex = { workspace = true } syntax to match everything else

@ehayes2000 ehayes2000 merged commit 4456314 into main Jan 13, 2026
40 checks passed
@ehayes2000 ehayes2000 deleted the fetch-tool branch January 13, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants