Skip to content

fix(ai): drop blank text from Anthropic error tool results - #461

Merged
shuv1337 merged 1 commit into
integration-v2from
cursor/anthropic-error-text-24cd
Oct 29, 2026
Merged

shuv1337 merged 1 commit into
integration-v2from
cursor/anthropic-error-text-24cd

Conversation

@shuv1337

Copy link
Copy Markdown
Owner

Issue for this PR

No tracked issue. Follow-up to the merged sync in #458.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

An Anthropic tool_result with is_error: true is rejected when it contains an empty text block. Error lowering was always emitting the error value and every content item, so an empty string or whitespace-only text became "".

Blank text items are now dropped. If nothing remains, the result is a single [tool error] text block. Omission notes such as [image omitted] are kept.

How did you verify your code works?

bun test test/provider/anthropic-messages.test.ts in packages/ai: 85 pass, 0 fail. The new cases cover an empty-string error, an error whose only content is omitted media, and whitespace-only error text. Each asserts that every text block is non-blank.

Visual

No UI change.

Screenshots / recordings

None.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
Open in Web Open in Cursor 

An empty or whitespace-only text block in an is_error tool_result is a 400.
Drop those items, and send a single [tool error] note when nothing remains.
@shuv1337
shuv1337 merged commit d436a49 into integration-v2 Oct 29, 2026
5 checks passed
@cursor cursor Bot mentioned this pull request Oct 29, 2026
3 of 6 tasks
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.

2 participants