diff --git a/packages/ai/src/providers/anthropic.ts b/packages/ai/src/providers/anthropic.ts
index ec588885..fe249db5 100644
--- a/packages/ai/src/providers/anthropic.ts
+++ b/packages/ai/src/providers/anthropic.ts
@@ -460,11 +460,20 @@ function convertMessages(messages: Message[], model: Model<"anthropic-messages">
});
} else if (block.type === "thinking") {
if (block.thinking.trim().length === 0) continue;
- blocks.push({
- type: "thinking",
- thinking: sanitizeSurrogates(block.thinking),
- signature: block.thinkingSignature || "",
- });
+ // If thinking signature is missing/empty (e.g., from aborted stream),
+ // convert to text block to avoid API rejection
+ if (!block.thinkingSignature || block.thinkingSignature.trim().length === 0) {
+ blocks.push({
+ type: "text",
+ text: sanitizeSurrogates(`\n${block.thinking}\n`),
+ });
+ } else {
+ blocks.push({
+ type: "thinking",
+ thinking: sanitizeSurrogates(block.thinking),
+ signature: block.thinkingSignature,
+ });
+ }
} else if (block.type === "toolCall") {
blocks.push({
type: "tool_use",
diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md
index 2209cd1b..e9fcb791 100644
--- a/packages/coding-agent/CHANGELOG.md
+++ b/packages/coding-agent/CHANGELOG.md
@@ -2,6 +2,10 @@
## [Unreleased]
+### Fixed
+
+- **Anthropic Aborted Thinking**: Fixed error when resubmitting assistant messages with incomplete thinking blocks (from aborted streams). Thinking blocks without valid signatures are now converted to text blocks with `` delimiters, preventing API rejection.
+
## [0.7.16] - 2025-11-17
### Fixed