Skip to content

Handle errors in anthropic's web search tool#15552

Merged
aayush-kapoor merged 1 commit into
mainfrom
error-json-websearch
May 22, 2026
Merged

Handle errors in anthropic's web search tool#15552
aayush-kapoor merged 1 commit into
mainfrom
error-json-websearch

Conversation

@msullivan
Copy link
Copy Markdown
Contributor

Background

Currently if web search returns an error, we mishandled it and
lose the tool response when continuing the conversation.

This would result in errors like:

Error: messages.1: `web_search` tool use with id `srvtoolu_01DZi3ZdTUsKUj24ZhA1XdSV` was found without a corresponding `web_search_tool_result` block

Summary

web fetch already has handling for this, so reuse that.

Manual Verification

I verified that trying to continue a conversation with an error failed
on the old version and works with this one.

Checklist

  • All commits are signed (PRs with unsigned commits cannot be merged)
  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

Currently if web search returns an error, we mishandled it and
lose the tool response when continuing the conversation.

This would result in errors like:
```
Error: messages.1: `web_search` tool use with id `srvtoolu_01DZi3ZdTUsKUj24ZhA1XdSV` was found without a corresponding `web_search_tool_result` block
```

web fetch already has handling for this, so reuse that.
@felixarntz felixarntz added the backport Admins only: add this label to a pull request in order to backport it to the prior version label May 22, 2026
@aayush-kapoor aayush-kapoor merged commit acdbf84 into main May 22, 2026
53 checks passed
@aayush-kapoor aayush-kapoor deleted the error-json-websearch branch May 22, 2026 17:13
@aayush-kapoor aayush-kapoor added backport Admins only: add this label to a pull request in order to backport it to the prior version and removed backport Admins only: add this label to a pull request in order to backport it to the prior version labels May 22, 2026
github-actions Bot added a commit that referenced this pull request May 22, 2026
@github-actions github-actions Bot removed the backport Admins only: add this label to a pull request in order to backport it to the prior version label May 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Backport to release-v6.0 created but has conflicts: #15555

aayush-kapoor added a commit that referenced this pull request May 22, 2026
This is an automated backport of #15552 to the release-v6.0 branch. FYI
@msullivan
This backport has conflicts that need to be resolved manually.

### `git cherry-pick` output

```
Auto-merging packages/anthropic/src/anthropic-messages-api.ts
Auto-merging packages/anthropic/src/convert-to-anthropic-messages-prompt.test.ts
Auto-merging packages/anthropic/src/convert-to-anthropic-messages-prompt.ts
CONFLICT (content): Merge conflict in packages/anthropic/src/convert-to-anthropic-messages-prompt.ts
error: could not apply acdbf84... Handle errors in anthropic's web search tool (#15552)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
```

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Aayush Kapoor <aayushkapoor34@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

🚀 Published in:

Package Version
@ai-sdk/amazon-bedrock 5.0.0-canary.68 github npm
@ai-sdk/anthropic 4.0.0-canary.58 github npm
@ai-sdk/google-vertex 5.0.0-canary.92 github npm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants