WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Anthropic web_fetch tool failing type validation with PDFs #11019

@JustinTulloss

Description

@JustinTulloss

Description

When web_fetch is called on a PDF, I get this validation error:

Error message: [ { "code": "invalid_union", "errors": [ [ { "code": "invalid_value", "values": [ "text" ], "path": [ "content", "source", "type" ], "message": "Invalid input: expected \"text\"" } ], [ { "code": "invalid_value", "values": [ "web_fetch_tool_result_error" ], "path": [ "type" ], "message": "Invalid input: expected \"web_fetch_tool_result_error\"" }, { "expected": "string", "code": "invalid_type", "path": [ "error_code" ], "message": "Invalid input: expected string, received undefined" } ] ], "path": [ "content_block", "content" ], "message": "Invalid input" } ]

The full message appears to be valid (according to https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-fetch-tool), pasted below with the PDF content elided for brevity.

Type validation failed: Value: {"type":"content_block_start","index":10,"content_block":{"type":"web_fetch_tool_result","tool_use_id":"srvtoolu_01J56AdRLf4MjaHUq6CLqKAA","content":{"type":"web_fetch_result","url":"https://assets.unilogcorp.com/187/ITEM/DOC/Simpson_Strong_Tie_101860392_Specification_Sheet.pdf","retrieved_at":"2025-12-09T22:40:10.654602","content":{"type":"document","source":{"type":"base64","media_type":"application/pdf","data":"JVBERi0xLjcNJeLjz9MNC..."},"title":null}}}}. Error message: [ { "code": "invalid_union", "errors": [ [ { "code": "invalid_value", "values": [ "text" ], "path": [ "content", "source", "type" ], "message": "Invalid input: expected \"text\"" } ], [ { "code": "invalid_value", "values": [ "web_fetch_tool_result_error" ], "path": [ "type" ], "message": "Invalid input: expected \"web_fetch_tool_result_error\"" }, { "expected": "string", "code": "invalid_type", "path": [ "error_code" ], "message": "Invalid input: expected string, received undefined" } ] ], "path": [ "content_block", "content" ], "message": "Invalid input" } ]

AI SDK Version

  "@ai-sdk/anthropic": "^3.0.0-beta.77",
  "@ai-sdk/google": "^3.0.0-beta.66",
  "@ai-sdk/openai": "^3.0.0-beta.88",
  "ai": "^6.0.0-beta.138",

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions